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/cmCTest.cxx | |
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/cmCTest.cxx')
-rw-r--r-- | Source/cmCTest.cxx | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 8fa576c..8d05762 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -792,7 +792,8 @@ int cmCTest::ProcessTests() break; } } - if ( this->Tests[UPDATE_TEST] || this->Tests[ALL_TEST] ) + if (( this->Tests[UPDATE_TEST] || this->Tests[ALL_TEST] ) && + (this->GetRemainingTimeAllowed() - 120 > 0)) { cmCTestGenericHandler* uphandler = this->GetHandler("update"); uphandler->SetPersistentOption("SourceDirectory", @@ -807,14 +808,16 @@ int cmCTest::ProcessTests() { return 0; } - if ( this->Tests[CONFIGURE_TEST] || this->Tests[ALL_TEST] ) + if (( this->Tests[CONFIGURE_TEST] || this->Tests[ALL_TEST] )&& + (this->GetRemainingTimeAllowed() - 120 > 0)) { if (this->GetHandler("configure")->ProcessHandler() < 0) { res |= cmCTest::CONFIGURE_ERRORS; } } - if ( this->Tests[BUILD_TEST] || this->Tests[ALL_TEST] ) + if (( this->Tests[BUILD_TEST] || this->Tests[ALL_TEST] )&& + (this->GetRemainingTimeAllowed() - 120 > 0)) { this->UpdateCTestConfiguration(); if (this->GetHandler("build")->ProcessHandler() < 0) @@ -822,7 +825,8 @@ int cmCTest::ProcessTests() res |= cmCTest::BUILD_ERRORS; } } - if ( this->Tests[TEST_TEST] || this->Tests[ALL_TEST] || notest ) + if (( this->Tests[TEST_TEST] || this->Tests[ALL_TEST] || notest ) && + (this->GetRemainingTimeAllowed() - 120 > 0)) { this->UpdateCTestConfiguration(); if (this->GetHandler("test")->ProcessHandler() < 0) @@ -830,7 +834,8 @@ int cmCTest::ProcessTests() res |= cmCTest::TEST_ERRORS; } } - if ( this->Tests[COVERAGE_TEST] || this->Tests[ALL_TEST] ) + if (( this->Tests[COVERAGE_TEST] || this->Tests[ALL_TEST] ) && + (this->GetRemainingTimeAllowed() - 120 > 0)) { this->UpdateCTestConfiguration(); if (this->GetHandler("coverage")->ProcessHandler() < 0) @@ -838,7 +843,8 @@ int cmCTest::ProcessTests() res |= cmCTest::COVERAGE_ERRORS; } } - if ( this->Tests[MEMCHECK_TEST] || this->Tests[ALL_TEST] ) + if (( this->Tests[MEMCHECK_TEST] || this->Tests[ALL_TEST] )&& + (this->GetRemainingTimeAllowed() - 120 > 0)) { this->UpdateCTestConfiguration(); if (this->GetHandler("memcheck")->ProcessHandler() < 0) @@ -1109,6 +1115,19 @@ int cmCTest::RunTest(std::vector<const char*> argv, { cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); } + + // do we have time for + double timeout = this->GetRemainingTimeAllowed() - 120; + if (this->TimeOut && this->TimeOut < timeout) + { + timeout = this->TimeOut; + } + // always have at least 1 second if we got to here + if (timeout <= 0) + { + timeout = 1; + } + cmsysProcess_SetTimeout(cp, this->TimeOut); cmsysProcess_Execute(cp); @@ -2547,3 +2566,16 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg) } } +//------------------------------------------------------------------------- +double cmCTest::GetRemainingTimeAllowed() +{ + if (!this->GetHandler("script")) + { + return 1.0e7; + } + + cmCTestScriptHandler* ch + = static_cast<cmCTestScriptHandler*>(this->GetHandler("script")); + + return ch->GetRemainingTimeAllowed(); +} |