summaryrefslogtreecommitdiffstats
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-07-09 18:22:02 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-07-09 18:22:02 (GMT)
commit8657c3cea65ebce68b907fd5cb75055363a351c3 (patch)
tree219965a6ba55dd7aface9ff9bbb67fbe13099472 /Source/cmCTest.cxx
parente6ce00a4ac92c34fedc68fe56d74c31183ea8124 (diff)
parent361696ae2073b537545755e8ef765d080490d244 (diff)
downloadCMake-8657c3cea65ebce68b907fd5cb75055363a351c3.zip
CMake-8657c3cea65ebce68b907fd5cb75055363a351c3.tar.gz
CMake-8657c3cea65ebce68b907fd5cb75055363a351c3.tar.bz2
Merge topic 'ctest-cmd-line-vars'
361696a CTest: Add test to verify -D variable definitions work c77b57b CTest: Allow -Dvar=value with no space between the D and the var 93d084c CTest: Extend -D command line arg handling for variable definitions af29848 CTest: Rename local variable for clarity 24ba0fd CTest: Refactor error output into ErrorMessageUnknownDashDValue
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx88
1 files changed, 58 insertions, 30 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 4aff64b..b5687e3 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1944,29 +1944,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;
@@ -1974,6 +1951,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)
{
@@ -2232,13 +2230,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
@@ -2263,14 +2277,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) )
{
@@ -2278,7 +2307,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);
@@ -2316,7 +2345,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);
@@ -2387,8 +2416,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
return retv;
}
- // if some tests must be run
- if(performSomeTest)
+ if(executeTests)
{
int res;
// call process directory