소스 검색

cmCTestMultiProcessHandler: Check stop time more directly

Avoid creating a cmCTestRunTest instance if the stop time has been
reached.  If the stop time occurs in the small time between creating an
instance and computing the child process timeout, we will simply compute
a zero timeout.  This is already done for the case that we StartAgain
after the stop time.
Brad King 8 년 전
부모
커밋
61ab5a8ef4
3개의 변경된 파일14개의 추가작업 그리고 14개의 파일을 삭제
  1. 11 4
      Source/CTest/cmCTestMultiProcessHandler.cxx
  2. 3 7
      Source/CTest/cmCTestRunTest.cxx
  3. 0 3
      Source/CTest/cmCTestRunTest.h

+ 11 - 4
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -13,6 +13,7 @@
 #include "cmsys/String.hxx"
 #include "cmsys/String.hxx"
 #include "cmsys/SystemInformation.hxx"
 #include "cmsys/SystemInformation.hxx"
 #include <algorithm>
 #include <algorithm>
+#include <chrono>
 #include <iomanip>
 #include <iomanip>
 #include <list>
 #include <list>
 #include <math.h>
 #include <math.h>
@@ -113,6 +114,16 @@ void cmCTestMultiProcessHandler::RunTests()
 
 
 void cmCTestMultiProcessHandler::StartTestProcess(int test)
 void cmCTestMultiProcessHandler::StartTestProcess(int test)
 {
 {
+  std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime();
+  if (stop_time != std::chrono::system_clock::time_point() &&
+      stop_time <= std::chrono::system_clock::now()) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
+                                           "Stopping all tests."
+                 << std::endl);
+    this->StopTimePassed = true;
+    return;
+  }
+
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                      "test " << test << "\n", this->Quiet);
                      "test " << test << "\n", this->Quiet);
   this->TestRunningMap[test] = true; // mark the test as running
   this->TestRunningMap[test] = true; // mark the test as running
@@ -144,10 +155,6 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
 
 
   if (testRun->StartTest(this->Total)) {
   if (testRun->StartTest(this->Total)) {
     this->RunningTests.insert(testRun);
     this->RunningTests.insert(testRun);
-  } else if (testRun->IsStopTimePassed()) {
-    this->StopTimePassed = true;
-    delete testRun;
-    return;
   } else {
   } else {
 
 
     for (auto& j : this->Tests) {
     for (auto& j : this->Tests) {

+ 3 - 7
Source/CTest/cmCTestRunTest.cxx

@@ -15,6 +15,7 @@
 #include "cmsys/RegularExpression.hxx"
 #include "cmsys/RegularExpression.hxx"
 #include <chrono>
 #include <chrono>
 #include <iomanip>
 #include <iomanip>
+#include <ratio>
 #include <sstream>
 #include <sstream>
 #include <stdio.h>
 #include <stdio.h>
 #include <utility>
 #include <utility>
@@ -32,7 +33,6 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
   this->ProcessOutput.clear();
   this->ProcessOutput.clear();
   this->CompressedOutput.clear();
   this->CompressedOutput.clear();
   this->CompressionRatio = 2;
   this->CompressionRatio = 2;
-  this->StopTimePassed = false;
   this->NumberOfRunsLeft = 1; // default to 1 run of the test
   this->NumberOfRunsLeft = 1; // default to 1 run of the test
   this->RunUntilFail = false; // default to run the test once
   this->RunUntilFail = false; // default to run the test once
   this->RunAgain = false;     // default to not having to run again
   this->RunAgain = false;     // default to not having to run again
@@ -524,15 +524,11 @@ bool cmCTestRunTest::StartTest(size_t total)
 
 
   std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime();
   std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime();
   if (stop_time != std::chrono::system_clock::time_point()) {
   if (stop_time != std::chrono::system_clock::time_point()) {
-    auto stop_timeout =
+    std::chrono::duration<double> stop_timeout =
       (stop_time - std::chrono::system_clock::now()) % std::chrono::hours(24);
       (stop_time - std::chrono::system_clock::now()) % std::chrono::hours(24);
 
 
     if (stop_timeout <= std::chrono::duration<double>::zero()) {
     if (stop_timeout <= std::chrono::duration<double>::zero()) {
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
-                                             "Stopping all tests."
-                   << std::endl);
-      this->StopTimePassed = true;
-      return false;
+      stop_timeout = std::chrono::duration<double>::zero();
     }
     }
     if (timeout == std::chrono::duration<double>::zero() ||
     if (timeout == std::chrono::duration<double>::zero() ||
         stop_timeout < timeout) {
         stop_timeout < timeout) {

+ 0 - 3
Source/CTest/cmCTestRunTest.h

@@ -50,8 +50,6 @@ public:
 
 
   std::string GetProcessOutput() { return this->ProcessOutput; }
   std::string GetProcessOutput() { return this->ProcessOutput; }
 
 
-  bool IsStopTimePassed() { return this->StopTimePassed; }
-
   cmCTestTestHandler::cmCTestTestResult GetTestResults()
   cmCTestTestHandler::cmCTestTestResult GetTestResults()
   {
   {
     return this->TestResult;
     return this->TestResult;
@@ -108,7 +106,6 @@ private:
   std::string StartTime;
   std::string StartTime;
   std::string ActualCommand;
   std::string ActualCommand;
   std::vector<std::string> Arguments;
   std::vector<std::string> Arguments;
-  bool StopTimePassed;
   bool RunUntilFail;
   bool RunUntilFail;
   int NumberOfRunsLeft;
   int NumberOfRunsLeft;
   bool RunAgain;
   bool RunAgain;