[cmake-commits] martink committed cmCTest.cxx 1.310 1.311 cmCTest.h
1.95 1.96
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Oct 19 10:45:26 EDT 2006
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv22252/Source
Modified Files:
cmCTest.cxx cmCTest.h
Log Message:
ENH: added total time limit for a CTest run bug 1207
Index: cmCTest.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCTest.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- cmCTest.h 13 Oct 2006 21:10:48 -0000 1.95
+++ cmCTest.h 19 Oct 2006 14:45:18 -0000 1.96
@@ -137,6 +137,13 @@
///! Get the current time as string
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
bool OpenOutputFile(const std::string& path,
const std::string& name,
Index: cmCTest.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCTest.cxx,v
retrieving revision 1.310
retrieving revision 1.311
diff -u -d -r1.310 -r1.311
--- cmCTest.cxx 15 Oct 2006 11:54:51 -0000 1.310
+++ cmCTest.cxx 19 Oct 2006 14:45:17 -0000 1.311
@@ -792,7 +792,8 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
{
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 @@
}
}
+//-------------------------------------------------------------------------
+double cmCTest::GetRemainingTimeAllowed()
+{
+ if (!this->GetHandler("script"))
+ {
+ return 1.0e7;
+ }
+
+ cmCTestScriptHandler* ch
+ = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+
+ return ch->GetRemainingTimeAllowed();
+}
More information about the Cmake-commits
mailing list