diff options
author | Ken Martin <ken.martin@kitware.com> | 2007-01-30 16:35:17 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2007-01-30 16:35:17 (GMT) |
commit | 49085f7fedfe467211129205349edaeb9b195a18 (patch) | |
tree | 3a5bdc8d6c50059d926e20ca7e1052b269cb3783 /Source/CTest | |
parent | b32f3b4131294b0d4d8895cecf3bb2df11ff434c (diff) | |
download | CMake-49085f7fedfe467211129205349edaeb9b195a18.zip CMake-49085f7fedfe467211129205349edaeb9b195a18.tar.gz CMake-49085f7fedfe467211129205349edaeb9b195a18.tar.bz2 |
BUG: fixes so that --build-and-test will honor timeouts
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestBuildAndTestHandler.cxx | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index f7b7481..c470299 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -161,6 +161,10 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) return 1; } + // we need to honor the timeout specified, the timeout include cmake, build + // and test time + double clock_start = cmSystemTools::GetTime(); + // make sure the binary dir is there std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); out << "Internal cmake changing into directory: " @@ -178,7 +182,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) if(!this->BuildNoCMake) { - // do the cmake step + // do the cmake step, no timeout here since it is not a sub process if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm)) { return 1; @@ -194,12 +198,27 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) for ( tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end(); ++ tarIt ) { + double remainingTime = 0; + if (this->Timeout) + { + remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start; + if (remainingTime <= 0) + { + if(outstring) + { + *outstring = "--build-and-test timeout exceeded. "; + } + return 1; + } + } std::string output; int retVal = cm.GetGlobalGenerator()->Build( this->SourceDir.c_str(), this->BinaryDir.c_str(), this->BuildProject.c_str(), tarIt->c_str(), &output, this->BuildMakeProgram.c_str(), - this->CTest->GetConfigType().c_str(),!this->BuildNoClean, false); + this->CTest->GetConfigType().c_str(), + !this->BuildNoClean, + false, remainingTime); out << output; // if the build failed then return @@ -361,8 +380,25 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) out << this->TestCommandArgs[k] << " "; } out << "\n"; + + // how much time is remaining + double remainingTime = 0; + if (this->Timeout) + { + remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start; + if (remainingTime <= 0) + { + if(outstring) + { + *outstring = "--build-and-test timeout exceeded. "; + } + return 1; + } + } + int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0, - this->Timeout); + remainingTime); + if(runTestRes != cmsysProcess_State_Exited || retval != 0) { out << "Failed to run test command: " << testCommand[0] << "\n"; |