From a175613a561d50dc1b2d39d052e11563cd6d8d57 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 6 Jun 2007 11:02:24 -0400 Subject: [PATCH] BUG: better passing of global TIMEOUT to internal ctest invocaitons --- Source/CTest/cmCTestBuildAndTestHandler.cxx | 22 ++++++------- Source/cmCTest.cxx | 36 ++++++++++----------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 83ccb1996..2855cae26 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -218,8 +218,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) { this->BuildTargets.push_back(""); } - for ( tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end(); - ++ tarIt ) + for ( tarIt = this->BuildTargets.begin(); + tarIt != this->BuildTargets.end(); ++ tarIt ) { double remainingTime = 0; if (this->Timeout) @@ -332,19 +332,19 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) out << "\n"; // how much time is remaining - double remainingTime = 0; - if (this->Timeout) + double remainingTime = 0; + if (this->Timeout) + { + remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start; + if (remainingTime <= 0) { - remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start; - if (remainingTime <= 0) + if(outstring) { - if(outstring) - { - *outstring = "--build-and-test timeout exceeded. "; - } - return 1; + *outstring = "--build-and-test timeout exceeded. "; } + return 1; } + } int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0, remainingTime); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index db6c38cda..149fb8493 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1083,12 +1083,28 @@ int cmCTest::RunTest(std::vector argv, std::string* output, int *retVal, std::ostream* log, double testTimeOut) { + // determine how much time we have + double timeout = this->GetRemainingTimeAllowed() - 120; + if (this->TimeOut && this->TimeOut < timeout) + { + timeout = this->TimeOut; + } + if (testTimeOut && testTimeOut < timeout) + { + timeout = testTimeOut; + } + // always have at least 1 second if we got to here + if (timeout <= 0) + { + timeout = 1; + } + if(cmSystemTools::SameFile(argv[0], this->CTestSelf.c_str()) && !this->ForceNewCTestProcess) { cmCTest inst; inst.ConfigType = this->ConfigType; - inst.TimeOut = this->TimeOut; + inst.TimeOut = timeout; std::vector args; for(unsigned int i =0; i < argv.size(); ++i) { @@ -1101,7 +1117,7 @@ int cmCTest::RunTest(std::vector argv, { args.push_back("--test-timeout"); cmOStringStream msg; - msg << testTimeOut; + msg << timeout; args.push_back(msg.str()); } args.push_back(argv[i]); @@ -1139,22 +1155,6 @@ int cmCTest::RunTest(std::vector 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; - } - if (testTimeOut && testTimeOut < timeout) - { - timeout = testTimeOut; - } - // always have at least 1 second if we got to here - if (timeout <= 0) - { - timeout = 1; - } - cmsysProcess_SetTimeout(cp, timeout); cmsysProcess_Execute(cp);