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.
This commit is contained in:
David Cole 2012-06-24 06:16:32 -04:00
parent af298480d0
commit 93d084c180
4 changed files with 46 additions and 2 deletions

View File

@ -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())

View File

@ -2229,6 +2229,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)
@ -2264,11 +2280,14 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
// AddTestsForDashboard parses the dashboard type and converts it
// into the separate stages
if (!this->AddTestsForDashboardType(targ))
{
if (!this->AddVariableDefinition(targ))
{
this->ErrorMessageUnknownDashDValue(targ);
executeTests = false;
}
}
}
if(this->CheckArgument(arg, "-T", "--test-action") &&
(i < args.size() -1) )

View File

@ -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

View File

@ -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, "