cmCTest: Improve readability adding "RunCMakeAndTest()" and "ExecuteTests()"

This commit is contained in:
Jean-Christophe Fillion-Robin 2016-06-28 18:04:07 -04:00 committed by Brad King
parent 898cb987b4
commit 280d0a6947
2 changed files with 71 additions and 58 deletions

View File

@ -2134,22 +2134,18 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// now what should cmake do? if --build-and-test was specified then // now what should cmake do? if --build-and-test was specified then
// we run the build and test handler and return // we run the build and test handler and return
if (cmakeAndTest) { if (cmakeAndTest) {
this->Verbose = true; return this->RunCMakeAndTest(output);
cmCTestBuildAndTestHandler* handler =
static_cast<cmCTestBuildAndTestHandler*>(this->GetHandler("buildtest"));
int retv = handler->ProcessHandler();
*output = handler->GetOutput();
#ifdef CMAKE_BUILD_WITH_CMAKE
cmDynamicLoader::FlushCache();
#endif
if (retv != 0) {
cmCTestLog(this, DEBUG,
"build and test failing returning: " << retv << std::endl);
}
return retv;
} }
if (executeTests) { if (executeTests) {
return this->ExecuteTests();
}
return 1;
}
int cmCTest::ExecuteTests()
{
int res; int res;
// call process directory // call process directory
if (this->RunConfigurationScript) { if (this->RunConfigurationScript) {
@ -2157,8 +2153,8 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
cmCTestLog(this, OUTPUT, "* Extra verbosity turned on" << std::endl); cmCTestLog(this, OUTPUT, "* Extra verbosity turned on" << std::endl);
} }
cmCTest::t_TestingHandlers::iterator it; cmCTest::t_TestingHandlers::iterator it;
for (it = this->TestingHandlers.begin(); for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
it != this->TestingHandlers.end(); ++it) { ++it) {
it->second->SetVerbose(this->ExtraVerbose); it->second->SetVerbose(this->ExtraVerbose);
it->second->SetSubmitIndex(this->SubmitIndex); it->second->SetSubmitIndex(this->SubmitIndex);
} }
@ -2175,8 +2171,8 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
this->ExtraVerbose = this->Verbose; this->ExtraVerbose = this->Verbose;
this->Verbose = true; this->Verbose = true;
cmCTest::t_TestingHandlers::iterator it; cmCTest::t_TestingHandlers::iterator it;
for (it = this->TestingHandlers.begin(); for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
it != this->TestingHandlers.end(); ++it) { ++it) {
it->second->SetVerbose(this->Verbose); it->second->SetVerbose(this->Verbose);
it->second->SetSubmitIndex(this->SubmitIndex); it->second->SetSubmitIndex(this->SubmitIndex);
} }
@ -2195,9 +2191,23 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
"Running a test(s) failed returning : " << res << std::endl); "Running a test(s) failed returning : " << res << std::endl);
} }
return res; return res;
} }
return 1; int cmCTest::RunCMakeAndTest(std::string* output)
{
this->Verbose = true;
cmCTestBuildAndTestHandler* handler =
static_cast<cmCTestBuildAndTestHandler*>(this->GetHandler("buildtest"));
int retv = handler->ProcessHandler();
*output = handler->GetOutput();
#ifdef CMAKE_BUILD_WITH_CMAKE
cmDynamicLoader::FlushCache();
#endif
if (retv != 0) {
cmCTestLog(this, DEBUG, "build and test failing returning: " << retv
<< std::endl);
}
return retv;
} }
void cmCTest::SetNotesFiles(const char* notes) void cmCTest::SetNotesFiles(const char* notes)

View File

@ -579,6 +579,9 @@ private:
//! Output errors from a test //! Output errors from a test
void OutputTestErrors(std::vector<char> const& process_output); void OutputTestErrors(std::vector<char> const& process_output);
int RunCMakeAndTest(std::string* output);
int ExecuteTests();
bool SuppressUpdatingCTestConfiguration; bool SuppressUpdatingCTestConfiguration;
bool Debug; bool Debug;