Cleanup test property script code generation
We teach cmTestGenerator::GenerateScriptConfigs to use the general cmLocalGenerator::EscapeForCMake method to write escaped test property values into test scripts. This eliminates the previous hand-coded escaping implementation.
This commit is contained in:
parent
cf6634fe2a
commit
821247ef4d
|
@ -50,6 +50,8 @@ void cmTestGenerator::GenerateScriptConfigs(std::ostream& os,
|
||||||
if(this->TestGenerated)
|
if(this->TestGenerated)
|
||||||
{
|
{
|
||||||
cmTest* test = this->Test;
|
cmTest* test = this->Test;
|
||||||
|
cmMakefile* mf = test->GetMakefile();
|
||||||
|
cmLocalGenerator* lg = mf->GetLocalGenerator();
|
||||||
std::ostream& fout = os;
|
std::ostream& fout = os;
|
||||||
cmPropertyMap::const_iterator pit;
|
cmPropertyMap::const_iterator pit;
|
||||||
cmPropertyMap* mpit = &test->GetProperties();
|
cmPropertyMap* mpit = &test->GetProperties();
|
||||||
|
@ -58,36 +60,8 @@ void cmTestGenerator::GenerateScriptConfigs(std::ostream& os,
|
||||||
fout << "SET_TESTS_PROPERTIES(" << test->GetName() << " PROPERTIES ";
|
fout << "SET_TESTS_PROPERTIES(" << test->GetName() << " PROPERTIES ";
|
||||||
for ( pit = mpit->begin(); pit != mpit->end(); ++ pit )
|
for ( pit = mpit->begin(); pit != mpit->end(); ++ pit )
|
||||||
{
|
{
|
||||||
fout << " " << pit->first.c_str() << " \"";
|
fout << " " << pit->first
|
||||||
const char* value = pit->second.GetValue();
|
<< " " << lg->EscapeForCMake(pit->second.GetValue());
|
||||||
for ( ; *value; ++ value )
|
|
||||||
{
|
|
||||||
switch ( *value )
|
|
||||||
{
|
|
||||||
case '\\':
|
|
||||||
case '"':
|
|
||||||
case ' ':
|
|
||||||
case '#':
|
|
||||||
case '(':
|
|
||||||
case ')':
|
|
||||||
case '$':
|
|
||||||
case '^':
|
|
||||||
fout << "\\" << *value;
|
|
||||||
break;
|
|
||||||
case '\t':
|
|
||||||
fout << "\\t";
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
fout << "\\n";
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
fout << "\\r";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fout << *value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fout << "\"";
|
|
||||||
}
|
}
|
||||||
fout << ")" << std::endl;
|
fout << ")" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue