cmCTest: Use concrete accessor functions for TestingHandlers

This commit is contained in:
Regina Pfeifer
2019-03-18 22:25:50 +01:00
committed by Brad King
parent 46090c2337
commit b172a81d55
12 changed files with 144 additions and 191 deletions

View File

@@ -4,7 +4,6 @@
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestBuildHandler.h" #include "cmCTestBuildHandler.h"
#include "cmCTestGenericHandler.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmMessageType.h" #include "cmMessageType.h"
@@ -39,12 +38,10 @@ cmCTestBuildCommand::~cmCTestBuildCommand()
cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
{ {
cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("build"); cmCTestBuildHandler* handler = this->CTest->GetBuildHandler();
if (!handler) { handler->Initialize();
this->SetError("internal CTest error. Cannot instantiate build handler");
return nullptr; this->Handler = handler;
}
this->Handler = static_cast<cmCTestBuildHandler*>(handler);
const char* ctestBuildCommand = const char* ctestBuildCommand =
this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");

View File

@@ -3,7 +3,7 @@
#include "cmCTestConfigureCommand.h" #include "cmCTestConfigureCommand.h"
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestGenericHandler.h" #include "cmCTestConfigureHandler.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@@ -142,13 +142,8 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
labelsForSubprojects, this->Quiet); labelsForSubprojects, this->Quiet);
} }
cmCTestGenericHandler* handler = cmCTestConfigureHandler* handler = this->CTest->GetConfigureHandler();
this->CTest->GetInitializedHandler("configure"); handler->Initialize();
if (!handler) {
this->SetError(
"internal CTest error. Cannot instantiate configure handler");
return nullptr;
}
handler->SetQuiet(this->Quiet); handler->SetQuiet(this->Quiet);
return handler; return handler;
} }

View File

@@ -19,12 +19,8 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS",
this->Quiet); this->Quiet);
cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>( cmCTestCoverageHandler* handler = this->CTest->GetCoverageHandler();
this->CTest->GetInitializedHandler("coverage")); handler->Initialize();
if (!handler) {
this->SetError("internal CTest error. Cannot instantiate test handler");
return nullptr;
}
// If a LABELS option was given, select only files with the labels. // If a LABELS option was given, select only files with the labels.
if (this->LabelsMentioned) { if (this->LabelsMentioned) {

View File

@@ -7,7 +7,6 @@
#include <vector> #include <vector>
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestGenericHandler.h"
#include "cmCTestMemCheckHandler.h" #include "cmCTestMemCheckHandler.h"
#include "cmMakefile.h" #include "cmMakefile.h"
@@ -20,8 +19,8 @@ cmCTestMemCheckCommand::cmCTestMemCheckCommand()
cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler() cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler()
{ {
cmCTestGenericHandler* handler = cmCTestMemCheckHandler* handler = this->CTest->GetMemCheckHandler();
this->CTest->GetInitializedHandler("memcheck"); handler->Initialize();
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet); this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);

View File

@@ -3,7 +3,6 @@
#include "cmCTestSubmitCommand.h" #include "cmCTestSubmitCommand.h"
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestGenericHandler.h"
#include "cmCTestSubmitHandler.h" #include "cmCTestSubmitHandler.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmMessageType.h" #include "cmMessageType.h"
@@ -63,12 +62,8 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
} }
} }
cmCTestGenericHandler* handler = cmCTestSubmitHandler* handler = this->CTest->GetSubmitHandler();
this->CTest->GetInitializedHandler("submit"); handler->Initialize();
if (!handler) {
this->SetError("internal CTest error. Cannot instantiate submit handler");
return nullptr;
}
// If no FILES or PARTS given, *all* PARTS are submitted by default. // If no FILES or PARTS given, *all* PARTS are submitted by default.
// //
@@ -90,38 +85,30 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
// But FILES with no PARTS mentioned should just submit the FILES // But FILES with no PARTS mentioned should just submit the FILES
// without any of the default parts. // without any of the default parts.
// //
std::set<cmCTest::Part> noParts; handler->SelectParts(std::set<cmCTest::Part>());
static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(noParts); handler->SelectFiles(this->Files);
static_cast<cmCTestSubmitHandler*>(handler)->SelectFiles(this->Files);
} }
// If a PARTS option was given, select only the named parts for submission. // If a PARTS option was given, select only the named parts for submission.
// //
if (this->PartsMentioned) { if (this->PartsMentioned) {
static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts); handler->SelectParts(this->Parts);
} }
// Pass along any HTTPHEADER to the handler if this option was given. // Pass along any HTTPHEADER to the handler if this option was given.
if (!this->HttpHeaders.empty()) { if (!this->HttpHeaders.empty()) {
static_cast<cmCTestSubmitHandler*>(handler)->SetHttpHeaders( handler->SetHttpHeaders(this->HttpHeaders);
this->HttpHeaders);
} }
static_cast<cmCTestSubmitHandler*>(handler)->SetOption( handler->SetOption("RetryDelay", this->RetryDelay.c_str());
"RetryDelay", this->RetryDelay.c_str()); handler->SetOption("RetryCount", this->RetryCount.c_str());
static_cast<cmCTestSubmitHandler*>(handler)->SetOption( handler->SetOption("InternalTest", this->InternalTest ? "ON" : "OFF");
"RetryCount", this->RetryCount.c_str());
static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
"InternalTest", this->InternalTest ? "ON" : "OFF");
handler->SetQuiet(this->Quiet); handler->SetQuiet(this->Quiet);
if (this->CDashUpload) { if (this->CDashUpload) {
static_cast<cmCTestSubmitHandler*>(handler)->SetOption( handler->SetOption("CDashUploadFile", this->CDashUploadFile.c_str());
"CDashUploadFile", this->CDashUploadFile.c_str()); handler->SetOption("CDashUploadType", this->CDashUploadType.c_str());
static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
"CDashUploadType", this->CDashUploadType.c_str());
} }
return handler; return handler;
} }

View File

@@ -259,8 +259,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
upload_as += ctest_curl.Escape(this->CTest->GetCurrentTag()); upload_as += ctest_curl.Escape(this->CTest->GetCurrentTag());
upload_as += "-"; upload_as += "-";
upload_as += ctest_curl.Escape(this->CTest->GetTestModelString()); upload_as += ctest_curl.Escape(this->CTest->GetTestModelString());
cmCTestScriptHandler* ch = static_cast<cmCTestScriptHandler*>( cmCTestScriptHandler* ch = this->CTest->GetScriptHandler();
this->CTest->GetHandler("script"));
cmake* cm = ch->GetCMake(); cmake* cm = ch->GetCMake();
if (cm) { if (cm) {
const char* subproject = const char* subproject =
@@ -558,8 +557,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
// has already been uploaded // has already been uploaded
// TODO I added support for subproject. You would need to add // TODO I added support for subproject. You would need to add
// a "&subproject=subprojectname" to the first POST. // a "&subproject=subprojectname" to the first POST.
cmCTestScriptHandler* ch = cmCTestScriptHandler* ch = this->CTest->GetScriptHandler();
static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
cmake* cm = ch->GetCMake(); cmake* cm = ch->GetCMake();
const char* subproject = cm->GetState()->GetGlobalProperty("SubProject"); const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
// TODO: Encode values for a URL instead of trusting caller. // TODO: Encode values for a URL instead of trusting caller.

View File

@@ -4,6 +4,7 @@
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestGenericHandler.h" #include "cmCTestGenericHandler.h"
#include "cmCTestTestHandler.h"
#include "cmDuration.h" #include "cmDuration.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@@ -140,5 +141,7 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler() cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler()
{ {
return this->CTest->GetInitializedHandler("test"); cmCTestTestHandler* handler = this->CTest->GetTestHandler();
handler->Initialize();
return handler;
} }

View File

@@ -3,7 +3,7 @@
#include "cmCTestUpdateCommand.h" #include "cmCTestUpdateCommand.h"
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestGenericHandler.h" #include "cmCTestUpdateHandler.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@@ -74,12 +74,8 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
this->CTest->SetCTestConfigurationFromCMakeVariable( this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "P4Options", "CTEST_P4_OPTIONS", this->Quiet); this->Makefile, "P4Options", "CTEST_P4_OPTIONS", this->Quiet);
cmCTestGenericHandler* handler = cmCTestUpdateHandler* handler = this->CTest->GetUpdateHandler();
this->CTest->GetInitializedHandler("update"); handler->Initialize();
if (!handler) {
this->SetError("internal CTest error. Cannot instantiate update handler");
return nullptr;
}
handler->SetCommand(this); handler->SetCommand(this);
if (source_dir.empty()) { if (source_dir.empty()) {
this->SetError("source directory not specified. Please use SOURCE tag"); this->SetError("source directory not specified. Please use SOURCE tag");

View File

@@ -6,7 +6,6 @@
#include <vector> #include <vector>
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestGenericHandler.h"
#include "cmCTestUploadHandler.h" #include "cmCTestUploadHandler.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmMessageType.h" #include "cmMessageType.h"
@@ -14,14 +13,9 @@
cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler() cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler()
{ {
cmCTestGenericHandler* handler = cmCTestUploadHandler* handler = this->CTest->GetUploadHandler();
this->CTest->GetInitializedHandler("upload"); handler->Initialize();
if (!handler) { handler->SetFiles(this->Files);
this->SetError("internal CTest error. Cannot instantiate upload handler");
return nullptr;
}
static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files);
handler->SetQuiet(this->Quiet); handler->SetQuiet(this->Quiet);
return handler; return handler;
} }

View File

@@ -1010,58 +1010,54 @@ bool cmCTest::CTestFileExists(const std::string& filename)
return cmSystemTools::FileExists(testingDir); return cmSystemTools::FileExists(testingDir);
} }
cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler) cmCTestBuildHandler* cmCTest::GetBuildHandler()
{ {
if (cmCTestGenericHandler* testHandler = this->GetHandler(handler)) { return &this->Impl->BuildHandler;
testHandler->Initialize();
return testHandler;
}
return nullptr;
} }
cmCTestGenericHandler* cmCTest::GetHandler(const char* handler) cmCTestBuildAndTestHandler* cmCTest::GetBuildAndTestHandler()
{ {
if (strcmp(handler, "build") == 0) { return &this->Impl->BuildAndTestHandler;
return &this->Impl->BuildHandler;
}
if (strcmp(handler, "buildtest") == 0) {
return &this->Impl->BuildAndTestHandler;
}
if (strcmp(handler, "coverage") == 0) {
return &this->Impl->CoverageHandler;
}
if (strcmp(handler, "script") == 0) {
return &this->Impl->ScriptHandler;
}
if (strcmp(handler, "test") == 0) {
return &this->Impl->TestHandler;
}
if (strcmp(handler, "update") == 0) {
return &this->Impl->UpdateHandler;
}
if (strcmp(handler, "configure") == 0) {
return &this->Impl->ConfigureHandler;
}
if (strcmp(handler, "memcheck") == 0) {
return &this->Impl->MemCheckHandler;
}
if (strcmp(handler, "submit") == 0) {
return &this->Impl->SubmitHandler;
}
if (strcmp(handler, "upload") == 0) {
return &this->Impl->UploadHandler;
}
return nullptr;
} }
int cmCTest::ExecuteHandler(const char* shandler) cmCTestCoverageHandler* cmCTest::GetCoverageHandler()
{ {
cmCTestGenericHandler* handler = this->GetHandler(shandler); return &this->Impl->CoverageHandler;
if (!handler) { }
return -1;
} cmCTestScriptHandler* cmCTest::GetScriptHandler()
handler->Initialize(); {
return handler->ProcessHandler(); return &this->Impl->ScriptHandler;
}
cmCTestTestHandler* cmCTest::GetTestHandler()
{
return &this->Impl->TestHandler;
}
cmCTestUpdateHandler* cmCTest::GetUpdateHandler()
{
return &this->Impl->UpdateHandler;
}
cmCTestConfigureHandler* cmCTest::GetConfigureHandler()
{
return &this->Impl->ConfigureHandler;
}
cmCTestMemCheckHandler* cmCTest::GetMemCheckHandler()
{
return &this->Impl->MemCheckHandler;
}
cmCTestSubmitHandler* cmCTest::GetSubmitHandler()
{
return &this->Impl->SubmitHandler;
}
cmCTestUploadHandler* cmCTest::GetUploadHandler()
{
return &this->Impl->UploadHandler;
} }
int cmCTest::ProcessSteps() int cmCTest::ProcessSteps()
@@ -1075,7 +1071,7 @@ int cmCTest::ProcessSteps()
} }
if (this->Impl->Parts[PartUpdate] && if (this->Impl->Parts[PartUpdate] &&
(this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) { (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
cmCTestGenericHandler* uphandler = this->GetHandler("update"); cmCTestUpdateHandler* uphandler = this->GetUpdateHandler();
uphandler->SetPersistentOption( uphandler->SetPersistentOption(
"SourceDirectory", "SourceDirectory",
this->GetCTestConfiguration("SourceDirectory").c_str()); this->GetCTestConfiguration("SourceDirectory").c_str());
@@ -1089,35 +1085,35 @@ int cmCTest::ProcessSteps()
} }
if (this->Impl->Parts[PartConfigure] && if (this->Impl->Parts[PartConfigure] &&
(this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) { (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
if (this->GetHandler("configure")->ProcessHandler() < 0) { if (this->GetConfigureHandler()->ProcessHandler() < 0) {
res |= cmCTest::CONFIGURE_ERRORS; res |= cmCTest::CONFIGURE_ERRORS;
} }
} }
if (this->Impl->Parts[PartBuild] && if (this->Impl->Parts[PartBuild] &&
(this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) { (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
this->UpdateCTestConfiguration(); this->UpdateCTestConfiguration();
if (this->GetHandler("build")->ProcessHandler() < 0) { if (this->GetBuildHandler()->ProcessHandler() < 0) {
res |= cmCTest::BUILD_ERRORS; res |= cmCTest::BUILD_ERRORS;
} }
} }
if ((this->Impl->Parts[PartTest] || notest) && if ((this->Impl->Parts[PartTest] || notest) &&
(this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) { (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
this->UpdateCTestConfiguration(); this->UpdateCTestConfiguration();
if (this->GetHandler("test")->ProcessHandler() < 0) { if (this->GetTestHandler()->ProcessHandler() < 0) {
res |= cmCTest::TEST_ERRORS; res |= cmCTest::TEST_ERRORS;
} }
} }
if (this->Impl->Parts[PartCoverage] && if (this->Impl->Parts[PartCoverage] &&
(this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) { (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
this->UpdateCTestConfiguration(); this->UpdateCTestConfiguration();
if (this->GetHandler("coverage")->ProcessHandler() < 0) { if (this->GetCoverageHandler()->ProcessHandler() < 0) {
res |= cmCTest::COVERAGE_ERRORS; res |= cmCTest::COVERAGE_ERRORS;
} }
} }
if (this->Impl->Parts[PartMemCheck] && if (this->Impl->Parts[PartMemCheck] &&
(this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) { (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
this->UpdateCTestConfiguration(); this->UpdateCTestConfiguration();
if (this->GetHandler("memcheck")->ProcessHandler() < 0) { if (this->GetMemCheckHandler()->ProcessHandler() < 0) {
res |= cmCTest::MEMORY_ERRORS; res |= cmCTest::MEMORY_ERRORS;
} }
} }
@@ -1149,7 +1145,7 @@ int cmCTest::ProcessSteps()
} }
if (this->Impl->Parts[PartSubmit]) { if (this->Impl->Parts[PartSubmit]) {
this->UpdateCTestConfiguration(); this->UpdateCTestConfiguration();
if (this->GetHandler("submit")->ProcessHandler() < 0) { if (this->GetSubmitHandler()->ProcessHandler() < 0) {
res |= cmCTest::SUBMIT_ERRORS; res |= cmCTest::SUBMIT_ERRORS;
} }
} }
@@ -1579,8 +1575,7 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
void cmCTest::AddSiteProperties(cmXMLWriter& xml) void cmCTest::AddSiteProperties(cmXMLWriter& xml)
{ {
cmCTestScriptHandler* ch = cmCTestScriptHandler* ch = this->GetScriptHandler();
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
cmake* cm = ch->GetCMake(); cmake* cm = ch->GetCMake();
// if no CMake then this is the old style script and props like // if no CMake then this is the old style script and props like
// this will not work anyway. // this will not work anyway.
@@ -2172,78 +2167,75 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
if (this->CheckArgument(arg, "-I", "--tests-information") && if (this->CheckArgument(arg, "-I", "--tests-information") &&
i < args.size() - 1) { i < args.size() - 1) {
i++; i++;
this->GetHandler("test")->SetPersistentOption("TestsToRunInformation", this->GetTestHandler()->SetPersistentOption("TestsToRunInformation",
args[i].c_str()); args[i].c_str());
this->GetHandler("memcheck") this->GetMemCheckHandler()->SetPersistentOption("TestsToRunInformation",
->SetPersistentOption("TestsToRunInformation", args[i].c_str()); args[i].c_str());
} }
if (this->CheckArgument(arg, "-U", "--union")) { if (this->CheckArgument(arg, "-U", "--union")) {
this->GetHandler("test")->SetPersistentOption("UseUnion", "true"); this->GetTestHandler()->SetPersistentOption("UseUnion", "true");
this->GetHandler("memcheck")->SetPersistentOption("UseUnion", "true"); this->GetMemCheckHandler()->SetPersistentOption("UseUnion", "true");
} }
if (this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1) { if (this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1) {
i++; i++;
this->GetHandler("test")->SetPersistentOption("IncludeRegularExpression", this->GetTestHandler()->SetPersistentOption("IncludeRegularExpression",
args[i].c_str()); args[i].c_str());
this->GetHandler("memcheck") this->GetMemCheckHandler()->SetPersistentOption("IncludeRegularExpression",
->SetPersistentOption("IncludeRegularExpression", args[i].c_str()); args[i].c_str());
} }
if (this->CheckArgument(arg, "-L", "--label-regex") && i < args.size() - 1) { if (this->CheckArgument(arg, "-L", "--label-regex") && i < args.size() - 1) {
i++; i++;
this->GetHandler("test")->SetPersistentOption("LabelRegularExpression", this->GetTestHandler()->SetPersistentOption("LabelRegularExpression",
args[i].c_str()); args[i].c_str());
this->GetHandler("memcheck") this->GetMemCheckHandler()->SetPersistentOption("LabelRegularExpression",
->SetPersistentOption("LabelRegularExpression", args[i].c_str()); args[i].c_str());
} }
if (this->CheckArgument(arg, "-LE", "--label-exclude") && if (this->CheckArgument(arg, "-LE", "--label-exclude") &&
i < args.size() - 1) { i < args.size() - 1) {
i++; i++;
this->GetHandler("test")->SetPersistentOption( this->GetTestHandler()->SetPersistentOption(
"ExcludeLabelRegularExpression", args[i].c_str());
this->GetMemCheckHandler()->SetPersistentOption(
"ExcludeLabelRegularExpression", args[i].c_str()); "ExcludeLabelRegularExpression", args[i].c_str());
this->GetHandler("memcheck")
->SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
} }
if (this->CheckArgument(arg, "-E", "--exclude-regex") && if (this->CheckArgument(arg, "-E", "--exclude-regex") &&
i < args.size() - 1) { i < args.size() - 1) {
i++; i++;
this->GetHandler("test")->SetPersistentOption("ExcludeRegularExpression", this->GetTestHandler()->SetPersistentOption("ExcludeRegularExpression",
args[i].c_str()); args[i].c_str());
this->GetHandler("memcheck") this->GetMemCheckHandler()->SetPersistentOption("ExcludeRegularExpression",
->SetPersistentOption("ExcludeRegularExpression", args[i].c_str()); args[i].c_str());
} }
if (this->CheckArgument(arg, "-FA", "--fixture-exclude-any") && if (this->CheckArgument(arg, "-FA", "--fixture-exclude-any") &&
i < args.size() - 1) { i < args.size() - 1) {
i++; i++;
this->GetHandler("test")->SetPersistentOption( this->GetTestHandler()->SetPersistentOption(
"ExcludeFixtureRegularExpression", args[i].c_str());
this->GetMemCheckHandler()->SetPersistentOption(
"ExcludeFixtureRegularExpression", args[i].c_str()); "ExcludeFixtureRegularExpression", args[i].c_str());
this->GetHandler("memcheck")
->SetPersistentOption("ExcludeFixtureRegularExpression",
args[i].c_str());
} }
if (this->CheckArgument(arg, "-FS", "--fixture-exclude-setup") && if (this->CheckArgument(arg, "-FS", "--fixture-exclude-setup") &&
i < args.size() - 1) { i < args.size() - 1) {
i++; i++;
this->GetHandler("test")->SetPersistentOption( this->GetTestHandler()->SetPersistentOption(
"ExcludeFixtureSetupRegularExpression", args[i].c_str());
this->GetMemCheckHandler()->SetPersistentOption(
"ExcludeFixtureSetupRegularExpression", args[i].c_str()); "ExcludeFixtureSetupRegularExpression", args[i].c_str());
this->GetHandler("memcheck")
->SetPersistentOption("ExcludeFixtureSetupRegularExpression",
args[i].c_str());
} }
if (this->CheckArgument(arg, "-FC", "--fixture-exclude-cleanup") && if (this->CheckArgument(arg, "-FC", "--fixture-exclude-cleanup") &&
i < args.size() - 1) { i < args.size() - 1) {
i++; i++;
this->GetHandler("test")->SetPersistentOption( this->GetTestHandler()->SetPersistentOption(
"ExcludeFixtureCleanupRegularExpression", args[i].c_str());
this->GetMemCheckHandler()->SetPersistentOption(
"ExcludeFixtureCleanupRegularExpression", args[i].c_str()); "ExcludeFixtureCleanupRegularExpression", args[i].c_str());
this->GetHandler("memcheck")
->SetPersistentOption("ExcludeFixtureCleanupRegularExpression",
args[i].c_str());
} }
if (this->CheckArgument(arg, "--rerun-failed")) { if (this->CheckArgument(arg, "--rerun-failed")) {
this->GetHandler("test")->SetPersistentOption("RerunFailed", "true"); this->GetTestHandler()->SetPersistentOption("RerunFailed", "true");
this->GetHandler("memcheck")->SetPersistentOption("RerunFailed", "true"); this->GetMemCheckHandler()->SetPersistentOption("RerunFailed", "true");
} }
return true; return true;
} }
@@ -2292,8 +2284,7 @@ void cmCTest::HandleScriptArguments(size_t& i, std::vector<std::string>& args,
i < args.size() - 1) { i < args.size() - 1) {
this->Impl->RunConfigurationScript = true; this->Impl->RunConfigurationScript = true;
i++; i++;
cmCTestScriptHandler* ch = cmCTestScriptHandler* ch = this->GetScriptHandler();
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
// -SR is an internal argument, -SP should be ignored when it is passed // -SR is an internal argument, -SP should be ignored when it is passed
if (!SRArgumentSpecified) { if (!SRArgumentSpecified) {
ch->AddConfigurationScript(args[i].c_str(), false); ch->AddConfigurationScript(args[i].c_str(), false);
@@ -2304,16 +2295,14 @@ void cmCTest::HandleScriptArguments(size_t& i, std::vector<std::string>& args,
SRArgumentSpecified = true; SRArgumentSpecified = true;
this->Impl->RunConfigurationScript = true; this->Impl->RunConfigurationScript = true;
i++; i++;
cmCTestScriptHandler* ch = cmCTestScriptHandler* ch = this->GetScriptHandler();
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
ch->AddConfigurationScript(args[i].c_str(), true); ch->AddConfigurationScript(args[i].c_str(), true);
} }
if (this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1) { if (this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1) {
this->Impl->RunConfigurationScript = true; this->Impl->RunConfigurationScript = true;
i++; i++;
cmCTestScriptHandler* ch = cmCTestScriptHandler* ch = this->GetScriptHandler();
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
// -SR is an internal argument, -S should be ignored when it is passed // -SR is an internal argument, -S should be ignored when it is passed
if (!SRArgumentSpecified) { if (!SRArgumentSpecified) {
ch->AddConfigurationScript(args[i].c_str(), true); ch->AddConfigurationScript(args[i].c_str(), true);
@@ -2537,8 +2526,8 @@ int cmCTest::ExecuteTests()
handler->SetVerbose(this->Impl->ExtraVerbose); handler->SetVerbose(this->Impl->ExtraVerbose);
handler->SetSubmitIndex(this->Impl->SubmitIndex); handler->SetSubmitIndex(this->Impl->SubmitIndex);
} }
this->GetHandler("script")->SetVerbose(this->Impl->Verbose); this->GetScriptHandler()->SetVerbose(this->Impl->Verbose);
res = this->GetHandler("script")->ProcessHandler(); res = this->GetScriptHandler()->ProcessHandler();
if (res != 0) { if (res != 0) {
cmCTestLog(this, DEBUG, cmCTestLog(this, DEBUG,
"running script failing returning: " << res << std::endl); "running script failing returning: " << res << std::endl);
@@ -2573,8 +2562,7 @@ int cmCTest::ExecuteTests()
int cmCTest::RunCMakeAndTest(std::string* output) int cmCTest::RunCMakeAndTest(std::string* output)
{ {
this->Impl->Verbose = true; this->Impl->Verbose = true;
cmCTestBuildAndTestHandler* handler = cmCTestBuildAndTestHandler* handler = this->GetBuildAndTestHandler();
static_cast<cmCTestBuildAndTestHandler*>(this->GetHandler("buildtest"));
int retv = handler->ProcessHandler(); int retv = handler->ProcessHandler();
*output = handler->GetOutput(); *output = handler->GetOutput();
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
@@ -3336,14 +3324,7 @@ std::string cmCTest::GetColorCode(Color color) const
cmDuration cmCTest::GetRemainingTimeAllowed() cmDuration cmCTest::GetRemainingTimeAllowed()
{ {
if (!this->GetHandler("script")) { return this->GetScriptHandler()->GetRemainingTimeAllowed();
return cmCTest::MaxDuration();
}
cmCTestScriptHandler* ch =
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
return ch->GetRemainingTimeAllowed();
} }
cmDuration cmCTest::MaxDuration() cmDuration cmCTest::MaxDuration()
@@ -3353,10 +3334,7 @@ cmDuration cmCTest::MaxDuration()
void cmCTest::SetRunCurrentScript(bool value) void cmCTest::SetRunCurrentScript(bool value)
{ {
cmCTestScriptHandler* ch = this->GetScriptHandler()->SetRunCurrentScript(value);
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
ch->SetRunCurrentScript(value);
} }
void cmCTest::OutputTestErrors(std::vector<char> const& process_output) void cmCTest::OutputTestErrors(std::vector<char> const& process_output)

View File

@@ -17,7 +17,16 @@
#include <time.h> #include <time.h>
#include <vector> #include <vector>
class cmCTestGenericHandler; class cmCTestBuildHandler;
class cmCTestBuildAndTestHandler;
class cmCTestCoverageHandler;
class cmCTestScriptHandler;
class cmCTestTestHandler;
class cmCTestUpdateHandler;
class cmCTestConfigureHandler;
class cmCTestMemCheckHandler;
class cmCTestSubmitHandler;
class cmCTestUploadHandler;
class cmCTestStartCommand; class cmCTestStartCommand;
class cmGeneratedFileStream; class cmGeneratedFileStream;
class cmMakefile; class cmMakefile;
@@ -314,17 +323,19 @@ public:
std::vector<std::string>* environment, std::vector<std::string>* environment,
Encoding encoding = cmProcessOutput::Auto); Encoding encoding = cmProcessOutput::Auto);
/**
* Execute handler and return its result. If the handler fails, it returns
* negative value.
*/
int ExecuteHandler(const char* handler);
/** /**
* Get the handler object * Get the handler object
*/ */
cmCTestGenericHandler* GetHandler(const char* handler); cmCTestBuildHandler* GetBuildHandler();
cmCTestGenericHandler* GetInitializedHandler(const char* handler); cmCTestBuildAndTestHandler* GetBuildAndTestHandler();
cmCTestCoverageHandler* GetCoverageHandler();
cmCTestScriptHandler* GetScriptHandler();
cmCTestTestHandler* GetTestHandler();
cmCTestUpdateHandler* GetUpdateHandler();
cmCTestConfigureHandler* GetConfigureHandler();
cmCTestMemCheckHandler* GetMemCheckHandler();
cmCTestSubmitHandler* GetSubmitHandler();
cmCTestUploadHandler* GetUploadHandler();
/** /**
* Set the CTest variable from CMake variable * Set the CTest variable from CMake variable

View File

@@ -191,8 +191,7 @@ int main(int argc, char const* const* argv)
doc.addCTestStandardDocSections(); doc.addCTestStandardDocSections();
if (doc.CheckOptions(argc, argv)) { if (doc.CheckOptions(argc, argv)) {
// Construct and print requested documentation. // Construct and print requested documentation.
cmCTestScriptHandler* ch = cmCTestScriptHandler* ch = inst.GetScriptHandler();
static_cast<cmCTestScriptHandler*>(inst.GetHandler("script"));
ch->CreateCMake(); ch->CreateCMake();
doc.SetShowGenerators(false); doc.SetShowGenerators(false);