Преглед на файлове

Added CTest command --print-labels

This command allows a user to quickly see the list of all available
test labels.  The labels are also printed in verbose show only mode,
alongside their corresponding tests.
Zach Mullen преди 15 години
родител
ревизия
32242affea

+ 42 - 0
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -516,11 +516,13 @@ void cmCTestMultiProcessHandler::PrintTestList()
 {
 {
   this->TestHandler->SetMaxIndex(this->FindMaxIndex());
   this->TestHandler->SetMaxIndex(this->FindMaxIndex());
   int count = 0;
   int count = 0;
+
   for (PropertiesMap::iterator it = this->Properties.begin();
   for (PropertiesMap::iterator it = this->Properties.begin();
        it != this->Properties.end(); ++it)
        it != this->Properties.end(); ++it)
     {
     {
     count++;
     count++;
     cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
     cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
+
     //push working dir
     //push working dir
     std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
     std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
     cmSystemTools::ChangeDirectory(p.Directory.c_str());
     cmSystemTools::ChangeDirectory(p.Directory.c_str());
@@ -530,6 +532,20 @@ void cmCTestMultiProcessHandler::PrintTestList()
     testRun.SetTestProperties(&p);
     testRun.SetTestProperties(&p);
     testRun.ComputeArguments(); //logs the command in verbose mode
     testRun.ComputeArguments(); //logs the command in verbose mode
 
 
+    if(p.Labels.size()) //print the labels
+      {
+      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Labels:");
+      }
+    for(std::vector<std::string>::iterator label = p.Labels.begin();
+        label != p.Labels.end(); ++label)
+      {
+      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << *label);
+      }
+    if(p.Labels.size()) //print the labels
+      {
+      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl);
+      }
+
     if (this->TestHandler->MemCheck)
     if (this->TestHandler->MemCheck)
       {
       {
       cmCTestLog(this->CTest, HANDLER_OUTPUT, "  Memory Check");
       cmCTestLog(this->CTest, HANDLER_OUTPUT, "  Memory Check");
@@ -548,10 +564,36 @@ void cmCTestMultiProcessHandler::PrintTestList()
     //pop working dir
     //pop working dir
     cmSystemTools::ChangeDirectory(current_dir.c_str());
     cmSystemTools::ChangeDirectory(current_dir.c_str());
     }
     }
+
   cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: "
   cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: "
     << this->Total << std::endl);
     << this->Total << std::endl);
 }
 }
 
 
+void cmCTestMultiProcessHandler::PrintLabels()
+{
+  std::set<std::string> allLabels;
+  for (PropertiesMap::iterator it = this->Properties.begin();
+       it != this->Properties.end(); ++it)
+    {
+    cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
+    allLabels.insert(p.Labels.begin(), p.Labels.end());
+    }
+
+  if(allLabels.size())
+    {
+    cmCTestLog(this->CTest, HANDLER_OUTPUT, "All Labels:" << std::endl);
+    }
+  else
+    {
+    cmCTestLog(this->CTest, HANDLER_OUTPUT, "No Labels Exist" << std::endl);
+    }
+  for(std::set<std::string>::iterator label = allLabels.begin();
+      label != allLabels.end(); ++label)
+    {
+    cmCTestLog(this->CTest, HANDLER_OUTPUT, "  " << *label << std::endl);
+    }
+}
+
 //---------------------------------------------------------
 //---------------------------------------------------------
 void cmCTestMultiProcessHandler::CheckResume()
 void cmCTestMultiProcessHandler::CheckResume()
 {
 {

+ 1 - 0
Source/CTest/cmCTestMultiProcessHandler.h

@@ -39,6 +39,7 @@ public:
   void SetParallelLevel(size_t);
   void SetParallelLevel(size_t);
   virtual void RunTests();
   virtual void RunTests();
   void PrintTestList();
   void PrintTestList();
+  void PrintLabels();
 
 
   void SetPassFailVectors(std::vector<cmStdString>* passed,
   void SetPassFailVectors(std::vector<cmStdString>* passed,
                           std::vector<cmStdString>* failed)
                           std::vector<cmStdString>* failed)

+ 7 - 2
Source/CTest/cmCTestTestHandler.cxx

@@ -567,7 +567,7 @@ int cmCTestTestHandler::ProcessHandler()
 
 
   if (total == 0)
   if (total == 0)
     {
     {
-    if ( !this->CTest->GetShowOnly() )
+    if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
       {
       {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "No tests were found!!!"
       cmCTestLog(this->CTest, ERROR_MESSAGE, "No tests were found!!!"
         << std::endl);
         << std::endl);
@@ -1079,7 +1079,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
   parallel->SetPassFailVectors(&passed, &failed);
   parallel->SetPassFailVectors(&passed, &failed);
   this->TestResults.clear();
   this->TestResults.clear();
   parallel->SetTestResults(&this->TestResults);
   parallel->SetTestResults(&this->TestResults);
-  if(this->CTest->GetShowOnly())
+
+  if(this->CTest->ShouldPrintLabels())
+    {
+    parallel->PrintLabels();
+    }
+  else if(this->CTest->GetShowOnly())
     {
     {
     parallel->PrintTestList();
     parallel->PrintTestList();
     }
     }

+ 6 - 0
Source/cmCTest.cxx

@@ -304,6 +304,7 @@ cmCTest::cmCTest()
   this->ShowOnly               = false;
   this->ShowOnly               = false;
   this->RunConfigurationScript = false;
   this->RunConfigurationScript = false;
   this->UseHTTP10              = false;
   this->UseHTTP10              = false;
+  this->PrintLabels            = false;
   this->CompressTestOutput     = true;
   this->CompressTestOutput     = true;
   this->ComputedCompressOutput = false;
   this->ComputedCompressOutput = false;
   this->TestModel              = cmCTest::EXPERIMENTAL;
   this->TestModel              = cmCTest::EXPERIMENTAL;
@@ -1877,6 +1878,11 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
     this->CompressTestOutput = false;
     this->CompressTestOutput = false;
     }
     }
 
 
+  if(this->CheckArgument(arg, "--print-labels"))
+    {
+    this->PrintLabels = true;
+    }
+
   if(this->CheckArgument(arg, "--http1.0"))
   if(this->CheckArgument(arg, "--http1.0"))
     {
     {
     this->UseHTTP10 = true;
     this->UseHTTP10 = true;

+ 3 - 0
Source/cmCTest.h

@@ -210,6 +210,8 @@ public:
 
 
   bool ShouldUseHTTP10() { return this->UseHTTP10; }
   bool ShouldUseHTTP10() { return this->UseHTTP10; }
 
 
+  bool ShouldPrintLabels() { return this->PrintLabels; }
+
   bool ShouldCompressTestOutput();
   bool ShouldCompressTestOutput();
 
 
   std::string GetCDashVersion();
   std::string GetCDashVersion();
@@ -413,6 +415,7 @@ private:
   bool ProduceXML;
   bool ProduceXML;
   bool LabelSummary;
   bool LabelSummary;
   bool UseHTTP10;
   bool UseHTTP10;
+  bool PrintLabels;
   bool Failover;
   bool Failover;
   bool BatchJobs;
   bool BatchJobs;
 
 

+ 4 - 1
Source/ctest.cxx

@@ -152,7 +152,7 @@ static const char * cmDocumentationOptions[][3] =
    "popups and interactive "
    "popups and interactive "
    "debugging."},
    "debugging."},
   {"--no-label-summary", "Disable timing summary information for labels.",
   {"--no-label-summary", "Disable timing summary information for labels.",
-   "This option tells ctest to not print summary information for each label "
+   "This option tells ctest not to print summary information for each label "
    "associated with the tests run. If there are no labels on the "
    "associated with the tests run. If there are no labels on the "
    "tests, nothing extra is printed."},
    "tests, nothing extra is printed."},
   {"--build-and-test", "Configure, build and run a test.",
   {"--build-and-test", "Configure, build and run a test.",
@@ -229,6 +229,9 @@ static const char * cmDocumentationOptions[][3] =
    "This flag will turn off automatic compression of test output.  Use this "
    "This flag will turn off automatic compression of test output.  Use this "
    "to maintain compatibility with an older version of CDash which doesn't "
    "to maintain compatibility with an older version of CDash which doesn't "
    "support compressed test output."},
    "support compressed test output."},
+  {"--print-labels", "Print all available test labels.",
+   "This option will not run any tests, it will simply print the list of "
+   "all labels associated with the test set."},
   {"--help-command <cmd> [<file>]", "Show help for a single command and exit.",
   {"--help-command <cmd> [<file>]", "Show help for a single command and exit.",
    "Prints the help for the command to stdout or to the specified file." },
    "Prints the help for the command to stdout or to the specified file." },
   {"--help-command-list [<file>]", "List available commands and exit.",
   {"--help-command-list [<file>]", "List available commands and exit.",

+ 5 - 0
Tests/CMakeLists.txt

@@ -1315,6 +1315,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
     --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log"
     --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log"
     )
     )
 
 
+  ADD_TEST(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels)
+  SET_TESTS_PROPERTIES(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2")
+  SET_TESTS_PROPERTIES(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION
+    "All Labels:.*  Label1.*  Label2")
+
   CONFIGURE_FILE(
   CONFIGURE_FILE(
     "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
     "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
     "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"
     "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"