ENH: keep the name of the test as close to the source file (only the function name is cleaned up)

This commit is contained in:
Sebastien Barre 2002-03-26 18:06:36 -05:00
parent 95519ef1b7
commit 0fd3ae7ba5

View File

@ -64,23 +64,24 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
"\n"; "\n";
std::vector<std::string>::iterator testsBegin = i; std::vector<std::string>::iterator testsBegin = i;
std::vector<std::string> tests_filename; std::vector<std::string> tests_func_name;
// The rest of the arguments consist of a list of test source files. // The rest of the arguments consist of a list of test source files.
// Sadly, they can be in directories. Let's modify each arg to get // Sadly, they can be in directories. Let's find a unique function
// a unique function name for the corresponding test, and push the // name for the corresponding test, and push it to the tests_func_name
// real source filename to the tests_filename var (used at the end). // list.
// For the moment: // For the moment:
// - replace spaces ' ', ':' and '/' with underscores '_' // - replace spaces ' ', ':' and '/' with underscores '_'
for(i = testsBegin; i != args.end(); ++i) for(i = testsBegin; i != args.end(); ++i)
{ {
tests_filename.push_back(*i); std::string func_name = *i;
cmSystemTools::ConvertToUnixSlashes(*i); cmSystemTools::ConvertToUnixSlashes(func_name);
cmSystemTools::ReplaceString(*i, " ", "_"); cmSystemTools::ReplaceString(func_name, " ", "_");
cmSystemTools::ReplaceString(*i, "/", "_"); cmSystemTools::ReplaceString(func_name, "/", "_");
cmSystemTools::ReplaceString(*i, ":", "_"); cmSystemTools::ReplaceString(func_name, ":", "_");
fout << "int " << *i << "(int, char**);\n"; tests_func_name.push_back(func_name);
fout << "int " << func_name << "(int, char**);\n";
} }
fout << fout <<
@ -97,12 +98,13 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
"functionMapEntry cmakeGeneratedFunctionMapEntries[] = {\n"; "functionMapEntry cmakeGeneratedFunctionMapEntries[] = {\n";
int numTests = 0; int numTests = 0;
for(i = testsBegin; i != args.end(); ++i) std::vector<std::string>::iterator j;
for(i = testsBegin, j = tests_func_name.begin(); i != args.end(); ++i, ++j)
{ {
fout << fout <<
" {\n" " {\n"
" \"" << *i << "\",\n" " \"" << *i << "\",\n"
" " << *i << "\n" " " << *j << "\n"
" },\n"; " },\n";
numTests++; numTests++;
} }
@ -194,7 +196,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
false); false);
m_Makefile->AddSource(cfile, sourceList); m_Makefile->AddSource(cfile, sourceList);
for (i = tests_filename.begin(); i != tests_filename.end(); ++i) for(i = testsBegin; i != args.end(); ++i)
{ {
cmSourceFile cfile; cmSourceFile cfile;
cfile.SetIsAnAbstractClass(false); cfile.SetIsAnAbstractClass(false);