Do not exit if stoptime is passed.

This commit is contained in:
Zach Mullen 2010-06-15 10:29:35 -04:00
parent d714b18ac5
commit 960dc2b10f
5 changed files with 32 additions and 6 deletions

View File

@ -23,6 +23,7 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler()
this->ParallelLevel = 1; this->ParallelLevel = 1;
this->Completed = 0; this->Completed = 0;
this->RunningCount = 0; this->RunningCount = 0;
this->StopTimePassed = false;
} }
cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler() cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler()
@ -69,6 +70,10 @@ void cmCTestMultiProcessHandler::RunTests()
this->StartNextTests(); this->StartNextTests();
while(this->Tests.size() != 0) while(this->Tests.size() != 0)
{ {
if(this->StopTimePassed)
{
return;
}
this->CheckOutput(); this->CheckOutput();
this->StartNextTests(); this->StartNextTests();
} }
@ -102,6 +107,12 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
{ {
this->RunningTests.insert(testRun); this->RunningTests.insert(testRun);
} }
else if(testRun->IsStopTimePassed())
{
this->StopTimePassed = true;
delete testRun;
return;
}
else else
{ {
this->UnlockResources(test); this->UnlockResources(test);
@ -251,6 +262,10 @@ void cmCTestMultiProcessHandler::StartNextTests()
} }
if(this->StartTest(*test)) if(this->StartTest(*test))
{ {
if(this->StopTimePassed)
{
return;
}
numToStart -= processors; numToStart -= processors;
this->RunningCount += processors; this->RunningCount += processors;
} }

View File

@ -94,6 +94,7 @@ protected:
//Number of tests that are complete //Number of tests that are complete
size_t Completed; size_t Completed;
size_t RunningCount; size_t RunningCount;
bool StopTimePassed;
//list of test properties (indices concurrent to the test map) //list of test properties (indices concurrent to the test map)
PropertiesMap Properties; PropertiesMap Properties;
std::map<int, bool> TestRunningMap; std::map<int, bool> TestRunningMap;

View File

@ -32,6 +32,7 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
this->ProcessOutput = ""; this->ProcessOutput = "";
this->CompressedOutput = ""; this->CompressedOutput = "";
this->CompressionRatio = 2; this->CompressionRatio = 2;
this->StopTimePassed = false;
} }
cmCTestRunTest::~cmCTestRunTest() cmCTestRunTest::~cmCTestRunTest()
@ -436,8 +437,13 @@ bool cmCTestRunTest::StartTest(size_t total)
} }
this->StartTime = this->CTest->CurrentTime(); this->StartTime = this->CTest->CurrentTime();
return this->ForkProcess(this->ResolveTimeout(), double timeout = this->ResolveTimeout();
&this->TestProperties->Environment);
if(this->StopTimePassed)
{
return false;
}
return this->ForkProcess(timeout, &this->TestProperties->Environment);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -569,8 +575,9 @@ double cmCTestRunTest::ResolveTimeout()
if(stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout) if(stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout)
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. " cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
"Exiting ctest." << std::endl); "Stopping all tests." << std::endl);
exit(-1); this->StopTimePassed = true;
return 0;
} }
return timeout == 0 ? stop_timeout : return timeout == 0 ? stop_timeout :
(timeout < stop_timeout ? timeout : stop_timeout); (timeout < stop_timeout ? timeout : stop_timeout);

View File

@ -39,6 +39,8 @@ 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; }
@ -90,6 +92,7 @@ private:
std::string TestCommand; std::string TestCommand;
std::string ActualCommand; std::string ActualCommand;
std::vector<std::string> Arguments; std::vector<std::string> Arguments;
bool StopTimePassed;
}; };
inline int getNumWidth(size_t n) inline int getNumWidth(size_t n)