Commit 2f84bd17 authored by Ken Martin's avatar Ken Martin
Browse files

ENH: added per test timeout support

parent f71ad851
......@@ -29,6 +29,7 @@ cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
this->BuildTwoConfig = false;
this->BuildNoClean = false;
this->BuildNoCMake = false;
this->Timeout = 0;
}
//----------------------------------------------------------------------
......@@ -146,7 +147,6 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString);
cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &cmakeOutString);
cmOStringStream out;
// What is this? double timeout = this->CTest->GetTimeOut();
// if the generator and make program are not specified then it is an error
if (!this->BuildGenerator.size() || !this->BuildMakeProgram.size())
......@@ -217,7 +217,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
*outstring = out.str();
}
// if not test was specified then we are done
// if no test was specified then we are done
if (!this->TestCommand.size())
{
return 0;
......@@ -361,8 +361,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
out << this->TestCommandArgs[k] << " ";
}
out << "\n";
// What is this? this->TimeOut = timeout;
int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0);
int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0,
this->Timeout);
if(runTestRes != cmsysProcess_State_Exited || retval != 0)
{
out << "Failed to run test command: " << testCommand[0] << "\n";
......@@ -432,6 +432,11 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
idx++;
this->ExecutableDirectory = allArgs[idx];
}
if(currentArg.find("--test-timeout",0) == 0 && idx < allArgs.size() - 1)
{
idx++;
this->Timeout = atof(allArgs[idx].c_str());
}
if(currentArg.find("--build-generator",0) == 0 && idx < allArgs.size() - 1)
{
idx++;
......
......@@ -75,6 +75,7 @@ protected:
std::vector<std::string> TestCommandArgs;
std::vector<std::string> BuildTargets;
bool BuildNoCMake;
double Timeout;
};
#endif
......
This diff is collapsed.
......@@ -85,6 +85,7 @@ public:
std::map<cmStdString, cmStdString> Measurements;
bool IsInBasedOnREOptions;
bool WillFail;
double Timeout;
};
struct cmCTestTestResult
......@@ -145,11 +146,18 @@ private:
virtual void GenerateDartOutput(std::ostream& os);
/**
* Run the test for a directory and any subdirectories
* Run the tests for a directory and any subdirectories
*/
void ProcessDirectory(std::vector<cmStdString> &passed,
std::vector<cmStdString> &failed);
/**
* Run one test
*/
void ProcessOneTest(cmCTestTestProperties *props,
std::vector<cmStdString> &passed,
std::vector<cmStdString> &failed,
int count, int tmsize);
typedef std::vector<cmCTestTestProperties> ListOfTests;
/**
......
......@@ -1074,7 +1074,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
//----------------------------------------------------------------------
int cmCTest::RunTest(std::vector<const char*> argv,
std::string* output, int *retVal,
std::ostream* log)
std::ostream* log, double testTimeOut)
{
if(cmSystemTools::SameFile(argv[0], this->CTestSelf.c_str()) &&
!this->ForceNewCTestProcess)
......@@ -1087,6 +1087,14 @@ int cmCTest::RunTest(std::vector<const char*> argv,
{
if(argv[i])
{
// if this test has a test command make sure we pass the timeout in
if (strcmp(argv[i],"--test-command") == 0 && testTimeOut)
{
args.push_back("--test-timeout");
cmOStringStream msg;
msg << testTimeOut;
args.push_back(msg.str());
}
args.push_back(argv[i]);
}
}
......@@ -1128,6 +1136,12 @@ int cmCTest::RunTest(std::vector<const char*> argv,
{
timeout = this->TimeOut;
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "-- timeout set to "
<< testTimeOut << std::endl);
if (testTimeOut && testTimeOut < timeout)
{
timeout = testTimeOut;
}
// always have at least 1 second if we got to here
if (timeout <= 0)
{
......
......@@ -232,7 +232,7 @@ public:
//! Run command specialized for tests. Returns process status and retVal is
// return value or exception.
int RunTest(std::vector<const char*> args, std::string* output, int *retVal,
std::ostream* logfile);
std::ostream* logfile, double testTimeOut);
/**
* Execute handler and return its result. If the handler fails, it returns
......
......@@ -117,6 +117,15 @@ void cmTest::DefineProperties(cmake *cm)
"against the specified regular expressions and at least one of the"
" regular expressions has to match, otherwise the test will fail.");
cm->DefineProperty
("TIMEOUT", cmProperty::TEST,
"How many seconds to allow for this test.",
"This property if set will limit a test to nto take more than "
"the specified number of seconds to run. If it exceeds that the "
"test process will be killed and ctest will move to the next test. "
"This setting takes precedence over DART_TESTING_TIMEOUT and "
"CTEST_TESTING_TIMOUT.");
cm->DefineProperty
("WILL_FAIL", cmProperty::TEST,
"If set to true, this will invert the pass/fail flag of the test.",
......
......@@ -148,7 +148,7 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
"complete. Other options that affect this mode are --build-target "
"--build-nocmake, --build-run-dir, "
"--build-two-config, --build-exe-dir, --build-project,"
"--build-noclean, --build-options"},
"--build-noclean, --build-options, --test-timeout"},
{"--build-target", "Specify a specific target to build.",
"This option goes with the --build-and-test option, if left out the all "
"target is built." },
......@@ -168,6 +168,8 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
{"--test-command", "The test to run with the --build-and-test option.", ""
},
{"--test-timeout", "The time limit in seconds for --test-command.", ""
},
{"--tomorrow-tag", "Nightly or experimental starts with next day tag.",
"This is useful if the build will not finish in one day." },
{"--ctest-config", "The configuration file used to initialize CTest state "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment