updated to handle extensions
This commit is contained in:
parent
c05e3613ce
commit
0f6e022dca
|
@ -69,11 +69,15 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
|||
++i;
|
||||
|
||||
// Name of the test driver
|
||||
|
||||
// make sure they specified an extension
|
||||
if (cmSystemTools::GetFilenameExtension(*i).size() < 1)
|
||||
{
|
||||
this->SetError("You must specify a file extenion for the test driver file.");
|
||||
return false;
|
||||
}
|
||||
std::string driver = m_Makefile->GetCurrentOutputDirectory();
|
||||
driver += "/";
|
||||
driver += *i;
|
||||
driver += ".cxx";
|
||||
++i;
|
||||
|
||||
std::ofstream fout(driver.c_str());
|
||||
|
@ -119,20 +123,29 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
|||
{
|
||||
break;
|
||||
}
|
||||
std::string func_name = *i;
|
||||
std::string func_name;
|
||||
if (cmSystemTools::GetFilenamePath(*i).size() > 0)
|
||||
{
|
||||
func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(*i);
|
||||
}
|
||||
else
|
||||
{
|
||||
func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
|
||||
}
|
||||
cmSystemTools::ConvertToUnixSlashes(func_name);
|
||||
cmSystemTools::ReplaceString(func_name, " ", "_");
|
||||
cmSystemTools::ReplaceString(func_name, "/", "_");
|
||||
cmSystemTools::ReplaceString(func_name, ":", "_");
|
||||
tests_func_name.push_back(func_name);
|
||||
fout << "int " << func_name << "(int, char**);\n";
|
||||
fout << "int " << func_name << "(int, char*[]);\n";
|
||||
}
|
||||
|
||||
fout <<
|
||||
"\n"
|
||||
"// Create map\n"
|
||||
"\n"
|
||||
"typedef int (*MainFuncPointer)(int , char**);\n"
|
||||
"typedef int (*MainFuncPointer)(int , char*[]);\n"
|
||||
"struct functionMapEntry\n"
|
||||
"{\n"
|
||||
" const char* name;\n"
|
||||
|
@ -145,9 +158,19 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
|||
std::vector<std::string>::iterator j;
|
||||
for(i = testsBegin, j = tests_func_name.begin(); i != tests.end(); ++i, ++j)
|
||||
{
|
||||
std::string func_name;
|
||||
if (cmSystemTools::GetFilenamePath(*i).size() > 0)
|
||||
{
|
||||
func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(*i);
|
||||
}
|
||||
else
|
||||
{
|
||||
func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
|
||||
}
|
||||
fout <<
|
||||
" {\n"
|
||||
" \"" << *i << "\",\n"
|
||||
" \"" << func_name << "\",\n"
|
||||
" " << *j << "\n"
|
||||
" },\n";
|
||||
numTests++;
|
||||
|
@ -177,7 +200,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
|||
" return new_string;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"int main(int ac, char** av)\n"
|
||||
"int main(int ac, char *av[])\n"
|
||||
"{\n"
|
||||
" int NumTests, i, testNum, partial_match;\n"
|
||||
" char *arg, *test_name;\n"
|
||||
|
@ -266,12 +289,12 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
|||
std::string sourceListValue;
|
||||
|
||||
cfile.SetIsAnAbstractClass(false);
|
||||
cfile.SetName(args[1].c_str(),
|
||||
cfile.SetName(cmSystemTools::GetFilenameWithoutExtension(args[1]).c_str(),
|
||||
m_Makefile->GetCurrentOutputDirectory(),
|
||||
"cxx",
|
||||
false);
|
||||
m_Makefile->AddSource(cfile);
|
||||
sourceListValue = args[1] + ".cxx";
|
||||
sourceListValue = args[1];
|
||||
|
||||
for(i = testsBegin; i != tests.end(); ++i)
|
||||
{
|
||||
|
|
|
@ -70,11 +70,11 @@ public:
|
|||
"CREATE_TEST_SOURCELIST(SourceListName DriverName test1 test2 test3 "
|
||||
"EXTRA_INCLUDE include.h FUNCTION function) The list of source files "
|
||||
"needed to build the testdriver will be in SourceListName. "
|
||||
"DriverName.cxx is the name of the test driver program. The rest of "
|
||||
"DriverName is the name of the test driver program. The rest of "
|
||||
"the arguments consist of a list of test source files, can be "
|
||||
"; separated. Each test source file should have a function in it that "
|
||||
"is the same name as the file with no extension (foo.cxx should have "
|
||||
"int foo();) DriverName.cxx will be able to call each of the tests by "
|
||||
"int foo();) DriverName will be able to call each of the tests by "
|
||||
"name on the command line. If EXTRA_INCLUDE is specified, then the "
|
||||
"next argument is included into the generated file. If FUNCTION is "
|
||||
"specified, then the next argument is taken as a function name that "
|
||||
|
|
Loading…
Reference in New Issue