diff --git a/CTestConfig.cmake b/CTestConfig.cmake new file mode 100644 index 000000000..0623d6779 --- /dev/null +++ b/CTestConfig.cmake @@ -0,0 +1,6 @@ +SET (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +SET (CTEST_DROP_SITE "public.kitware.com") +SET (CTEST_DROP_LOCATION "/cgi-bin/HTTPUploadDartFile.cgi") +SET (CTEST_TRIGGER_SITE + "http://${DROP_SITE}/cgi-bin/Submit-CMake-TestingResults.cgi") + diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 393109c1d..f3fdbeb95 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -151,20 +151,22 @@ INCLUDE_DIRECTORIES( # Sources for CTestLib # SET(CMTEST_SRCS cmCTest.cxx - CTest/cmCTestGenericHandler.cxx + CTest/cmCTestBuildCommand.cxx CTest/cmCTestBuildHandler.cxx + CTest/cmCTestConfigureCommand.cxx CTest/cmCTestConfigureHandler.cxx CTest/cmCTestCoverageHandler.cxx - CTest/cmCTestScriptHandler.cxx - CTest/cmCTestTestHandler.cxx - CTest/cmCTestUpdateHandler.cxx CTest/cmCTestEmptyBinaryDirectoryCommand.cxx + CTest/cmCTestGenericHandler.cxx + CTest/cmCTestMemCheckHandler.cxx CTest/cmCTestRunScriptCommand.cxx + CTest/cmCTestScriptHandler.cxx CTest/cmCTestSleepCommand.cxx CTest/cmCTestStartCommand.cxx - CTest/cmCTestUpdateCommand.cxx - CTest/cmCTestMemCheckHandler.cxx CTest/cmCTestSubmit.cxx + CTest/cmCTestTestHandler.cxx + CTest/cmCTestUpdateCommand.cxx + CTest/cmCTestUpdateHandler.cxx ) # Build CTestLib diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx new file mode 100644 index 000000000..e1c3d666e --- /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 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 000000000..82f87a4cb --- /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 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 000000000..7d49ca488 --- /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 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 000000000..bd7c00ca5 --- /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 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 5e15b5a52..22e1146d4 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -42,6 +42,8 @@ # include #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 78938b6ec..09cdf6e26 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 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 40f13f9cc..09bf0b85d 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 ) { diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index d00f11041..e75efd40b 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -227,6 +227,7 @@ cmCTest::cmCTest() m_BuildNoClean = false; m_BuildTwoConfig = false; m_Verbose = false; + m_ExtraVerbose = false; m_ProduceXML = false; m_ShowOnly = false; m_RunConfigurationScript = false; @@ -343,7 +344,7 @@ int cmCTest::Initialize(const char* binary_dir) if ( m_TestModel == cmCTest::NIGHTLY ) { lctime = cmCTest::GetNightlyTime(m_DartConfiguration["NightlyStartTime"], - m_Verbose, + m_ExtraVerbose, m_TomorrowTag); } char datestring[100]; @@ -627,7 +628,7 @@ int cmCTest::SubmitResults() std::cout << "Submit files (using " << m_DartConfiguration["DropMethod"] << ")" << std::endl; cmCTestSubmit submit; - submit.SetVerbose(m_Verbose); + submit.SetVerbose(m_ExtraVerbose); submit.SetLogFile(&ofs); if ( m_DartConfiguration["DropMethod"] == "" || m_DartConfiguration["DropMethod"] == "ftp" ) @@ -1048,7 +1049,7 @@ int cmCTest::RunTest(std::vector argv, } cmSystemTools::ChangeDirectory(oldpath.c_str()); - if(m_Verbose) + if(m_ExtraVerbose) { std::cout << "Internal cmCTest object used to run test.\n"; std::cout << *output << "\n"; @@ -1079,7 +1080,7 @@ int cmCTest::RunTest(std::vector argv, { tempOutput.insert(tempOutput.end(), data, data+length); } - if ( m_Verbose ) + if ( m_ExtraVerbose ) { std::cout.write(data, length); std::cout.flush(); @@ -1096,7 +1097,7 @@ int cmCTest::RunTest(std::vector argv, { output->append(&*tempOutput.begin(), tempOutput.size()); } - if ( m_Verbose ) + if ( m_ExtraVerbose ) { std::cout << "-- Process completed" << std::endl; } @@ -1113,7 +1114,7 @@ int cmCTest::RunTest(std::vector argv, std::string outerr = "\n*** Exception executing: "; outerr += cmsysProcess_GetExceptionString(cp); *output += outerr; - if ( m_Verbose ) + if ( m_ExtraVerbose ) { std::cout << outerr.c_str() << "\n"; std::cout.flush(); @@ -1124,7 +1125,7 @@ int cmCTest::RunTest(std::vector argv, std::string outerr = "\n*** ERROR executing: "; outerr += cmsysProcess_GetErrorString(cp); *output += outerr; - if ( m_Verbose ) + if ( m_ExtraVerbose ) { std::cout << outerr.c_str() << "\n"; std::cout.flush(); @@ -1246,11 +1247,11 @@ int cmCTest::Run(std::vectorconst& args, std::string* output) if( arg.find("-V",0) == 0 || arg.find("--verbose",0) == 0 ) { this->m_Verbose = true; - cmCTest::t_TestingHandlers::iterator it; - for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) - { - it->second->SetVerbose(this->m_Verbose); - } + } + if( arg.find("-VV",0) == 0 || arg.find("--extra-verbose",0) == 0 ) + { + this->m_ExtraVerbose = true; + this->m_Verbose = true; } if( arg.find("-N",0) == 0 || arg.find("--show-only",0) == 0 ) @@ -1670,10 +1671,22 @@ int cmCTest::Run(std::vectorconst& args, std::string* output) // call process directory if (this->m_RunConfigurationScript) { + cmCTest::t_TestingHandlers::iterator it; + for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) + { + it->second->SetVerbose(this->m_ExtraVerbose); + } + this->GetHandler("script")->SetVerbose(m_Verbose); res = this->GetHandler("script")->ProcessHandler(); } else { + m_Verbose = m_ExtraVerbose; + cmCTest::t_TestingHandlers::iterator it; + for ( it = m_TestingHandlers.begin(); it != m_TestingHandlers.end(); ++ it ) + { + it->second->SetVerbose(this->m_Verbose); + } if ( !this->Initialize(cmSystemTools::GetCurrentWorkingDirectory().c_str()) ) { res = 12; @@ -2200,6 +2213,20 @@ std::string cmCTest::GetDartConfiguration(const char *name) return m_DartConfiguration[name]; } +void cmCTest::SetDartConfiguration(const char *name, const char* value) +{ + if ( !name ) + { + return; + } + if ( !value ) + { + m_DartConfiguration.erase(name); + return; + } + m_DartConfiguration[name] = value; +} + std::string cmCTest::GetCurrentTag() { @@ -2230,3 +2257,15 @@ bool cmCTest::GetProduceXML() { return m_ProduceXML; } + +bool cmCTest::SetDartConfigurationFromCMakeVariable(cmMakefile* mf, const char* dconfig, const char* cmake_var) +{ + const char* ctvar; + ctvar = mf->GetDefinition(cmake_var); + if ( !ctvar ) + { + return false; + } + this->SetDartConfiguration(dconfig, ctvar); + return true; +} diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 6ef86b9f8..7e832dc04 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -101,6 +101,7 @@ public: static int GetTestModelFromString(const char* str); static std::string CleanString(const std::string& str); std::string GetDartConfiguration(const char *name); + void SetDartConfiguration(const char *name, const char* value); /** * constructor and destructor @@ -192,9 +193,15 @@ public: */ cmCTestGenericHandler* GetHandler(const char* handler); + /* + * Set the CTest variable from CMake variable + */ + bool SetDartConfigurationFromCMakeVariable(cmMakefile* mf, const char* dconfig, const char* cmake_var); + private: std::string m_ConfigType; bool m_Verbose; + bool m_ExtraVerbose; bool m_ProduceXML; bool m_ForceNewCTestProcess;