ENH: added total time limit for a CTest run bug 1207
This commit is contained in:
parent
2fd1b374c1
commit
f7a5289e31
@ -250,6 +250,12 @@ int cmCTestBuildHandler::ProcessHandler()
|
|||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl);
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl);
|
||||||
|
|
||||||
|
// do we have time for this
|
||||||
|
if (this->CTest->GetRemainingTimeAllowed() < 120)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int entry;
|
int entry;
|
||||||
for ( entry = 0;
|
for ( entry = 0;
|
||||||
cmCTestWarningErrorFileLine[entry].RegularExpressionString;
|
cmCTestWarningErrorFileLine[entry].RegularExpressionString;
|
||||||
|
@ -180,6 +180,12 @@ int cmCTestCoverageHandler::ProcessHandler()
|
|||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
|
// do we have time for this
|
||||||
|
if (this->CTest->GetRemainingTimeAllowed() < 120)
|
||||||
|
{
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
std::string sourceDir
|
std::string sourceDir
|
||||||
= this->CTest->GetCTestConfiguration("SourceDirectory");
|
= this->CTest->GetCTestConfiguration("SourceDirectory");
|
||||||
std::string binaryDir
|
std::string binaryDir
|
||||||
|
@ -965,3 +965,24 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname)
|
|||||||
}
|
}
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
@ -96,6 +96,13 @@ public:
|
|||||||
static void SleepInSeconds(unsigned int secondsToWait);
|
static void SleepInSeconds(unsigned int secondsToWait);
|
||||||
void UpdateElapsedTime();
|
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();
|
||||||
~cmCTestScriptHandler();
|
~cmCTestScriptHandler();
|
||||||
|
|
||||||
|
@ -605,6 +605,14 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
|
|||||||
{
|
{
|
||||||
inREcnt++;
|
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;
|
const std::string& testname = it->Name;
|
||||||
std::vector<std::string>& args = it->Args;
|
std::vector<std::string>& args = it->Args;
|
||||||
cmCTestTestResult cres;
|
cmCTestTestResult cres;
|
||||||
|
@ -792,7 +792,8 @@ int cmCTest::ProcessTests()
|
|||||||
break;
|
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");
|
cmCTestGenericHandler* uphandler = this->GetHandler("update");
|
||||||
uphandler->SetPersistentOption("SourceDirectory",
|
uphandler->SetPersistentOption("SourceDirectory",
|
||||||
@ -807,14 +808,16 @@ int cmCTest::ProcessTests()
|
|||||||
{
|
{
|
||||||
return 0;
|
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)
|
if (this->GetHandler("configure")->ProcessHandler() < 0)
|
||||||
{
|
{
|
||||||
res |= cmCTest::CONFIGURE_ERRORS;
|
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();
|
this->UpdateCTestConfiguration();
|
||||||
if (this->GetHandler("build")->ProcessHandler() < 0)
|
if (this->GetHandler("build")->ProcessHandler() < 0)
|
||||||
@ -822,7 +825,8 @@ int cmCTest::ProcessTests()
|
|||||||
res |= cmCTest::BUILD_ERRORS;
|
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();
|
this->UpdateCTestConfiguration();
|
||||||
if (this->GetHandler("test")->ProcessHandler() < 0)
|
if (this->GetHandler("test")->ProcessHandler() < 0)
|
||||||
@ -830,7 +834,8 @@ int cmCTest::ProcessTests()
|
|||||||
res |= cmCTest::TEST_ERRORS;
|
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();
|
this->UpdateCTestConfiguration();
|
||||||
if (this->GetHandler("coverage")->ProcessHandler() < 0)
|
if (this->GetHandler("coverage")->ProcessHandler() < 0)
|
||||||
@ -838,7 +843,8 @@ int cmCTest::ProcessTests()
|
|||||||
res |= cmCTest::COVERAGE_ERRORS;
|
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();
|
this->UpdateCTestConfiguration();
|
||||||
if (this->GetHandler("memcheck")->ProcessHandler() < 0)
|
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);
|
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_SetTimeout(cp, this->TimeOut);
|
||||||
cmsysProcess_Execute(cp);
|
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();
|
||||||
|
}
|
||||||
|
@ -137,6 +137,13 @@ public:
|
|||||||
///! Get the current time as string
|
///! Get the current time as string
|
||||||
std::string CurrentTime();
|
std::string CurrentTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
///! Open file in the output directory and set the stream
|
///! Open file in the output directory and set the stream
|
||||||
bool OpenOutputFile(const std::string& path,
|
bool OpenOutputFile(const std::string& path,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user