diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-02-17 15:51:52 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-02-17 15:51:52 (GMT) |
commit | 8fe168651033cb1374b36424ed2458db5d56ab27 (patch) | |
tree | d39ea4af235887acd1f907cb2d1a2948273e6307 | |
parent | ad5115d00f4753970187739c20360d922b36e7b1 (diff) | |
download | CMake-8fe168651033cb1374b36424ed2458db5d56ab27.zip CMake-8fe168651033cb1374b36424ed2458db5d56ab27.tar.gz CMake-8fe168651033cb1374b36424ed2458db5d56ab27.tar.bz2 |
ENH: Cleanups and add CTEST_START command
-rw-r--r-- | Source/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.cxx | 26 | ||||
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.h | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestStartCommand.cxx | 78 | ||||
-rw-r--r-- | Source/CTest/cmCTestStartCommand.h | 81 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 49 | ||||
-rw-r--r-- | Source/cmCTest.h | 104 |
9 files changed, 262 insertions, 85 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 57e9a1d..8648efa 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -151,6 +151,7 @@ SET(CMTEST_SRCS ctest.cxx cmCTest.cxx CTest/cmCTestEmptyBinaryDirectoryCommand.cxx CTest/cmCTestRunScriptCommand.cxx CTest/cmCTestSleepCommand.cxx + CTest/cmCTestStartCommand.cxx CTest/cmCTestMemCheckHandler.cxx ) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index b09ac4d..3c7e197 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -176,7 +176,7 @@ int cmCTestCoverageHandler::ProcessHandler() std::string coverage_start_time = m_CTest->CurrentTime(); - std::string testingDir = m_CTest->GetToplevelPath() + "/Testing"; + std::string testingDir = m_CTest->GetBinaryDir() + "/Testing"; std::string tempDir = testingDir + "/CoverageInfo"; std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::MakeDirectory(tempDir.c_str()); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 73577fc..490236a 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -316,7 +316,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() m_MemoryTesterOptions = m_CTest->GetDartConfiguration("ValgrindCommandOptions"); } - m_MemoryTesterOutputFile = m_CTest->GetToplevelPath() + "/Testing/Temporary/MemoryChecker.log"; + m_MemoryTesterOutputFile = m_CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; m_MemoryTesterOutputFile = cmSystemTools::EscapeSpaces(m_MemoryTesterOutputFile.c_str()); if ( m_MemoryTester.find("valgrind") != std::string::npos ) diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index d1e89df..ba396ba 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -45,6 +45,7 @@ #include "cmCTestEmptyBinaryDirectoryCommand.h" #include "cmCTestRunScriptCommand.h" #include "cmCTestSleepCommand.h" +#include "cmCTestStartCommand.h" #define CTEST_INITIAL_CMAKE_OUTPUT_FILE_NAME "CTestInitialCMakeOutput.log" @@ -158,6 +159,15 @@ void cmCTestScriptHandler::UpdateElapsedTime() } //---------------------------------------------------------------------- +void cmCTestScriptHandler::AddCTestCommand(cmCTestCommand* command) +{ + cmCTestCommand* newCom = command; + newCom->m_CTest = m_CTest; + newCom->m_CTestScriptHandler = this; + m_CMake->AddCommand(newCom); +} + +//---------------------------------------------------------------------- // this sets up some variables for thew script to use, creates the required // cmake instance and generators, and then reads in the script int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) @@ -209,18 +219,10 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) // add any ctest specific commands, probably should have common superclass // for ctest commands to clean this up. If a couple more commands are // created with the same format lets do that - ken - cmCTestCommand* newCom = new cmCTestRunScriptCommand; - newCom->m_CTest = m_CTest; - newCom->m_CTestScriptHandler = this; - m_CMake->AddCommand(newCom); - newCom = new cmCTestEmptyBinaryDirectoryCommand; - newCom->m_CTest = m_CTest; - newCom->m_CTestScriptHandler = this; - m_CMake->AddCommand(newCom); - newCom = new cmCTestSleepCommand; - newCom->m_CTest = m_CTest; - newCom->m_CTestScriptHandler = this; - m_CMake->AddCommand(newCom); + this->AddCTestCommand(new cmCTestRunScriptCommand); + this->AddCTestCommand(new cmCTestEmptyBinaryDirectoryCommand); + this->AddCTestCommand(new cmCTestSleepCommand); + this->AddCTestCommand(new cmCTestStartCommand); // add the script arg if defined if (script_arg.size()) diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 4d316ce..3b7a882 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -26,6 +26,7 @@ class cmMakefile; class cmLocalGenerator; class cmGlobalGenerator; class cmake; +class cmCTestCommand; /** \class cmCTestScriptHandler * \brief A class that handles ctest -S invocations @@ -116,6 +117,9 @@ private: int RunConfigurationScript(const std::string& script); int RunConfigurationDashboard(); + // Add ctest command + void AddCTestCommand(cmCTestCommand* command); + std::vector<cmStdString> m_ConfigurationScripts; bool m_Backup; diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx new file mode 100644 index 0000000..78938b6 --- /dev/null +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -0,0 +1,78 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmCTestStartCommand.h" + +#include "cmCTest.h" + +bool cmCTestStartCommand::InitialPass( + std::vector<std::string> const& args) +{ + if (args.size() < 1) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + + const char* smodel = args[0].c_str(); + const char* src_dir = 0; + const char* bld_dir = 0; + + if ( args.size() >= 2 ) + { + src_dir = args[1].c_str(); + if ( args.size() == 3 ) + { + bld_dir = args[2].c_str(); + } + } + if ( args.size() > 3 ) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + if ( !src_dir ) + { + src_dir = m_Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"); + } + if ( !bld_dir) + { + bld_dir = m_Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"); + } + if ( !src_dir ) + { + this->SetError("source directory not specified. Specify source directory as an argument or set CTEST_SOURCE_DIRECTORY"); + return false; + } + if ( !bld_dir) + { + this->SetError("binary directory not specified. Specify binary directory as an argument or set CTEST_BINARY_DIRECTORY"); + return false; + } + std::cout << "Run dashboard with model " << smodel + << " for src dir: " << src_dir << " and binary dir: " << bld_dir << std::endl; + + int model = m_CTest->GetTestModelFromString(smodel); + m_CTest->SetTestModel(model); + m_CTest->SetProduceXML(true); + if ( !m_CTest->Initialize(bld_dir) ) + { + return false; + } + return true; +} + + diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h new file mode 100644 index 0000000..2bed7d7 --- /dev/null +++ b/Source/CTest/cmCTestStartCommand.h @@ -0,0 +1,81 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmCTestStartCommand_h +#define cmCTestStartCommand_h + +#include "cmCTestCommand.h" + +/** \class cmCTestStart + * \brief Run a ctest script + * + * cmCTestStartCommand defineds the command to start the nightly testing. + */ +class cmCTestStartCommand : public cmCTestCommand +{ +public: + + cmCTestStartCommand() {} + + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + cmCTestStartCommand* ni = new cmCTestStartCommand; + ni->m_CTest = this->m_CTest; + ni->m_CTestScriptHandler = this->m_CTestScriptHandler; + return ni; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool InitialPass(std::vector<std::string> const& args); + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() { return "CTEST_START";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Starts the testing for a given model"; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + " CTEST_START(Model [source [binary]])\n" + "Starts the testing for a given model. The command should be called after " + "the binary directory is initialized. If the 'source' and 'binary' " + "directory are not specified, it reads the CTEST_SOURCE_DIRECTORY and " + "CTEST_BINARY_DIRECTORY."; + } + + cmTypeMacro(cmCTestStartCommand, cmCTestCommand); + +}; + + +#endif diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 8e1e88d..6d3dd26 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -227,7 +227,7 @@ cmCTest::cmCTest() m_BuildNoClean = false; m_BuildTwoConfig = false; m_Verbose = false; - m_DartMode = false; + m_ProduceXML = false; m_ShowOnly = false; m_RunConfigurationScript = false; m_TestModel = cmCTest::EXPERIMENTAL; @@ -266,23 +266,23 @@ cmCTest::~cmCTest() } } -int cmCTest::Initialize() +int cmCTest::Initialize(const char* binary_dir) { if(!m_InteractiveDebugMode) { this->BlockTestErrorDiagnostics(); } - m_ToplevelPath = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ConvertToUnixSlashes(m_ToplevelPath); - if ( !this->ReadCustomConfigurationFileTree(m_ToplevelPath.c_str()) ) + m_BinaryDir = binary_dir; + cmSystemTools::ConvertToUnixSlashes(m_BinaryDir); + if ( !this->ReadCustomConfigurationFileTree(m_BinaryDir.c_str()) ) { return 0; } this->UpdateCTestConfiguration(); - if ( m_DartMode ) + if ( m_ProduceXML ) { - std::string testingDir = m_ToplevelPath + "/Testing"; + std::string testingDir = m_BinaryDir + "/Testing"; if ( cmSystemTools::FileExists(testingDir.c_str()) ) { if ( !cmSystemTools::FileIsDirectory(testingDir.c_str()) ) @@ -410,7 +410,7 @@ void cmCTest::UpdateCTestConfiguration() m_DartConfiguration[key] = value; } fin.close(); - if ( m_DartMode ) + if ( m_ProduceXML ) { m_TimeOut = atoi(m_DartConfiguration["TimeOut"].c_str()); m_CompressXMLFiles = cmSystemTools::IsOn(m_DartConfiguration["CompressSubmission"].c_str()); @@ -495,7 +495,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name, cmGeneratedFileStream& stream, bool compress) { - std::string testingDir = m_ToplevelPath + "/Testing"; + std::string testingDir = m_BinaryDir + "/Testing"; if ( path.size() > 0 ) { testingDir += "/" + path; @@ -574,7 +574,7 @@ int cmCTest::SubmitResults() if ( this->AddIfExists(files, "Coverage.xml") ) { cmCTest::tm_VectorOfStrings gfiles; - std::string gpath = m_ToplevelPath + "/Testing/" + m_CurrentTag; + std::string gpath = m_BinaryDir + "/Testing/" + m_CurrentTag; std::string::size_type glen = gpath.size() + 1; gpath = gpath + "/CoverageLog*"; //std::cout << "Globbing for: " << gpath.c_str() << std::endl; @@ -623,7 +623,7 @@ int cmCTest::SubmitResults() cmCTest::MakeURLSafe(m_DartConfiguration["DropSitePassword"]) + "@" + m_DartConfiguration["DropSite"] + cmCTest::MakeURLSafe(m_DartConfiguration["DropLocation"]); - if ( !submit.SubmitUsingFTP(m_ToplevelPath+"/Testing/"+m_CurrentTag, + if ( !submit.SubmitUsingFTP(m_BinaryDir+"/Testing/"+m_CurrentTag, files, prefix, url) ) { std::cerr << " Problems when submitting via FTP" << std::endl; @@ -655,7 +655,7 @@ int cmCTest::SubmitResults() url += "@"; } url += m_DartConfiguration["DropSite"] + m_DartConfiguration["DropLocation"]; - if ( !submit.SubmitUsingHTTP(m_ToplevelPath+"/Testing/"+m_CurrentTag, files, prefix, url) ) + if ( !submit.SubmitUsingHTTP(m_BinaryDir+"/Testing/"+m_CurrentTag, files, prefix, url) ) { std::cerr << " Problems when submitting via HTTP" << std::endl; ofs << " Problems when submitting via HTTP" << std::endl; @@ -681,7 +681,7 @@ int cmCTest::SubmitResults() url += m_DartConfiguration["DropSite"] + ":" + m_DartConfiguration["DropLocation"]; if ( !submit.SubmitUsingSCP(m_DartConfiguration["ScpCommand"], - m_ToplevelPath+"/Testing/"+m_CurrentTag, files, prefix, url) ) + m_BinaryDir+"/Testing/"+m_CurrentTag, files, prefix, url) ) { std::cerr << " Problems when submitting via SCP" << std::endl; ofs << " Problems when submitting via SCP" << std::endl; @@ -696,7 +696,7 @@ int cmCTest::SubmitResults() bool cmCTest::CTestFileExists(const std::string& filename) { - std::string testingDir = m_ToplevelPath + "/Testing/" + m_CurrentTag + "/" + + std::string testingDir = m_BinaryDir + "/Testing/" + m_CurrentTag + "/" + filename; return cmSystemTools::FileExists(testingDir.c_str()); } @@ -780,7 +780,7 @@ int cmCTest::ProcessTests() } if ( !notest ) { - std::string notes_dir = m_ToplevelPath + "/Testing/Notes"; + std::string notes_dir = m_BinaryDir + "/Testing/Notes"; if ( cmSystemTools::FileIsDirectory(notes_dir.c_str()) ) { cmsys::Directory d; @@ -1218,7 +1218,7 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output) } if( arg.find("-D",0) == 0 && i < args.size() - 1 ) { - this->m_DartMode = true; + this->m_ProduceXML = true; i++; std::string targ = args[i]; if ( targ == "Experimental" ) @@ -1419,7 +1419,7 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output) if( ( arg.find("-T",0) == 0 ) && (i < args.size() -1) ) { - this->m_DartMode = true; + this->m_ProduceXML = true; i++; if ( !this->SetTest(args[i].c_str(), false) ) { @@ -1496,7 +1496,7 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output) if(arg.find("-A",0) == 0 && i < args.size() - 1) { - this->m_DartMode = true; + this->m_ProduceXML = true; this->SetTest("Notes"); i++; this->SetNotesFiles(args[i].c_str()); @@ -1617,7 +1617,7 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output) } else { - if ( !this->Initialize() ) + if ( !this->Initialize(cmSystemTools::GetCurrentWorkingDirectory().c_str()) ) { res = 12; } @@ -2285,9 +2285,9 @@ std::string cmCTest::GetCurrentTag() return m_CurrentTag; } -std::string cmCTest::GetToplevelPath() +std::string cmCTest::GetBinaryDir() { - return m_ToplevelPath; + return m_BinaryDir; } std::string cmCTest::GetConfigType() @@ -2300,7 +2300,12 @@ bool cmCTest::GetShowOnly() return m_ShowOnly; } +void cmCTest::SetProduceXML(bool v) +{ + m_ProduceXML = v; +} + bool cmCTest::GetProduceXML() { - return m_DartMode; + return m_ProduceXML; } diff --git a/Source/cmCTest.h b/Source/cmCTest.h index adb8d9b..3674f01 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -38,7 +38,7 @@ public: /** * Initialize and finalize testing */ - int Initialize(); + int Initialize(const char* binary_dir); void Finalize(); /** @@ -110,53 +110,25 @@ public: //! Set the notes files to be created. void SetNotesFiles(const char* notes); - std::string m_ConfigType; - bool m_Verbose; - bool m_DartMode; - - bool m_ForceNewCTestProcess; - - bool m_RunConfigurationScript; - - enum { - EXPERIMENTAL, - NIGHTLY, - CONTINUOUS - }; - - // provide some more detailed info on the return code for ctest - enum { - UPDATE_ERRORS = 0x01, - CONFIGURE_ERRORS = 0x02, - BUILD_ERRORS = 0x04, - TEST_ERRORS = 0x08, - MEMORY_ERRORS = 0x10, - COVERAGE_ERRORS = 0x20 - }; - - int GenerateNotesFile(const char* files); + static void PopulateCustomVector(cmMakefile* mf, const char* definition, + tm_VectorOfStrings& vec); + static void PopulateCustomInteger(cmMakefile* mf, const char* def, int& val); + ///! Get the current time as string + std::string CurrentTime(); + + ///! Open file in the output directory and set the stream bool OpenOutputFile(const std::string& path, const std::string& name, cmGeneratedFileStream& stream, bool compress = false); + + ///! Convert string to something that is XML safe static std::string MakeXMLSafe(const std::string&); - static std::string MakeURLSafe(const std::string&); - - /* - * return the current tag - */ - std::string GetCurrentTag(); - ///! Get the current time as string - std::string CurrentTime(); - ///! Should we only show what we would do? bool GetShowOnly(); - ///! Are we producing XML - bool GetProduceXML(); - //! Start CTest XML output file void StartXML(std::ostream& ostr); @@ -169,25 +141,60 @@ public: int* retVal, const char* dir, bool verbose, int timeout, std::ofstream& ofs); - static void PopulateCustomVector(cmMakefile* mf, const char* definition, - tm_VectorOfStrings& vec); - static void PopulateCustomInteger(cmMakefile* mf, const char* def, int& val); + /* + * return the current tag + */ + std::string GetCurrentTag(); - std::string GetToplevelPath(); + //! Get the path to the build tree + std::string GetBinaryDir(); + //! Get the short path to the file. This means if the file is in binary or + //source directory, it will become /.../relative/path/to/file + std::string GetShortPathToFile(const char* fname); + + //! Get the path to CTest + const char* GetCTestExecutable() { return m_CTestSelf.c_str(); } + + enum { + EXPERIMENTAL, + NIGHTLY, + CONTINUOUS + }; + + // provide some more detailed info on the return code for ctest + enum { + UPDATE_ERRORS = 0x01, + CONFIGURE_ERRORS = 0x02, + BUILD_ERRORS = 0x04, + TEST_ERRORS = 0x08, + MEMORY_ERRORS = 0x10, + COVERAGE_ERRORS = 0x20 + }; + + ///! Are we producing XML + bool GetProduceXML(); + void SetProduceXML(bool v); + //! Run command specialized for tests. Returns process status and retVal is // return value or exception. int RunTest(std::vector<const char*> args, std::string* output, int *retVal, std::ostream* logfile); - //! Get the path to CTest - const char* GetCTestExecutable() { return m_CTestSelf.c_str(); } +private: - //! Get the short path to the file. This means if the file is in binary or - //source directory, it will become /.../relative/path/to/file - std::string GetShortPathToFile(const char* fname); + std::string m_ConfigType; + bool m_Verbose; + bool m_ProduceXML; -private: + bool m_ForceNewCTestProcess; + + bool m_RunConfigurationScript; + + int GenerateNotesFile(const char* files); + + static std::string MakeURLSafe(const std::string&); + // these are helper classes typedef std::map<cmStdString,cmCTestGenericHandler*> t_TestingHandlers; t_TestingHandlers m_TestingHandlers; @@ -212,7 +219,6 @@ private: //! Map of configuration properties typedef std::map<cmStdString, cmStdString> tm_DartConfigurationMap; - std::string m_ToplevelPath; tm_DartConfigurationMap m_DartConfiguration; int m_Tests[LAST_TEST]; |