瀏覽代碼

Added support for CTest awareness of the CDash version. This will help forward compatibility for both tools. Note that this changeset effectively makes the default to disable output compression. Now, to enable output compression, the CDASH_CTEST_VERSION must be explicity set to >= 1.6. Automated detection of the CDash version is the next step.

Zach Mullen 16 年之前
父節點
當前提交
7af553188e
共有 6 個文件被更改,包括 63 次插入1 次删除
  1. 1 0
      CTestConfig.cmake
  2. 1 0
      Modules/DartConfiguration.tcl.in
  3. 19 0
      Source/cmCTest.cxx
  4. 4 1
      Source/cmCTest.h
  5. 27 0
      Source/cmSystemTools.cxx
  6. 11 0
      Source/cmSystemTools.h

+ 1 - 0
CTestConfig.cmake

@@ -16,6 +16,7 @@ set(CTEST_DROP_METHOD "http")
 set(CTEST_DROP_SITE "www.cdash.org")
 set(CTEST_DROP_LOCATION "/CDash/submit.php?project=CMake")
 set(CTEST_DROP_SITE_CDASH TRUE)
+set(CTEST_CDASH_VERSION "1.4")
 
 # use old trigger stuff so that cmake 2.4 and below will not 
 # get errors on trigger

+ 1 - 0
Modules/DartConfiguration.tcl.in

@@ -15,6 +15,7 @@ BuildName: @BUILDNAME@
 
 # Submission information
 IsCDash: @CTEST_DROP_SITE_CDASH@
+CDashVersion: @CTEST_CDASH_VERSION@
 DropSite: @DROP_SITE@
 DropLocation: @DROP_LOCATION@
 DropSiteUser: @DROP_SITE_USER@

+ 19 - 0
Source/cmCTest.cxx

@@ -222,6 +222,7 @@ cmCTest::cmCTest()
   this->RunConfigurationScript = false;
   this->UseHTTP10              = false;
   this->CompressTestOutput     = true;
+  this->ComputedCompressOutput = false;
   this->TestModel              = cmCTest::EXPERIMENTAL;
   this->MaxTestNameWidth       = 30;
   this->InteractiveDebugMode   = true;
@@ -299,6 +300,24 @@ void cmCTest::SetParallelLevel(int level)
   this->ParallelLevel = level < 1 ? 1 : level;
 }
 
+//----------------------------------------------------------------------------
+bool cmCTest::ShouldCompressTestOutput()
+{
+  if(!this->ComputedCompressOutput)
+    {   
+    std::string cdashVersion = 
+      this->GetCTestConfiguration("CDashVersion");
+    //version >= 1.6?
+    bool cdashSupportsGzip = cmSystemTools::VersionCompare(
+      cmSystemTools::OP_GREATER, cdashVersion.c_str(), "1.6") ||
+      cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
+      cdashVersion.c_str(), "1.6");
+    this->CompressTestOutput &= cdashSupportsGzip;
+    this->ComputedCompressOutput = true;
+    }
+  return this->CompressTestOutput;
+}
+
 //----------------------------------------------------------------------------
 cmCTest::Part cmCTest::GetPartFromName(const char* name)
 {

+ 4 - 1
Source/cmCTest.h

@@ -195,7 +195,7 @@ public:
 
   bool ShouldUseHTTP10() { return this->UseHTTP10; }
 
-  bool ShouldCompressTestOutput() { return this->CompressTestOutput; }
+  bool ShouldCompressTestOutput();
 
   //Used for parallel ctest job scheduling
   std::string GetScheduleType() { return this->ScheduleType; }
@@ -396,6 +396,9 @@ private:
 
   bool RunConfigurationScript;
 
+  //flag for lazy getter (optimization)
+  bool ComputedCompressOutput;
+
   int GenerateNotesFile(const char* files);
 
   // these are helper classes

+ 27 - 0
Source/cmSystemTools.cxx

@@ -2690,6 +2690,33 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
 #endif
 }
 
+//----------------------------------------------------------------------------
+bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
+                                   const char* lhss, const char* rhss)
+{
+  unsigned int lhs[4] = {0,0,0,0};
+  unsigned int rhs[4] = {0,0,0,0};
+  sscanf(lhss, "%u.%u.%u.%u", &lhs[0], &lhs[1], &lhs[2], &lhs[3]);
+  sscanf(rhss, "%u.%u.%u.%u", &rhs[0], &rhs[1], &rhs[2], &rhs[3]);
+
+  // Do component-wise comparison.
+  for(unsigned int i=0; i < 4; ++i)
+    {
+    if(lhs[i] < rhs[i])
+      {
+      // lhs < rhs, so true if operation is LESS
+      return op == cmSystemTools::OP_LESS;
+      }
+    else if(lhs[i] > rhs[i])
+      {
+      // lhs > rhs, so true if operation is GREATER
+        return op == cmSystemTools::OP_GREATER;
+      }
+    }
+  // lhs == rhs, so true if operation is EQUAL
+  return op == cmSystemTools::OP_EQUAL;
+}
+
 //----------------------------------------------------------------------------
 bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
                                 bool* removed)

+ 11 - 0
Source/cmSystemTools.h

@@ -268,6 +268,17 @@ public:
     UNKNOWN_FILE_FORMAT
   };
 
+  enum CompareOp {
+    OP_LESS,
+    OP_GREATER,
+    OP_EQUAL
+  };
+
+  /**
+   * Compare versions
+   */
+  static bool VersionCompare(CompareOp op, const char* lhs, const char* rhs);
+
   /**
    * Determine the file type based on the extension
    */