ENH: Start adding support for CTest testfiles

This commit is contained in:
Andy Cedilnik 2005-04-01 14:57:55 -05:00
parent eca18a2e9f
commit 7acfc4dc3c
6 changed files with 53 additions and 8 deletions

View File

@ -798,14 +798,24 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestTestHandler::GetListOfTests(tm_ListOfTests* testlist) void cmCTestTestHandler::GetListOfTests(tm_ListOfTests* testlist)
{ {
// does the DartTestfile.txt exist ? const char* testFilename = 0;
if(!cmSystemTools::FileExists("DartTestfile.txt")) if( cmSystemTools::FileExists("CTestTestfile.cmake") )
{
// does the CTestTestfile.cmake exist ?
testFilename = "CTestTestfile.cmake";
}
else if( cmSystemTools::FileExists("DartTestfile.txt") )
{
// does the DartTestfile.txt exist ?
testFilename = "DartTestfile.txt";
}
else
{ {
return; return;
} }
// parse the file // parse the file
std::ifstream fin("DartTestfile.txt"); std::ifstream fin(testFilename);
if(!fin) if(!fin)
{ {
return; return;
@ -815,7 +825,7 @@ void cmCTestTestHandler::GetListOfTests(tm_ListOfTests* testlist)
cmsys::RegularExpression ereg(this->m_ExcludeRegExp.c_str()); cmsys::RegularExpression ereg(this->m_ExcludeRegExp.c_str());
cmListFileCache cache; cmListFileCache cache;
cmListFile* listFile = cache.GetFileCache("DartTestfile.txt", false); cmListFile* listFile = cache.GetFileCache(testFilename, false);
for(std::vector<cmListFileFunction>::const_iterator f = for(std::vector<cmListFileFunction>::const_iterator f =
listFile->m_Functions.begin(); f != listFile->m_Functions.end(); ++f) listFile->m_Functions.begin(); f != listFile->m_Functions.end(); ++f)
{ {

View File

@ -44,7 +44,14 @@ void cmAddTestCommand::FinalPass()
std::string fname; std::string fname;
fname = m_Makefile->GetStartOutputDirectory(); fname = m_Makefile->GetStartOutputDirectory();
fname += "/"; fname += "/";
fname += "DartTestfile.txt"; if ( m_Makefile->IsOn("DART_ROOT") )
{
fname += "DartTestfile.txt";
}
else
{
fname += "CTestTestfile.cmake";
}
// If the file doesn't exist, then ENABLE_TESTING hasn't been run // If the file doesn't exist, then ENABLE_TESTING hasn't been run

View File

@ -234,6 +234,7 @@ cmCTest::cmCTest()
m_InteractiveDebugMode = true; m_InteractiveDebugMode = true;
m_TimeOut = 0; m_TimeOut = 0;
m_CompressXMLFiles = false; m_CompressXMLFiles = false;
m_CTestConfigFile = "";
int cc; int cc;
for ( cc=0; cc < cmCTest::LAST_TEST; cc ++ ) for ( cc=0; cc < cmCTest::LAST_TEST; cc ++ )
{ {
@ -370,7 +371,15 @@ int cmCTest::Initialize(const char* binary_dir)
bool cmCTest::UpdateCTestConfiguration() bool cmCTest::UpdateCTestConfiguration()
{ {
std::string fileName = m_BinaryDir + "/DartConfiguration.tcl"; std::string fileName = m_CTestConfigFile;
if ( fileName.empty() )
{
fileName = m_BinaryDir + "/DartConfiguration.tcl";
if ( !cmSystemTools::FileExists(fileName.c_str()) )
{
fileName = m_BinaryDir + "/CTestConfiguration.tcl";
}
}
if ( !cmSystemTools::FileExists(fileName.c_str()) ) if ( !cmSystemTools::FileExists(fileName.c_str()) )
{ {
std::cerr << "Cannot find file: " << fileName.c_str() << std::endl; std::cerr << "Cannot find file: " << fileName.c_str() << std::endl;
@ -1221,6 +1230,12 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output)
for(unsigned int i=1; i < args.size(); ++i) for(unsigned int i=1; i < args.size(); ++i)
{ {
std::string arg = args[i]; std::string arg = args[i];
if(arg.find("--dart-config",0) == 0 && i < args.size() - 1)
{
i++;
this->m_CTestConfigFile= args[i];
}
if(arg.find("-C",0) == 0 && i < args.size() - 1) if(arg.find("-C",0) == 0 && i < args.size() - 1)
{ {
i++; i++;

View File

@ -229,6 +229,7 @@ private:
//! Map of configuration properties //! Map of configuration properties
typedef std::map<cmStdString, cmStdString> tm_DartConfigurationMap; typedef std::map<cmStdString, cmStdString> tm_DartConfigurationMap;
std::string m_CTestConfigFile;
tm_DartConfigurationMap m_DartConfiguration; tm_DartConfigurationMap m_DartConfiguration;
int m_Tests[LAST_TEST]; int m_Tests[LAST_TEST];

View File

@ -37,7 +37,14 @@ void cmEnableTestingCommand::CreateDartTestfileForMakefile(cmMakefile *mf)
std::string fname; std::string fname;
fname = mf->GetStartOutputDirectory(); fname = mf->GetStartOutputDirectory();
fname += "/"; fname += "/";
fname += "DartTestfile.txt"; if ( m_Makefile->IsOn("DART_ROOT") )
{
fname += "DartTestfile.txt";
}
else
{
fname += "CTestTestfile.cmake";
}
cmSystemTools::MakeDirectory(mf->GetStartOutputDirectory()); cmSystemTools::MakeDirectory(mf->GetStartOutputDirectory());

View File

@ -138,6 +138,10 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
{"--test-command", "The test to run with the --build-and-test option.", "" }, {"--test-command", "The test to run with the --build-and-test option.", "" },
{"--tomorrow-tag", "Nightly or experimental starts with next day tag.", {"--tomorrow-tag", "Nightly or experimental starts with next day tag.",
"This is useful if the build will not finish in one day." }, "This is useful if the build will not finish in one day." },
{"--ctest-config", "The configuration file used to initialize CTest state when submitting dashboards.",
"This option tells CTest to use different initialization file instead of "
"DartConfiguration.tcl. This way multiple initialization files can be used "
"for example to submit to multiple dashboards." },
{0,0,0} {0,0,0}
}; };
@ -166,7 +170,8 @@ int main (int argc, char *argv[])
// If there is a testing input file, check for documentation options // If there is a testing input file, check for documentation options
// only if there are actually arguments. We want running without // only if there are actually arguments. We want running without
// arguments to run tests. // arguments to run tests.
if(argc > 1 || !cmSystemTools::FileExists("DartTestfile.txt")) if(argc > 1 || !cmSystemTools::FileExists("DartTestfile.txt") &&
!cmSystemTools::FileExists("CTestTestfile.cmake"))
{ {
if(argc == 1) if(argc == 1)
{ {