diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-05-02 18:15:29 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-05-02 18:15:29 (GMT) |
commit | f1ebfb24c63e9a37d440d405d0940ee07d572ace (patch) | |
tree | 8549dde40e9728f027a357d3b16f58bdbdf41938 /Source/CTest | |
parent | 572d9f11476e1964e333373169eaff6d57e3ff43 (diff) | |
download | CMake-f1ebfb24c63e9a37d440d405d0940ee07d572ace.zip CMake-f1ebfb24c63e9a37d440d405d0940ee07d572ace.tar.gz CMake-f1ebfb24c63e9a37d440d405d0940ee07d572ace.tar.bz2 |
ENH: More commands. Start working on new style ctest configuration
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestBuildCommand.cxx | 48 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildCommand.h | 77 | ||||
-rw-r--r-- | Source/CTest/cmCTestConfigureCommand.cxx | 50 | ||||
-rw-r--r-- | Source/CTest/cmCTestConfigureCommand.h | 79 | ||||
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestStartCommand.cxx | 23 | ||||
-rw-r--r-- | Source/CTest/cmCTestUpdateCommand.cxx | 3 |
7 files changed, 286 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx new file mode 100644 index 0000000..e1c3d66 --- /dev/null +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -0,0 +1,48 @@ +/*========================================================================= + + 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 "cmCTestBuildCommand.h" + +#include "cmCTest.h" +#include "cmCTestGenericHandler.h" + +bool cmCTestBuildCommand::InitialPass( + std::vector<std::string> const& args) +{ + if (args.size() != 2) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + + const char* build_dir = args[0].c_str(); + const char* res_var = args[1].c_str(); + + m_CTest->SetDartConfiguration("BuildDirectory", build_dir); + cmCTestGenericHandler* handler = m_CTest->GetHandler("build"); + if ( !handler ) + { + this->SetError("internal CTest error. Cannot instantiate build handler"); + return false; + } + int res = handler->ProcessHandler(); + cmOStringStream str; + str << res; + m_Makefile->AddDefinition(res_var, str.str().c_str()); + return true; +} + + diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h new file mode 100644 index 0000000..82f87a4 --- /dev/null +++ b/Source/CTest/cmCTestBuildCommand.h @@ -0,0 +1,77 @@ +/*========================================================================= + + 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 cmCTestBuildCommand_h +#define cmCTestBuildCommand_h + +#include "cmCTestCommand.h" + +/** \class cmCTestBuild + * \brief Run a ctest script + * + * cmCTestBuildCommand defineds the command to build the project. + */ +class cmCTestBuildCommand : public cmCTestCommand +{ +public: + + cmCTestBuildCommand() {} + + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + cmCTestBuildCommand* ni = new cmCTestBuildCommand; + 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_BUILD";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Builds the repository."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + " CTEST_BUILD(build_dir res)\n" + "Builds the given build directory and stores results in Build.xml."; + } + + cmTypeMacro(cmCTestBuildCommand, cmCTestCommand); +}; + + +#endif diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx new file mode 100644 index 0000000..7d49ca4 --- /dev/null +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -0,0 +1,50 @@ +/*========================================================================= + + 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 "cmCTestConfigureCommand.h" + +#include "cmCTest.h" +#include "cmCTestGenericHandler.h" + +bool cmCTestConfigureCommand::InitialPass( + std::vector<std::string> const& args) +{ + if (args.size() != 2) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + + const char* build_dir = args[0].c_str(); + const char* res_var = args[1].c_str(); + + m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "ConfigureCommand", "CTEST_CONFIGURE_COMMAND"); + m_CTest->SetDartConfiguration("BuildDirectory", build_dir); + + cmCTestGenericHandler* handler = m_CTest->GetHandler("configure"); + if ( !handler ) + { + this->SetError("internal CTest error. Cannot instantiate configure handler"); + return false; + } + int res = handler->ProcessHandler(); + cmOStringStream str; + str << res; + m_Makefile->AddDefinition(res_var, str.str().c_str()); + return true; +} + + diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h new file mode 100644 index 0000000..bd7c00c --- /dev/null +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -0,0 +1,79 @@ +/*========================================================================= + + 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 cmCTestConfigureCommand_h +#define cmCTestConfigureCommand_h + +#include "cmCTestCommand.h" + +/** \class cmCTestConfigure + * \brief Run a ctest script + * + * cmCTestConfigureCommand defineds the command to configures the project. + */ +class cmCTestConfigureCommand : public cmCTestCommand +{ +public: + + cmCTestConfigureCommand() {} + + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + cmCTestConfigureCommand* ni = new cmCTestConfigureCommand; + 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_CONFIGURE";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Configures the repository."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + " CTEST_CONFIGURE(build_dir res)\n" + "Configures the given build directory and stores results in Configure.xml. The " + "second argument is a variable that will hold return value."; + } + + cmTypeMacro(cmCTestConfigureCommand, cmCTestCommand); + +}; + + +#endif diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 5e15b5a..22e1146 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -42,6 +42,8 @@ # include <unistd.h> #endif +#include "cmCTestBuildCommand.h" +#include "cmCTestConfigureCommand.h" #include "cmCTestEmptyBinaryDirectoryCommand.h" #include "cmCTestRunScriptCommand.h" #include "cmCTestSleepCommand.h" @@ -220,8 +222,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 - this->AddCTestCommand(new cmCTestRunScriptCommand); + this->AddCTestCommand(new cmCTestBuildCommand); + this->AddCTestCommand(new cmCTestConfigureCommand); this->AddCTestCommand(new cmCTestEmptyBinaryDirectoryCommand); + this->AddCTestCommand(new cmCTestRunScriptCommand); this->AddCTestCommand(new cmCTestSleepCommand); this->AddCTestCommand(new cmCTestStartCommand); this->AddCTestCommand(new cmCTestUpdateCommand); @@ -372,6 +376,7 @@ int cmCTestScriptHandler::RunConfigurationScript(const std::string& total_script return result; } +//---------------------------------------------------------------------- int cmCTestScriptHandler::RunCurrentScript() { int result; diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 78938b6..09cdf6e 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -17,6 +17,8 @@ #include "cmCTestStartCommand.h" #include "cmCTest.h" +#include "cmLocalGenerator.h" +#include "cmGlobalGenerator.h" bool cmCTestStartCommand::InitialPass( std::vector<std::string> const& args) @@ -65,6 +67,27 @@ bool cmCTestStartCommand::InitialPass( std::cout << "Run dashboard with model " << smodel << " for src dir: " << src_dir << " and binary dir: " << bld_dir << std::endl; + std::string fname = src_dir; + fname += "/CTestConfig.cmake"; + cmSystemTools::ConvertToUnixSlashes(fname); + if ( cmSystemTools::FileExists(fname.c_str()) ) + { + std::cout << " Reading ctest configuration file: " << fname.c_str() << std::endl; + bool readit = m_Makefile->ReadListFile(m_Makefile->GetCurrentListFile(), + fname.c_str() ); + if(!readit) + { + std::string m = "Could not find include file: "; + m += fname; + this->SetError(m.c_str()); + return false; + } + } + + m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME"); + m_CTest->SetDartConfiguration("SourceDirectory", src_dir); + m_CTest->SetDartConfiguration("BuildDirectory", bld_dir); + int model = m_CTest->GetTestModelFromString(smodel); m_CTest->SetTestModel(model); m_CTest->SetProduceXML(true); diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 40f13f9..09bf0b8 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -31,6 +31,9 @@ bool cmCTestUpdateCommand::InitialPass( const char* source_dir = args[0].c_str(); const char* res_var = args[1].c_str(); + m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "CVSCommand", "CTEST_CVS_COMMAND"); + m_CTest->SetDartConfigurationFromCMakeVariable(m_Makefile, "SVNCommand", "CTEST_SVN_COMMAND"); + cmCTestGenericHandler* handler = m_CTest->GetHandler("update"); if ( !handler ) { |