summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-06-24 10:16:32 (GMT)
committerDavid Cole <david.cole@kitware.com>2012-06-24 12:03:24 (GMT)
commit93d084c180fde5bc3c31b9945ea7ddb06d9a6007 (patch)
treed5e21412dc94d4105acfdbf2c12c97cc0d8fc9d8 /Source
parentaf298480d020e814fa4537ca7d7dd44d472489b5 (diff)
downloadCMake-93d084c180fde5bc3c31b9945ea7ddb06d9a6007.zip
CMake-93d084c180fde5bc3c31b9945ea7ddb06d9a6007.tar.gz
CMake-93d084c180fde5bc3c31b9945ea7ddb06d9a6007.tar.bz2
CTest: Extend -D command line arg handling for variable definitions
If the argument following -D is not a valid dashboard type string, then try to parse it as a "var:type=value" string just like cmake already does.
Diffstat (limited to 'Source')
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx9
-rw-r--r--Source/cmCTest.cxx23
-rw-r--r--Source/cmCTest.h10
-rw-r--r--Source/ctest.cxx6
4 files changed, 46 insertions, 2 deletions
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index d3ab2ef..8643cb3 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -435,6 +435,15 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
return 2;
}
+ // Add definitions of variables passed in on the command line:
+ const std::map<std::string, std::string> &defs =
+ this->CTest->GetDefinitions();
+ for (std::map<std::string, std::string>::const_iterator it = defs.begin();
+ it != defs.end(); ++it)
+ {
+ this->Makefile->AddDefinition(it->first.c_str(), it->second.c_str());
+ }
+
// finally read in the script
if (!this->Makefile->ReadListFile(0, script.c_str()) ||
cmSystemTools::GetErrorOccuredFlag())
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index cc4a341..05e8237 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2230,6 +2230,22 @@ 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)
{
@@ -2265,8 +2281,11 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
// into the separate stages
if (!this->AddTestsForDashboardType(targ))
{
- this->ErrorMessageUnknownDashDValue(targ);
- executeTests = false;
+ if (!this->AddVariableDefinition(targ))
+ {
+ this->ErrorMessageUnknownDashDValue(targ);
+ executeTests = false;
+ }
}
}
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 68811f8..beffe9e 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -418,6 +418,11 @@ public:
std::string GetCostDataFile();
+ const std::map<std::string, std::string> &GetDefinitions()
+ {
+ return this->Definitions;
+ }
+
private:
std::string ConfigType;
std::string ScheduleType;
@@ -520,6 +525,9 @@ private:
//! read as "emit an error message for an unknown -D value"
void ErrorMessageUnknownDashDValue(std::string &val);
+ //! add a variable definition from a command line -D value
+ bool AddVariableDefinition(const std::string &arg);
+
//! parse and process most common command line arguments
void HandleCommandLineArguments(size_t &i,
std::vector<std::string> &args);
@@ -562,6 +570,8 @@ private:
int OutputLogFileLastTag;
bool OutputTestOutputOnTestFailure;
+
+ std::map<std::string, std::string> Definitions;
};
class cmCTestLogWrite
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index d41627e..d650777 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -103,6 +103,12 @@ static const char * cmDocumentationOptions[][3] =
"a dashboard test. All tests are <Mode><Test>, where Mode can be "
"Experimental, Nightly, and Continuous, and Test can be Start, Update, "
"Configure, Build, Test, Coverage, and Submit."},
+ {"-D <var>:<type>=<value>", "Define a variable for script mode",
+ "Pass in variable values on the command line. Use in "
+ "conjunction with -S to pass variable values to a dashboard script. "
+ "Parsing -D arguments as variable values is only attempted if "
+ "the value following -D does not match any of the known dashboard "
+ "types."},
{"-M <model>, --test-model <model>", "Sets the model for a dashboard",
"This option tells ctest to act as a Dart client "
"where the TestModel can be Experimental, "