summaryrefslogtreecommitdiffstats
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx166
1 files changed, 97 insertions, 69 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index b12cf40..bb6f3f2 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -75,8 +75,8 @@ struct tm* cmCTest::GetNightlyTime(std::string str,
char buf[1024];
// add todays year day and month to the time in str because
// curl_getdate no longer assumes the day is today
- sprintf(buf, "%d%02d%02d %s",
- lctime->tm_year+1900,
+ sprintf(buf, "%d%02d%02d %s",
+ lctime->tm_year+1900,
lctime->tm_mon +1,
lctime->tm_mday,
str.c_str());
@@ -223,7 +223,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
default:
break;
}
-
+
::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
@@ -237,7 +237,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
::curl_easy_cleanup(curl);
::curl_global_cleanup();
-
+
return static_cast<int>(res);
}
#endif
@@ -300,7 +300,7 @@ cmCTest::cmCTest()
this->ForceNewCTestProcess = false;
this->TomorrowTag = false;
this->Verbose = false;
-
+
this->Debug = false;
this->ShowLineNumbers = false;
this->Quiet = false;
@@ -763,7 +763,7 @@ bool cmCTest::UpdateCTestConfiguration()
}
else
{
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:"
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:"
<< fileName.c_str() << "\n");
// parse the dart test file
std::ifstream fin(fileName.c_str());
@@ -947,7 +947,7 @@ bool cmCTest::AddIfExists(Part part, const char* file)
//----------------------------------------------------------------------
bool cmCTest::CTestFileExists(const std::string& filename)
{
- std::string testingDir = this->BinaryDir + "/Testing/" +
+ std::string testingDir = this->BinaryDir + "/Testing/" +
this->CurrentTag + "/" + filename;
return cmSystemTools::FileExists(testingDir.c_str());
}
@@ -955,7 +955,7 @@ bool cmCTest::CTestFileExists(const std::string& filename)
//----------------------------------------------------------------------
cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler)
{
- cmCTest::t_TestingHandlers::iterator it =
+ cmCTest::t_TestingHandlers::iterator it =
this->TestingHandlers.find(handler);
if ( it == this->TestingHandlers.end() )
{
@@ -968,7 +968,7 @@ cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler)
//----------------------------------------------------------------------
cmCTestGenericHandler* cmCTest::GetHandler(const char* handler)
{
- cmCTest::t_TestingHandlers::iterator it =
+ cmCTest::t_TestingHandlers::iterator it =
this->TestingHandlers.find(handler);
if ( it == this->TestingHandlers.end() )
{
@@ -1317,8 +1317,8 @@ int cmCTest::RunTest(std::vector<const char*> argv,
{
if(argv[i])
{
- // make sure we pass the timeout in for any build and test
- // invocations. Since --build-generator is required this is a
+ // make sure we pass the timeout in for any build and test
+ // invocations. Since --build-generator is required this is a
// good place to check for it, and to add the arguments in
if (strcmp(argv[i],"--build-generator") == 0 && timeout > 0)
{
@@ -1527,18 +1527,18 @@ void cmCTest::StartXML(std::ostream& ostr, bool append)
<< "\tNumberOfPhysicalCPU=\""<< info.GetNumberOfPhysicalCPU() << "\"\n"
<< "\tTotalVirtualMemory=\"" << info.GetTotalVirtualMemory() << "\"\n"
<< "\tTotalPhysicalMemory=\""<< info.GetTotalPhysicalMemory() << "\"\n"
- << "\tLogicalProcessorsPerPhysical=\""
+ << "\tLogicalProcessorsPerPhysical=\""
<< info.GetLogicalProcessorsPerPhysical() << "\"\n"
- << "\tProcessorClockFrequency=\""
- << info.GetProcessorClockFrequency() << "\"\n"
+ << "\tProcessorClockFrequency=\""
+ << info.GetProcessorClockFrequency() << "\"\n"
<< ">" << std::endl;
- this->AddSiteProperties(ostr);
+ this->AddSiteProperties(ostr);
}
//----------------------------------------------------------------------
void cmCTest::AddSiteProperties(std::ostream& ostr)
{
- cmCTestScriptHandler* ch =
+ cmCTestScriptHandler* ch =
static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
cmake* cm = ch->GetCMake();
// if no CMake then this is the old style script and props like
@@ -1550,9 +1550,9 @@ void cmCTest::AddSiteProperties(std::ostream& ostr)
// This code should go when cdash is changed to use labels only
const char* subproject = cm->GetProperty("SubProject", cmProperty::GLOBAL);
if(subproject)
- {
+ {
ostr << "<Subproject name=\"" << subproject << "\">\n";
- const char* labels =
+ const char* labels =
ch->GetCMake()->GetProperty("SubProjectLabels", cmProperty::GLOBAL);
if(labels)
{
@@ -1569,11 +1569,11 @@ void cmCTest::AddSiteProperties(std::ostream& ostr)
}
ostr << "</Subproject>\n";
}
-
+
// This code should stay when cdash only does label based sub-projects
const char* label = cm->GetProperty("Label", cmProperty::GLOBAL);
if(label)
- {
+ {
ostr << "<Labels>\n";
ostr << " <Label>" << label << "</Label>\n";
ostr << "</Labels>\n";
@@ -1765,7 +1765,7 @@ bool cmCTest::SubmitExtraFiles(const char* cfiles)
//-------------------------------------------------------
-// for a -D argument convert the next argument into
+// for a -D argument convert the next argument into
// the proper list of dashboard steps via SetTest
bool cmCTest::AddTestsForDashboardType(std::string &targ)
{
@@ -1947,29 +1947,6 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
}
else
{
- cmCTestLog(this, ERROR_MESSAGE,
- "CTest -D called with incorrect option: "
- << targ << std::endl);
- cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
- << " " << "ctest" << " -D Continuous" << std::endl
- << " " << "ctest"
- << " -D Continuous(Start|Update|Configure|Build)" << std::endl
- << " " << "ctest"
- << " -D Continuous(Test|Coverage|MemCheck|Submit)"
- << std::endl
- << " " << "ctest" << " -D Experimental" << std::endl
- << " " << "ctest"
- << " -D Experimental(Start|Update|Configure|Build)"
- << std::endl
- << " " << "ctest"
- << " -D Experimental(Test|Coverage|MemCheck|Submit)"
- << std::endl
- << " " << "ctest" << " -D Nightly" << std::endl
- << " " << "ctest"
- << " -D Nightly(Start|Update|Configure|Build)" << std::endl
- << " " << "ctest"
- << " -D Nightly(Test|Coverage|MemCheck|Submit)" << std::endl
- << " " << "ctest" << " -D NightlyMemoryCheck" << std::endl);
return false;
}
return true;
@@ -1977,6 +1954,27 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
//----------------------------------------------------------------------
+void cmCTest::ErrorMessageUnknownDashDValue(std::string &val)
+{
+ cmCTestLog(this, ERROR_MESSAGE,
+ "CTest -D called with incorrect option: " << val << std::endl);
+
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Available options are:" << std::endl
+ << " ctest -D Continuous" << std::endl
+ << " ctest -D Continuous(Start|Update|Configure|Build)" << std::endl
+ << " ctest -D Continuous(Test|Coverage|MemCheck|Submit)" << std::endl
+ << " ctest -D Experimental" << std::endl
+ << " ctest -D Experimental(Start|Update|Configure|Build)" << std::endl
+ << " ctest -D Experimental(Test|Coverage|MemCheck|Submit)" << std::endl
+ << " ctest -D Nightly" << std::endl
+ << " ctest -D Nightly(Start|Update|Configure|Build)" << std::endl
+ << " ctest -D Nightly(Test|Coverage|MemCheck|Submit)" << std::endl
+ << " ctest -D NightlyMemoryCheck" << std::endl);
+}
+
+
+//----------------------------------------------------------------------
bool cmCTest::CheckArgument(const std::string& arg, const char* varg1,
const char* varg2)
{
@@ -1985,9 +1983,9 @@ bool cmCTest::CheckArgument(const std::string& arg, const char* varg1,
//----------------------------------------------------------------------
-// Processes one command line argument (and its arguments if any)
+// Processes one command line argument (and its arguments if any)
// for many simple options and then returns
-void cmCTest::HandleCommandLineArguments(size_t &i,
+void cmCTest::HandleCommandLineArguments(size_t &i,
std::vector<std::string> &args)
{
std::string arg = args[i];
@@ -2036,14 +2034,14 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
i++;
this->SetStopTime(args[i]);
}
-
+
if(this->CheckArgument(arg, "-C", "--build-config") &&
i < args.size() - 1)
{
i++;
this->SetConfigType(args[i].c_str());
}
-
+
if(this->CheckArgument(arg, "--debug"))
{
this->Debug = true;
@@ -2083,7 +2081,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
{
this->OutputTestOutputOnTestFailure = true;
}
-
+
if(this->CheckArgument(arg, "-N", "--show-only"))
{
this->ShowOnly = true;
@@ -2123,7 +2121,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
this->SubmitIndex = 0;
}
}
-
+
if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1)
{
i++;
@@ -2176,7 +2174,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
this->GetHandler("memcheck")->
SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
}
-
+
if(this->CheckArgument(arg, "-E", "--exclude-regex") &&
i < args.size() - 1)
{
@@ -2185,17 +2183,17 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
this->GetHandler("memcheck")->
SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
- }
+ }
}
//----------------------------------------------------------------------
// handle the -S -SR and -SP arguments
-void cmCTest::HandleScriptArguments(size_t &i,
+void cmCTest::HandleScriptArguments(size_t &i,
std::vector<std::string> &args,
bool &SRArgumentSpecified)
{
std::string arg = args[i];
- if(this->CheckArgument(arg, "-SP", "--script-new-process") &&
+ if(this->CheckArgument(arg, "-SP", "--script-new-process") &&
i < args.size() - 1 )
{
this->RunConfigurationScript = true;
@@ -2208,8 +2206,8 @@ void cmCTest::HandleScriptArguments(size_t &i,
ch->AddConfigurationScript(args[i].c_str(),false);
}
}
-
- if(this->CheckArgument(arg, "-SR", "--script-run") &&
+
+ if(this->CheckArgument(arg, "-SR", "--script-run") &&
i < args.size() - 1 )
{
SRArgumentSpecified = true;
@@ -2219,7 +2217,7 @@ void cmCTest::HandleScriptArguments(size_t &i,
= static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
ch->AddConfigurationScript(args[i].c_str(),true);
}
-
+
if(this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1 )
{
this->RunConfigurationScript = true;
@@ -2235,13 +2233,29 @@ void cmCTest::HandleScriptArguments(size_t &i,
}
//----------------------------------------------------------------------
+bool cmCTest::AddVariableDefinition(const std::string &arg)
+{
+ std::string name;
+ std::string value;
+ cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
+
+ if (cmCacheManager::ParseEntry(arg.c_str(), name, value, type))
+ {
+ this->Definitions[name] = value;
+ return true;
+ }
+
+ return false;
+}
+
+//----------------------------------------------------------------------
// the main entry point of ctest, called from main
int cmCTest::Run(std::vector<std::string> &args, std::string* output)
{
this->FindRunningCMake();
const char* ctestExec = "ctest";
bool cmakeAndTest = false;
- bool performSomeTest = true;
+ bool executeTests = true;
bool SRArgumentSpecified = false;
// copy the command line
@@ -2266,14 +2280,29 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
this->ProduceXML = true;
i++;
std::string targ = args[i];
- // AddTestsForDashboard parses the dashborad type and converts it
+ // AddTestsForDashboard parses the dashboard type and converts it
// into the separate stages
if (!this->AddTestsForDashboardType(targ))
{
- performSomeTest = false;
+ if (!this->AddVariableDefinition(targ))
+ {
+ this->ErrorMessageUnknownDashDValue(targ);
+ executeTests = false;
+ }
}
}
+ // If it's not exactly -D, but it starts with -D, then try to parse out
+ // a variable definition from it, same as CMake does. Unsuccessful
+ // attempts are simply ignored since previous ctest versions ignore
+ // this too. (As well as many other unknown command line args.)
+ //
+ if(arg != "-D" && cmSystemTools::StringStartsWith(arg.c_str(), "-D"))
+ {
+ std::string input = arg.substr(2);
+ this->AddVariableDefinition(input);
+ }
+
if(this->CheckArgument(arg, "-T", "--test-action") &&
(i < args.size() -1) )
{
@@ -2281,7 +2310,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
i++;
if ( !this->SetTest(args[i].c_str(), false) )
{
- performSomeTest = false;
+ executeTests = false;
cmCTestLog(this, ERROR_MESSAGE,
"CTest -T called with incorrect option: "
<< args[i].c_str() << std::endl);
@@ -2319,7 +2348,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
}
else
{
- performSomeTest = false;
+ executeTests = false;
cmCTestLog(this, ERROR_MESSAGE,
"CTest -M called with incorrect option: " << str.c_str()
<< std::endl);
@@ -2370,7 +2399,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
} // the close of the for argument loop
- // now what sould cmake do? if --build-and-test was specified then
+ // now what sould cmake do? if --build-and-test was specified then
// we run the build and test handler and return
if(cmakeAndTest)
{
@@ -2384,14 +2413,13 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
#endif
if(retv != 0)
{
- cmCTestLog(this, DEBUG, "build and test failing returing: " << retv
+ cmCTestLog(this, DEBUG, "build and test failing returing: " << retv
<< std::endl);
}
return retv;
}
- // if some tests must be run
- if(performSomeTest)
+ if(executeTests)
{
int res;
// call process directory
@@ -2413,14 +2441,14 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
res = this->GetHandler("script")->ProcessHandler();
if(res != 0)
{
- cmCTestLog(this, DEBUG, "running script failing returning: " << res
+ cmCTestLog(this, DEBUG, "running script failing returning: " << res
<< std::endl);
}
}
else
{
- // What is this? -V seems to be the same as -VV,
+ // What is this? -V seems to be the same as -VV,
// and Verbose is always on in this case
this->ExtraVerbose = this->Verbose;
this->Verbose = true;
@@ -2447,7 +2475,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
}
if(res != 0)
{
- cmCTestLog(this, DEBUG, "Running a test(s) failed returning : " << res
+ cmCTestLog(this, DEBUG, "Running a test(s) failed returning : " << res
<< std::endl);
}
return res;