Browse Source

Merge topic 'ctest-show-labels'

32242af Added CTest command --print-labels
Brad King 15 years ago
parent
commit
81fa6bbcc7

+ 42 - 0
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -516,11 +516,13 @@ void cmCTestMultiProcessHandler::PrintTestList()
 {
   this->TestHandler->SetMaxIndex(this->FindMaxIndex());
   int count = 0;
+
   for (PropertiesMap::iterator it = this->Properties.begin();
        it != this->Properties.end(); ++it)
     {
     count++;
     cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
+
     //push working dir
     std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
     cmSystemTools::ChangeDirectory(p.Directory.c_str());
@@ -530,6 +532,20 @@ void cmCTestMultiProcessHandler::PrintTestList()
     testRun.SetTestProperties(&p);
     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)
       {
       cmCTestLog(this->CTest, HANDLER_OUTPUT, "  Memory Check");
@@ -548,10 +564,36 @@ void cmCTestMultiProcessHandler::PrintTestList()
     //pop working dir
     cmSystemTools::ChangeDirectory(current_dir.c_str());
     }
+
   cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: "
     << 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()
 {

+ 1 - 0
Source/CTest/cmCTestMultiProcessHandler.h

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

+ 7 - 2
Source/CTest/cmCTestTestHandler.cxx

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

+ 6 - 0
Source/cmCTest.cxx

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

+ 3 - 0
Source/cmCTest.h

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

+ 4 - 1
Source/ctest.cxx

@@ -152,7 +152,7 @@ static const char * cmDocumentationOptions[][3] =
    "popups and interactive "
    "debugging."},
   {"--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 "
    "tests, nothing extra is printed."},
   {"--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 "
    "to maintain compatibility with an older version of CDash which doesn't "
    "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.",
    "Prints the help for the command to stdout or to the specified file." },
   {"--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"
     )
 
+  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(
     "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
     "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"