summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorZack Galbreath <zack.galbreath@kitware.com>2016-02-18 18:59:18 (GMT)
committerBrad King <brad.king@kitware.com>2016-03-22 15:17:55 (GMT)
commit993e48d0451b41f8e2c2a59473d9ddc09ada5792 (patch)
treeef678a032f62e84338653b903e6be7ebc0522d2b /Source/CTest
parent2b64dc7cabb6eda86f0c8b91b27aee4119ac7ebb (diff)
downloadCMake-993e48d0451b41f8e2c2a59473d9ddc09ada5792.zip
CMake-993e48d0451b41f8e2c2a59473d9ddc09ada5792.tar.gz
CMake-993e48d0451b41f8e2c2a59473d9ddc09ada5792.tar.bz2
CTest: Optionally use a secondary test timeout after matching output
Allow a test N seconds to complete after we detect a matching line in its output. Activate this behavior with a new TIMEOUT_AFTER_MATCH test property.
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestRunTest.cxx22
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx25
-rw-r--r--Source/CTest/cmCTestTestHandler.h3
-rw-r--r--Source/CTest/cmProcess.cxx10
-rw-r--r--Source/CTest/cmProcess.h2
5 files changed, 62 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index d108592..7f3a077 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -64,6 +64,28 @@ bool cmCTestRunTest::CheckOutput()
this->GetIndex() << ": " << line << std::endl);
this->ProcessOutput += line;
this->ProcessOutput += "\n";
+
+ // Check for TIMEOUT_AFTER_MATCH property.
+ if (!this->TestProperties->TimeoutRegularExpressions.empty())
+ {
+ std::vector<std::pair<cmsys::RegularExpression,
+ std::string> >::iterator regIt;
+ for ( regIt = this->TestProperties->TimeoutRegularExpressions.begin();
+ regIt != this->TestProperties->TimeoutRegularExpressions.end();
+ ++ regIt )
+ {
+ if ( regIt->first.find(this->ProcessOutput.c_str()) )
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Test timeout changed to " <<
+ this->TestProperties->AlternateTimeout << std::endl);
+ this->TestProcess->ResetStartTime();
+ this->TestProcess->ChangeTimeout(
+ this->TestProperties->AlternateTimeout);
+ break;
+ }
+ }
+ }
}
else // if(p == cmsysProcess_Pipe_Timeout)
{
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index b6a4819..59ed98e 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -2254,6 +2254,31 @@ bool cmCTestTestHandler::SetTestsProperties(
{
rtit->Directory = val;
}
+ if ( key == "TIMEOUT_AFTER_MATCH" )
+ {
+ std::vector<std::string> propArgs;
+ cmSystemTools::ExpandListArgument(val, propArgs);
+ if (propArgs.size() != 2)
+ {
+ cmCTestLog(this->CTest, WARNING,
+ "TIMEOUT_AFTER_MATCH expects two arguments, found " <<
+ propArgs.size() << std::endl);
+ }
+ else
+ {
+ rtit->AlternateTimeout = atof(propArgs[0].c_str());
+ std::vector<std::string> lval;
+ cmSystemTools::ExpandListArgument(propArgs[1], lval);
+ std::vector<std::string>::iterator crit;
+ for ( crit = lval.begin(); crit != lval.end(); ++ crit )
+ {
+ rtit->TimeoutRegularExpressions.push_back(
+ std::pair<cmsys::RegularExpression, std::string>(
+ cmsys::RegularExpression(crit->c_str()),
+ std::string(*crit)));
+ }
+ }
+ }
}
}
}
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index c635430..d12c2b6 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -104,6 +104,8 @@ public:
std::string> > ErrorRegularExpressions;
std::vector<std::pair<cmsys::RegularExpression,
std::string> > RequiredRegularExpressions;
+ std::vector<std::pair<cmsys::RegularExpression,
+ std::string> > TimeoutRegularExpressions;
std::map<std::string, std::string> Measurements;
bool IsInBasedOnREOptions;
bool WillFail;
@@ -112,6 +114,7 @@ public:
bool RunSerial;
double Timeout;
bool ExplicitTimeout;
+ double AlternateTimeout;
int Index;
//Requested number of process slots
int Processors;
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 0c25f40..6441886 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -262,6 +262,16 @@ int cmProcess::ReportStatus()
}
+void cmProcess::ChangeTimeout(double t)
+{
+ this->Timeout = t;
+ cmsysProcess_SetTimeout(this->Process, this->Timeout);
+}
+
+void cmProcess::ResetStartTime()
+{
+ cmsysProcess_ResetStartTime(this->Process);
+}
int cmProcess::GetExitException()
{
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index eddeeab..c9fd859 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -32,6 +32,8 @@ public:
void SetCommandArguments(std::vector<std::string> const& arg);
void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir;}
void SetTimeout(double t) { this->Timeout = t;}
+ void ChangeTimeout(double t);
+ void ResetStartTime();
// Return true if the process starts
bool StartProcess();