diff options
author | Ken Martin <ken.martin@kitware.com> | 2006-10-19 14:45:19 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2006-10-19 14:45:19 (GMT) |
commit | f7a5289e318e3802737a2629c7fe2ed24dbfc5b9 (patch) | |
tree | 200ff8466c8dd3da1cec87f51689eaea6651b50e /Source/CTest | |
parent | 2fd1b374c17f4da904a0f3e62802a352f8ab6c72 (diff) | |
download | CMake-f7a5289e318e3802737a2629c7fe2ed24dbfc5b9.zip CMake-f7a5289e318e3802737a2629c7fe2ed24dbfc5b9.tar.gz CMake-f7a5289e318e3802737a2629c7fe2ed24dbfc5b9.tar.bz2 |
ENH: added total time limit for a CTest run bug 1207
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.cxx | 21 | ||||
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.h | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 8 |
5 files changed, 48 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 47c708b..e0d7c84 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -250,6 +250,12 @@ int cmCTestBuildHandler::ProcessHandler() { cmCTestLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl); + // do we have time for this + if (this->CTest->GetRemainingTimeAllowed() < 120) + { + return 0; + } + int entry; for ( entry = 0; cmCTestWarningErrorFileLine[entry].RegularExpressionString; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 8a0dad8..b0dee01 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -180,6 +180,12 @@ int cmCTestCoverageHandler::ProcessHandler() { int error = 0; + // do we have time for this + if (this->CTest->GetRemainingTimeAllowed() < 120) + { + return error; + } + std::string sourceDir = this->CTest->GetCTestConfiguration("SourceDirectory"); std::string binaryDir diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 905a40b..0346e43 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -965,3 +965,24 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname) } return true; } + +//------------------------------------------------------------------------- +double cmCTestScriptHandler::GetRemainingTimeAllowed() +{ + if (!this->Makefile) + { + return 1.0e7; + } + + const char *timelimitS + = this->Makefile->GetDefinition("CTEST_TIME_LIMIT"); + + if (!timelimitS) + { + return 1.0e7; + } + + double timelimit = atof(timelimitS); + + return timelimit - cmSystemTools::GetTime() + this->ScriptStartTime; +} diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 503ddcc..f82f3ea 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -96,6 +96,13 @@ public: static void SleepInSeconds(unsigned int secondsToWait); void UpdateElapsedTime(); + /** + * Return the time remaianing that the script is allowed to run in + * seconds if the user has set the variable CTEST_TIME_LIMIT. If that has + * not been set it returns 1e7 seconds + */ + double GetRemainingTimeAllowed(); + cmCTestScriptHandler(); ~cmCTestScriptHandler(); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index c1a8dc8..fef7e42 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -605,6 +605,14 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, { inREcnt++; } + + // if we are out of time then skip this test, we leave two minutes + // to submit results + if (this->CTest->GetRemainingTimeAllowed() - 120 <= 0) + { + continue; + } + const std::string& testname = it->Name; std::vector<std::string>& args = it->Args; cmCTestTestResult cres; |