Quellcode durchsuchen

Added an option to conditionally attach files to a test submission only if the test does not pass. Also some preliminary changes for test output compression.

Zach Mullen vor 16 Jahren
Ursprung
Commit
9add940eb6

+ 23 - 4
Source/CTest/cmCTestTestHandler.cxx

@@ -1259,6 +1259,14 @@ void cmCTestTestHandler::WriteTestResultFooter(std::ostream& os,
 void cmCTestTestHandler::AttachFiles(std::ostream& os,
                                      cmCTestTestResult* result)
 {
+  if(result->Status != cmCTestTestHandler::COMPLETED
+     && result->Properties->AttachOnFail.size())
+    {
+    result->Properties->AttachedFiles.insert(
+      result->Properties->AttachedFiles.end(),
+      result->Properties->AttachOnFail.begin(),
+      result->Properties->AttachOnFail.end());
+    }
   for(std::vector<std::string>::const_iterator file = 
       result->Properties->AttachedFiles.begin();
       file != result->Properties->AttachedFiles.end(); ++file)
@@ -1268,9 +1276,9 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os,
     os << "\t\t<NamedMeasurement name=\"Attached File\" encoding=\"base64\" "
       "compression=\"tar/gzip\" filename=\"" << fname << "\" type=\"file\">"
       "\n\t\t\t<Value>\n\t\t\t"
-     << base64
-     << "\n\t\t\t</Value>\n\t\t</NamedMeasurement>\n";
-    } 
+      << base64
+      << "\n\t\t\t</Value>\n\t\t</NamedMeasurement>\n";
+    }
 }
 
 //----------------------------------------------------------------------
@@ -1355,7 +1363,7 @@ void cmCTestTestHandler
                     std::vector<std::string> &attemptedConfigs,
                     std::string filepath,
                     std::string &filename)
-{   
+{
   std::string tempPath;
 
   if (filepath.size() && 
@@ -2077,6 +2085,17 @@ bool cmCTestTestHandler::SetTestsProperties(
               rtit->AttachedFiles.push_back(*f);
               }
             }
+          if ( key == "ATTACHED_FILES_ON_FAIL" )
+            {
+            std::vector<std::string> lval;
+            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+
+            for(std::vector<std::string>::iterator f = lval.begin();
+                f != lval.end(); ++f)
+              {
+              rtit->AttachOnFail.push_back(*f);
+              }
+            }
           if ( key == "TIMEOUT" )
             {
             rtit->Timeout = atof(val.c_str());

+ 1 - 0
Source/CTest/cmCTestTestHandler.h

@@ -87,6 +87,7 @@ public:
     std::vector<std::string> RequiredFiles;
     std::vector<std::string> Depends;
     std::vector<std::string> AttachedFiles;
+    std::vector<std::string> AttachOnFail;
     std::vector<std::pair<cmsys::RegularExpression,
                           std::string> > ErrorRegularExpressions;
     std::vector<std::pair<cmsys::RegularExpression,

+ 6 - 0
Source/cmCTest.cxx

@@ -221,6 +221,7 @@ cmCTest::cmCTest()
   this->ShowOnly               = false;
   this->RunConfigurationScript = false;
   this->UseHTTP10              = false;
+  this->CompressTestOutput     = true;
   this->TestModel              = cmCTest::EXPERIMENTAL;
   this->MaxTestNameWidth       = 30;
   this->InteractiveDebugMode   = true;
@@ -1705,6 +1706,11 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
     this->SetParallelLevel(plevel);
     }
 
+  if(this->CheckArgument(arg, "--no-compress-output"))
+    {
+    this->CompressTestOutput = false;
+    }
+
   if(this->CheckArgument(arg, "--http1.0"))
     {
     this->UseHTTP10 = true;

+ 4 - 0
Source/cmCTest.h

@@ -195,6 +195,8 @@ public:
 
   bool ShouldUseHTTP10() { return this->UseHTTP10; }
 
+  bool ShouldCompressTestOutput() { return this->CompressTestOutput; }
+
   //Used for parallel ctest job scheduling
   std::string GetScheduleType() { return this->ScheduleType; }
   void SetScheduleType(std::string type) { this->ScheduleType = type; }
@@ -446,6 +448,8 @@ private:
 
   bool                     CompressXMLFiles;
 
+  bool                     CompressTestOutput;
+
   void InitStreams();
   std::ostream* StreamOut;
   std::ostream* StreamErr;

+ 3 - 1
Source/cmSetTestsPropertiesCommand.h

@@ -78,7 +78,9 @@ public:
       "for the test to be run.\n"
       "ATTACHED_FILES: Set this property to a list of files that will be "
       "encoded and submitted to the dashboard as an addition to the test "
-      "result.\n";
+      "result.\n"
+      "ATTACHED_FILES_ON_FAIL: Same as ATTACHED_FILES, but these files will "
+      "only be included if the test does not pass.\n";
     }
 
   cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);

+ 4 - 0
Source/ctest.cxx

@@ -221,6 +221,10 @@ static const char * cmDocumentationOptions[][3] =
   {"--http1.0", "Submit using HTTP 1.0.",
   "This option will force CTest to use HTTP 1.0 to submit files to the "
   "dashboard, instead of HTTP 1.1."},
+  {"--no-compress-output", "Do not compress test output when submitting.",
+   "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."},
   {"--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.",