BUG: fixes so that --build-and-test will honor timeouts
This commit is contained in:
parent
b32f3b4131
commit
49085f7fed
|
@ -383,6 +383,13 @@ IF(BUILD_TESTING)
|
||||||
OPTION(CMAKE_RUN_LONG_TESTS "Should the long tests be run (such as Bootstrap)." ON)
|
OPTION(CMAKE_RUN_LONG_TESTS "Should the long tests be run (such as Bootstrap)." ON)
|
||||||
MARK_AS_ADVANCED(CMAKE_RUN_LONG_TESTS)
|
MARK_AS_ADVANCED(CMAKE_RUN_LONG_TESTS)
|
||||||
|
|
||||||
|
IF (CMAKE_RUN_LONG_TESTS)
|
||||||
|
OPTION(CTEST_TEST_CTEST
|
||||||
|
"Should the tests that run a full sub ctest process be run?"
|
||||||
|
OFF)
|
||||||
|
MARK_AS_ADVANCED(CTEST_TEST_CTEST)
|
||||||
|
ENDIF (CMAKE_RUN_LONG_TESTS)
|
||||||
|
|
||||||
ADD_TEST(CommandLineTest ${CMAKE_CTEST_COMMAND}
|
ADD_TEST(CommandLineTest ${CMAKE_CTEST_COMMAND}
|
||||||
--build-and-test
|
--build-and-test
|
||||||
"${CMake_SOURCE_DIR}/Tests/CommandLineTest"
|
"${CMake_SOURCE_DIR}/Tests/CommandLineTest"
|
||||||
|
@ -1071,6 +1078,10 @@ IF(BUILD_TESTING)
|
||||||
-S "${CMake_BINARY_DIR}/Tests/CTestTest3/test.cmake" -V
|
-S "${CMake_BINARY_DIR}/Tests/CTestTest3/test.cmake" -V
|
||||||
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest3/testOutput.log"
|
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest3/testOutput.log"
|
||||||
)
|
)
|
||||||
|
# these tests take a log time, make sure they have it
|
||||||
|
SET_TESTS_PROPERTIES ( CTestTest CTestTest2 CTestTest3
|
||||||
|
PROPERTIES TIMEOUT 1500
|
||||||
|
)
|
||||||
ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS)
|
ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS)
|
||||||
|
|
||||||
IF("${CMAKE_TEST_GENERATOR}" MATCHES Xcode)
|
IF("${CMAKE_TEST_GENERATOR}" MATCHES Xcode)
|
||||||
|
|
|
@ -161,6 +161,10 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we need to honor the timeout specified, the timeout include cmake, build
|
||||||
|
// and test time
|
||||||
|
double clock_start = cmSystemTools::GetTime();
|
||||||
|
|
||||||
// make sure the binary dir is there
|
// make sure the binary dir is there
|
||||||
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
||||||
out << "Internal cmake changing into directory: "
|
out << "Internal cmake changing into directory: "
|
||||||
|
@ -178,7 +182,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
||||||
|
|
||||||
if(!this->BuildNoCMake)
|
if(!this->BuildNoCMake)
|
||||||
{
|
{
|
||||||
// do the cmake step
|
// do the cmake step, no timeout here since it is not a sub process
|
||||||
if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm))
|
if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -194,12 +198,27 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
||||||
for ( tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end();
|
for ( tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end();
|
||||||
++ tarIt )
|
++ tarIt )
|
||||||
{
|
{
|
||||||
|
double remainingTime = 0;
|
||||||
|
if (this->Timeout)
|
||||||
|
{
|
||||||
|
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
|
||||||
|
if (remainingTime <= 0)
|
||||||
|
{
|
||||||
|
if(outstring)
|
||||||
|
{
|
||||||
|
*outstring = "--build-and-test timeout exceeded. ";
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = cm.GetGlobalGenerator()->Build(
|
int retVal = cm.GetGlobalGenerator()->Build(
|
||||||
this->SourceDir.c_str(), this->BinaryDir.c_str(),
|
this->SourceDir.c_str(), this->BinaryDir.c_str(),
|
||||||
this->BuildProject.c_str(), tarIt->c_str(),
|
this->BuildProject.c_str(), tarIt->c_str(),
|
||||||
&output, this->BuildMakeProgram.c_str(),
|
&output, this->BuildMakeProgram.c_str(),
|
||||||
this->CTest->GetConfigType().c_str(),!this->BuildNoClean, false);
|
this->CTest->GetConfigType().c_str(),
|
||||||
|
!this->BuildNoClean,
|
||||||
|
false, remainingTime);
|
||||||
|
|
||||||
out << output;
|
out << output;
|
||||||
// if the build failed then return
|
// if the build failed then return
|
||||||
|
@ -361,8 +380,25 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
||||||
out << this->TestCommandArgs[k] << " ";
|
out << this->TestCommandArgs[k] << " ";
|
||||||
}
|
}
|
||||||
out << "\n";
|
out << "\n";
|
||||||
|
|
||||||
|
// how much time is remaining
|
||||||
|
double remainingTime = 0;
|
||||||
|
if (this->Timeout)
|
||||||
|
{
|
||||||
|
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
|
||||||
|
if (remainingTime <= 0)
|
||||||
|
{
|
||||||
|
if(outstring)
|
||||||
|
{
|
||||||
|
*outstring = "--build-and-test timeout exceeded. ";
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0,
|
int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0,
|
||||||
this->Timeout);
|
remainingTime);
|
||||||
|
|
||||||
if(runTestRes != cmsysProcess_State_Exited || retval != 0)
|
if(runTestRes != cmsysProcess_State_Exited || retval != 0)
|
||||||
{
|
{
|
||||||
out << "Failed to run test command: " << testCommand[0] << "\n";
|
out << "Failed to run test command: " << testCommand[0] << "\n";
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int cmGlobalGenerator::s_TryCompileTimeout = 0;
|
|
||||||
|
|
||||||
cmGlobalGenerator::cmGlobalGenerator()
|
cmGlobalGenerator::cmGlobalGenerator()
|
||||||
{
|
{
|
||||||
// By default the .SYMBOLIC dependency is not needed on symbolic rules.
|
// By default the .SYMBOLIC dependency is not needed on symbolic rules.
|
||||||
|
@ -49,6 +47,9 @@ cmGlobalGenerator::cmGlobalGenerator()
|
||||||
|
|
||||||
// Whether an install target is needed.
|
// Whether an install target is needed.
|
||||||
this->InstallTargetEnabled = false;
|
this->InstallTargetEnabled = false;
|
||||||
|
|
||||||
|
// how long to let try compiles run
|
||||||
|
this->TryCompileTimeout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalGenerator::~cmGlobalGenerator()
|
cmGlobalGenerator::~cmGlobalGenerator()
|
||||||
|
@ -808,7 +809,8 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
|
||||||
const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
|
const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
|
||||||
return this->Build(srcdir,bindir,projectName,
|
return this->Build(srcdir,bindir,projectName,
|
||||||
newTarget.c_str(),
|
newTarget.c_str(),
|
||||||
output,makeCommand.c_str(),config,false,true);
|
output,makeCommand.c_str(),config,false,true,
|
||||||
|
this->TryCompileTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGlobalGenerator
|
std::string cmGlobalGenerator
|
||||||
|
@ -852,7 +854,8 @@ int cmGlobalGenerator::Build(
|
||||||
std::string *output,
|
std::string *output,
|
||||||
const char *makeCommandCSTR,
|
const char *makeCommandCSTR,
|
||||||
const char *config,
|
const char *config,
|
||||||
bool clean, bool fast)
|
bool clean, bool fast,
|
||||||
|
double timeout)
|
||||||
{
|
{
|
||||||
*output += "\nTesting TryCompileWithoutMakefile\n";
|
*output += "\nTesting TryCompileWithoutMakefile\n";
|
||||||
|
|
||||||
|
@ -863,7 +866,6 @@ int cmGlobalGenerator::Build(
|
||||||
cmSystemTools::ChangeDirectory(bindir);
|
cmSystemTools::ChangeDirectory(bindir);
|
||||||
|
|
||||||
int retVal;
|
int retVal;
|
||||||
int timeout = cmGlobalGenerator::s_TryCompileTimeout;
|
|
||||||
bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
|
bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
|
||||||
cmSystemTools::SetRunCommandHideConsole(true);
|
cmSystemTools::SetRunCommandHideConsole(true);
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,8 @@ public:
|
||||||
const char *projectName, const char *targetName,
|
const char *projectName, const char *targetName,
|
||||||
std::string *output,
|
std::string *output,
|
||||||
const char *makeProgram, const char *config,
|
const char *makeProgram, const char *config,
|
||||||
bool clean, bool fast);
|
bool clean, bool fast,
|
||||||
|
double timeout);
|
||||||
virtual std::string GenerateBuildCommand
|
virtual std::string GenerateBuildCommand
|
||||||
(const char* makeProgram,
|
(const char* makeProgram,
|
||||||
const char *projectName, const char* additionalOptions,
|
const char *projectName, const char* additionalOptions,
|
||||||
|
@ -125,7 +126,7 @@ public:
|
||||||
void AddInstallComponent(const char* component);
|
void AddInstallComponent(const char* component);
|
||||||
void EnableInstallTarget();
|
void EnableInstallTarget();
|
||||||
|
|
||||||
static int s_TryCompileTimeout;
|
int TryCompileTimeout;
|
||||||
|
|
||||||
bool GetForceUnixPaths() {return this->ForceUnixPaths;}
|
bool GetForceUnixPaths() {return this->ForceUnixPaths;}
|
||||||
bool GetToolSupportsColor() { return this->ToolSupportsColor; }
|
bool GetToolSupportsColor() { return this->ToolSupportsColor; }
|
||||||
|
|
|
@ -148,7 +148,7 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
|
||||||
"complete. Other options that affect this mode are --build-target "
|
"complete. Other options that affect this mode are --build-target "
|
||||||
"--build-nocmake, --build-run-dir, "
|
"--build-nocmake, --build-run-dir, "
|
||||||
"--build-two-config, --build-exe-dir, --build-project,"
|
"--build-two-config, --build-exe-dir, --build-project,"
|
||||||
"--build-noclean, --build-options, --test-timeout"},
|
"--build-noclean, --build-options"},
|
||||||
{"--build-target", "Specify a specific target to build.",
|
{"--build-target", "Specify a specific target to build.",
|
||||||
"This option goes with the --build-and-test option, if left out the all "
|
"This option goes with the --build-and-test option, if left out the all "
|
||||||
"target is built." },
|
"target is built." },
|
||||||
|
@ -168,7 +168,7 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
|
||||||
|
|
||||||
{"--test-command", "The test to run with the --build-and-test option.", ""
|
{"--test-command", "The test to run with the --build-and-test option.", ""
|
||||||
},
|
},
|
||||||
{"--test-timeout", "The time limit in seconds for --test-command.", ""
|
{"--test-timeout", "The time limit in seconds, internal use only.", ""
|
||||||
},
|
},
|
||||||
{"--tomorrow-tag", "Nightly or experimental starts with next day tag.",
|
{"--tomorrow-tag", "Nightly or experimental starts with next day tag.",
|
||||||
"This is useful if the build will not finish in one day." },
|
"This is useful if the build will not finish in one day." },
|
||||||
|
|
Loading…
Reference in New Issue