From 7acfc4dc3cd8c5865ff55ed94e210776cff6876b Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Fri, 1 Apr 2005 14:57:55 -0500 Subject: [PATCH] ENH: Start adding support for CTest testfiles --- Source/CTest/cmCTestTestHandler.cxx | 18 ++++++++++++++---- Source/cmAddTestCommand.cxx | 9 ++++++++- Source/cmCTest.cxx | 17 ++++++++++++++++- Source/cmCTest.h | 1 + Source/cmEnableTestingCommand.cxx | 9 ++++++++- Source/ctest.cxx | 7 ++++++- 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 81bd145d8..4c6e1da09 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -798,14 +798,24 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe) //---------------------------------------------------------------------- void cmCTestTestHandler::GetListOfTests(tm_ListOfTests* testlist) { - // does the DartTestfile.txt exist ? - if(!cmSystemTools::FileExists("DartTestfile.txt")) + const char* testFilename = 0; + 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; } // parse the file - std::ifstream fin("DartTestfile.txt"); + std::ifstream fin(testFilename); if(!fin) { return; @@ -815,7 +825,7 @@ void cmCTestTestHandler::GetListOfTests(tm_ListOfTests* testlist) cmsys::RegularExpression ereg(this->m_ExcludeRegExp.c_str()); cmListFileCache cache; - cmListFile* listFile = cache.GetFileCache("DartTestfile.txt", false); + cmListFile* listFile = cache.GetFileCache(testFilename, false); for(std::vector::const_iterator f = listFile->m_Functions.begin(); f != listFile->m_Functions.end(); ++f) { diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 28ee2d72a..66203e2ea 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -44,7 +44,14 @@ void cmAddTestCommand::FinalPass() std::string fname; fname = m_Makefile->GetStartOutputDirectory(); 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 diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index e8e16a2cc..ed2856022 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -234,6 +234,7 @@ cmCTest::cmCTest() m_InteractiveDebugMode = true; m_TimeOut = 0; m_CompressXMLFiles = false; + m_CTestConfigFile = ""; int cc; for ( cc=0; cc < cmCTest::LAST_TEST; cc ++ ) { @@ -370,7 +371,15 @@ int cmCTest::Initialize(const char* binary_dir) 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()) ) { std::cerr << "Cannot find file: " << fileName.c_str() << std::endl; @@ -1221,6 +1230,12 @@ int cmCTest::Run(std::vectorconst& args, std::string* output) for(unsigned int i=1; i < args.size(); ++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) { i++; diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 1837a5386..6ef86b9f8 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -229,6 +229,7 @@ private: //! Map of configuration properties typedef std::map tm_DartConfigurationMap; + std::string m_CTestConfigFile; tm_DartConfigurationMap m_DartConfiguration; int m_Tests[LAST_TEST]; diff --git a/Source/cmEnableTestingCommand.cxx b/Source/cmEnableTestingCommand.cxx index 36625965c..9a97083c1 100644 --- a/Source/cmEnableTestingCommand.cxx +++ b/Source/cmEnableTestingCommand.cxx @@ -37,7 +37,14 @@ void cmEnableTestingCommand::CreateDartTestfileForMakefile(cmMakefile *mf) std::string fname; fname = mf->GetStartOutputDirectory(); fname += "/"; - fname += "DartTestfile.txt"; + if ( m_Makefile->IsOn("DART_ROOT") ) + { + fname += "DartTestfile.txt"; + } + else + { + fname += "CTestTestfile.cmake"; + } cmSystemTools::MakeDirectory(mf->GetStartOutputDirectory()); diff --git a/Source/ctest.cxx b/Source/ctest.cxx index fee6f2a85..d26257027 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -138,6 +138,10 @@ static const cmDocumentationEntry cmDocumentationOptions[] = {"--test-command", "The test to run with the --build-and-test option.", "" }, {"--tomorrow-tag", "Nightly or experimental starts with next day tag.", "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} }; @@ -166,7 +170,8 @@ int main (int argc, char *argv[]) // If there is a testing input file, check for documentation options // only if there are actually arguments. We want running without // 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) {