diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index b323881d1..5d19e0e90 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -39,61 +39,8 @@ cmCTestBuildCommand::~cmCTestBuildCommand() } //---------------------------------------------------------------------------- -bool cmCTestBuildCommand::InitialPass( - std::vector const& args) +cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() { - const char* build_dir = 0; - const char* res_var = 0; - - bool havereturn_variable = false; - bool havesource = false; - for(size_t i=0; i < args.size(); ++i) - { - if ( havereturn_variable ) - { - res_var = args[i].c_str(); - havereturn_variable = false; - } - else if ( havesource ) - { - build_dir = args[i].c_str(); - havesource = false; - } - else if(args[i] == "RETURN_VALUE") - { - if ( res_var ) - { - this->SetError("called with incorrect number of arguments. " - "RETURN_VALUE specified twice."); - return false; - } - havereturn_variable = true; - } - else if(args[i] == "BUILD") - { - if ( build_dir ) - { - this->SetError("called with incorrect number of arguments. " - "BUILD specified twice."); - return false; - } - havesource = true; - } - else - { - cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " - << args[i].c_str() << "."; - this->SetError(str.str().c_str()); - return false; - } - } - - if ( build_dir ) - { - this->CTest->SetCTestConfiguration("BuildDirectory", build_dir); - } - cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("build"); if ( !handler ) @@ -161,14 +108,7 @@ bool cmCTestBuildCommand::InitialPass( } } - int res = handler->ProcessHandler(); - if ( res_var ) - { - cmOStringStream str; - str << res; - this->Makefile->AddDefinition(res_var, str.str().c_str()); - } - return true; + return handler; } diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index 3f4c87acb..b4f16b7ea 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -17,7 +17,7 @@ #ifndef cmCTestBuildCommand_h #define cmCTestBuildCommand_h -#include "cmCTestCommand.h" +#include "cmCTestHandlerCommand.h" class cmGlobalGenerator; @@ -26,7 +26,7 @@ class cmGlobalGenerator; * * cmCTestBuildCommand defineds the command to build the project. */ -class cmCTestBuildCommand : public cmCTestCommand +class cmCTestBuildCommand : public cmCTestHandlerCommand { public: @@ -44,12 +44,6 @@ public: 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. */ @@ -73,9 +67,12 @@ public: "Builds the given build directory and stores results in Build.xml."; } - cmTypeMacro(cmCTestBuildCommand, cmCTestCommand); + cmTypeMacro(cmCTestBuildCommand, cmCTestHandlerCommand); cmGlobalGenerator* GlobalGenerator; + +protected: + cmCTestGenericHandler* InitializeHandler(); }; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 0b7b502a1..e1011dafb 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -222,18 +222,18 @@ void cmCTestBuildHandler::Initialize() //---------------------------------------------------------------------- void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf) { - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH", - this->CustomErrorMatches); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION", - this->CustomErrorExceptions); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH", - this->CustomWarningMatches); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION", - this->CustomWarningExceptions); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", - this->MaxErrors); - cmCTest::PopulateCustomInteger(mf, + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH", + this->CustomErrorMatches); + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION", + this->CustomErrorExceptions); + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH", + this->CustomWarningMatches); + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION", + this->CustomWarningExceptions); + this->CTest->PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", + this->MaxErrors); + this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", this->MaxWarnings); } diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 2d5a16f36..829f4a51f 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -19,98 +19,35 @@ #include "cmCTest.h" #include "cmCTestGenericHandler.h" -bool cmCTestConfigureCommand::InitialPass( - std::vector const& args) +cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() { - const char* source_dir = 0; - const char* build_dir = 0; - const char* res_var = 0; - - bool havereturn_variable = false; - bool havesource = false; - bool havebuild = false; - for(size_t i=0; i < args.size(); ++i) + if ( this->Values[ct_BUILD] ) { - if ( havereturn_variable ) - { - res_var = args[i].c_str(); - havereturn_variable = false; - } - else if ( havebuild ) - { - build_dir = args[i].c_str(); - havebuild = false; - } - else if ( havesource ) - { - source_dir = args[i].c_str(); - havesource = false; - } - else if(args[i] == "RETURN_VALUE") - { - if ( res_var ) - { - this->SetError("called with incorrect number of arguments. " - "RETURN_VALUE specified twice."); - return false; - } - havereturn_variable = true; - } - else if(args[i] == "SOURCE") - { - if ( source_dir ) - { - this->SetError("called with incorrect number of arguments. " - "SOURCE specified twice."); - return false; - } - havesource = true; - } - else if(args[i] == "BUILD") - { - if ( build_dir ) - { - this->SetError("called with incorrect number of arguments. " - "BUILD specified twice."); - return false; - } - havebuild = true; - } - else - { - cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " - << args[i].c_str() << "."; - this->SetError(str.str().c_str()); - return false; - } - } - - if ( source_dir ) - { - this->CTest->SetCTestConfiguration("SourceDirectory", source_dir); + this->CTest->SetCTestConfiguration("BuildDirectory", + this->Values[ct_BUILD]); } else { - source_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"); + this->CTest->SetCTestConfiguration("BuildDirectory", + this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY")); } - - if ( build_dir ) + if ( this->Values[ct_SOURCE] ) { - this->CTest->SetCTestConfiguration("BuildDirectory", build_dir); + this->CTest->SetCTestConfiguration("SourceDirectory", + this->Values[ct_SOURCE]); } else { - build_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"); - if ( !build_dir ) - { - this->SetError("Build directory not specified. Either use BUILD " - "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY " - "variable"); - return false; - } + this->CTest->SetCTestConfiguration("SourceDirectory", + this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")); + } + if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() ) + { + this->SetError("Build directory not specified. Either use BUILD " + "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY " + "variable"); + return false; } - const char* ctestConfigureCommand = this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); @@ -125,6 +62,15 @@ bool cmCTestConfigureCommand::InitialPass( = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); if ( cmakeGeneratorName && *cmakeGeneratorName ) { + const std::string& source_dir + = this->CTest->GetCTestConfiguration("SourceDirectory"); + if ( source_dir.empty() ) + { + this->SetError("Source directory not specified. Either use SOURCE " + "argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY " + "variable"); + return false; + } std::string cmakeConfigureCommand = "\""; cmakeConfigureCommand += this->CTest->GetCMakeExecutable(); cmakeConfigureCommand += "\" \"-G"; @@ -152,14 +98,7 @@ bool cmCTestConfigureCommand::InitialPass( "internal CTest error. Cannot instantiate configure handler"); return false; } - int res = handler->ProcessHandler(); - if ( res_var ) - { - cmOStringStream str; - str << res; - this->Makefile->AddDefinition(res_var, str.str().c_str()); - } - return true; + return handler; } diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index 34b9a4d31..f5282d90e 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -17,14 +17,14 @@ #ifndef cmCTestConfigureCommand_h #define cmCTestConfigureCommand_h -#include "cmCTestCommand.h" +#include "cmCTestHandlerCommand.h" /** \class cmCTestConfigure * \brief Run a ctest script * * cmCTestConfigureCommand defineds the command to configures the project. */ -class cmCTestConfigureCommand : public cmCTestCommand +class cmCTestConfigureCommand : public cmCTestHandlerCommand { public: @@ -41,12 +41,6 @@ public: 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. */ @@ -72,7 +66,10 @@ public: "return value."; } - cmTypeMacro(cmCTestConfigureCommand, cmCTestCommand); + cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand); + +protected: + cmCTestGenericHandler* InitializeHandler(); }; diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index c70c4cfd2..b97e0b28f 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -19,61 +19,8 @@ #include "cmCTest.h" #include "cmCTestGenericHandler.h" -bool cmCTestCoverageCommand::InitialPass( - std::vector const& args) +cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() { - const char* build_dir = 0; - const char* res_var = 0; - - bool havereturn_variable = false; - bool havesource = false; - for(size_t i=0; i < args.size(); ++i) - { - if ( havereturn_variable ) - { - res_var = args[i].c_str(); - havereturn_variable = false; - } - else if ( havesource ) - { - build_dir = args[i].c_str(); - havesource = false; - } - else if(args[i] == "RETURN_VALUE") - { - if ( res_var ) - { - this->SetError("called with incorrect number of arguments. " - "RETURN_VALUE specified twice."); - return false; - } - havereturn_variable = true; - } - else if(args[i] == "BUILD") - { - if ( build_dir ) - { - this->SetError("called with incorrect number of arguments. " - "BUILD specified twice."); - return false; - } - havesource = true; - } - else - { - cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " - << args[i].c_str() << "."; - this->SetError(str.str().c_str()); - return false; - } - } - - if ( build_dir ) - { - this->CTest->SetCTestConfiguration("BuildDirectory", build_dir); - } - this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND"); @@ -84,18 +31,7 @@ bool cmCTestCoverageCommand::InitialPass( this->SetError("internal CTest error. Cannot instantiate test handler"); return false; } - std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory( - this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); - int res = handler->ProcessHandler(); - if ( res_var ) - { - cmOStringStream str; - str << res; - this->Makefile->AddDefinition(res_var, str.str().c_str()); - } - cmSystemTools::ChangeDirectory(current_dir.c_str()); - return true; + return handler; } diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index afc2879e6..7007b1856 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -17,14 +17,14 @@ #ifndef cmCTestCoverageCommand_h #define cmCTestCoverageCommand_h -#include "cmCTestCommand.h" +#include "cmCTestHandlerCommand.h" /** \class cmCTestCoverage * \brief Run a ctest script * * cmCTestCoverageCommand defineds the command to test the project. */ -class cmCTestCoverageCommand : public cmCTestCommand +class cmCTestCoverageCommand : public cmCTestHandlerCommand { public: @@ -41,12 +41,6 @@ public: 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. */ @@ -72,8 +66,10 @@ public: "value."; } - cmTypeMacro(cmCTestCoverageCommand, cmCTestCommand); + cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand); +protected: + cmCTestGenericHandler* InitializeHandler(); }; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 11424b9b5..30187e898 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -836,7 +836,7 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude regular expressions." << std::endl); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE", + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE", this->CustomCoverageExclude); std::vector::iterator it; for ( it = this->CustomCoverageExclude.begin(); diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 10d58ae7a..25662cbc6 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -44,6 +44,7 @@ bool cmCTestHandlerCommand::InitialPass( return false; } + cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;); cmCTestGenericHandler* handler = this->InitializeHandler(); if ( !handler ) { @@ -51,11 +52,31 @@ bool cmCTestHandlerCommand::InitialPass( return false; } + cmCTestLog(this->CTest, DEBUG, "Populate Custom Vectors" << std::endl;); + handler->PopulateCustomVectors(this->Makefile); + if ( this->Values[ct_BUILD] ) { this->CTest->SetCTestConfiguration("BuildDirectory", this->Values[ct_BUILD]); } + else + { + this->CTest->SetCTestConfiguration("BuildDirectory", + this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY")); + } + if ( this->Values[ct_SOURCE] ) + { + cmCTestLog(this->CTest, DEBUG, + "Set source directory to: " << this->Values[ct_SOURCE] << std::endl); + this->CTest->SetCTestConfiguration("SourceDirectory", + this->Values[ct_SOURCE]); + } + else + { + this->CTest->SetCTestConfiguration("SourceDirectory", + this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")); + } if ( this->Values[ct_SUBMIT_INDEX] ) { if ( this->CTest->GetDartVersion() <= 1 ) @@ -72,7 +93,6 @@ bool cmCTestHandlerCommand::InitialPass( } } - std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ChangeDirectory( this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 76ed37881..51954bade 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -161,12 +161,12 @@ void cmCTestMemCheckHandler::GenerateTestCommand( void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf) { this->cmCTestTestHandler::PopulateCustomVectors(mf); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK", + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK", this->CustomPreMemCheck); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK", + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK", this->CustomPostMemCheck); - cmCTest::PopulateCustomVector(mf, + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_MEMCHECK_IGNORE", this->CustomTestsIgnore); } diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 5663bc461..a85c33e5d 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -19,39 +19,8 @@ #include "cmCTest.h" #include "cmCTestGenericHandler.h" -bool cmCTestSubmitCommand::InitialPass( - std::vector const& args) +cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() { - const char* res_var = 0; - - bool havereturn_variable = false; - for(size_t i=0; i < args.size(); ++i) - { - if ( havereturn_variable ) - { - res_var = args[i].c_str(); - havereturn_variable = false; - } - else if(args[i] == "RETURN_VALUE") - { - if ( res_var ) - { - this->SetError("called with incorrect number of arguments. " - "RETURN_VALUE specified twice."); - return false; - } - havereturn_variable = true; - } - else - { - cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " - << args[i].c_str() << "."; - this->SetError(str.str().c_str()); - return false; - } - } - const char* ctestDropMethod = this->Makefile->GetDefinition("CTEST_DROP_METHOD"); const char* ctestDropSite @@ -137,14 +106,7 @@ bool cmCTestSubmitCommand::InitialPass( this->SetError("internal CTest error. Cannot instantiate submit handler"); return false; } - int res = handler->ProcessHandler(); - if ( res_var ) - { - cmOStringStream str; - str << res; - this->Makefile->AddDefinition(res_var, str.str().c_str()); - } - return true; + return handler; } diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index a683781ff..819a1400b 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -17,7 +17,7 @@ #ifndef cmCTestSubmitCommand_h #define cmCTestSubmitCommand_h -#include "cmCTestCommand.h" +#include "cmCTestHandlerCommand.h" /** \class cmCTestSubmit * \brief Run a ctest script @@ -25,7 +25,7 @@ * cmCTestSubmitCommand defineds the command to submit the test results for * the project. */ -class cmCTestSubmitCommand : public cmCTestCommand +class cmCTestSubmitCommand : public cmCTestHandlerCommand { public: @@ -42,12 +42,6 @@ public: 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. */ @@ -71,8 +65,10 @@ public: "Submits the test results for the project."; } - cmTypeMacro(cmCTestSubmitCommand, cmCTestCommand); + cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand); +protected: + cmCTestGenericHandler* InitializeHandler(); }; diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index 8831fc368..895de0009 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -9,8 +9,8 @@ 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 + 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. =========================================================================*/ @@ -19,8 +19,6 @@ #include "cmCTestHandlerCommand.h" -class cmCTestGenericHandler; - /** \class cmCTestTest * \brief Run a ctest script * @@ -31,11 +29,11 @@ class cmCTestTestCommand : public cmCTestHandlerCommand public: cmCTestTestCommand(); - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestTestCommand* ni = new cmCTestTestCommand; ni->CTest = this->CTest; @@ -51,11 +49,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Tests the repository."; } - + /** * More documentation. */ diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 30b0abb7d..9e2b3b1d0 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -385,17 +385,17 @@ void cmCTestTestHandler::Initialize() //---------------------------------------------------------------------- void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf) { - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST", + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST", this->CustomPreTest); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST", + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST", this->CustomPostTest); - cmCTest::PopulateCustomVector(mf, + this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_TESTS_IGNORE", this->CustomTestsIgnore); - cmCTest::PopulateCustomInteger(mf, + this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE", this->CustomMaximumPassedTestOutputSize); - cmCTest::PopulateCustomInteger(mf, + this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE", this->CustomMaximumFailedTestOutputSize); } diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 94a79b906..2e523fe39 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -19,55 +19,20 @@ #include "cmCTest.h" #include "cmCTestGenericHandler.h" -bool cmCTestUpdateCommand::InitialPass( - std::vector const& args) +cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() { - const char* source_dir = 0; - const char* res_var = 0; - - bool havereturn_variable = false; - bool havesource = false; - for(size_t i=0; i < args.size(); ++i) + if ( this->Values[ct_SOURCE] ) { - if ( havereturn_variable ) - { - res_var = args[i].c_str(); - havereturn_variable = false; - } - else if ( havesource ) - { - source_dir = args[i].c_str(); - havesource = false; - } - else if(args[i] == "RETURN_VALUE") - { - if ( res_var ) - { - this->SetError("called with incorrect number of arguments. " - "RETURN_VALUE specified twice."); - return false; - } - havereturn_variable = true; - } - else if(args[i] == "SOURCE") - { - if ( source_dir ) - { - this->SetError("called with incorrect number of arguments. SOURCE " - "specified twice."); - return false; - } - havesource = true; - } - else - { - cmOStringStream str; - str << "called with incorrect number of arguments. Extra argument is: " - << args[i].c_str() << "."; - this->SetError(str.str().c_str()); - return false; - } + this->CTest->SetCTestConfiguration("SourceDirectory", + this->Values[ct_SOURCE]); } + else + { + this->CTest->SetCTestConfiguration("SourceDirectory", + this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")); + } + std::string source_dir + = this->CTest->GetCTestConfiguration("SourceDirectory"); this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND"); @@ -97,22 +62,23 @@ bool cmCTestUpdateCommand::InitialPass( return false; } handler->SetCommand(this); - if ( !source_dir ) + if ( source_dir.empty() ) { this->SetError("source directory not specified. Please use SOURCE tag"); return false; } + handler->SetOption("SourceDirectory", source_dir.c_str()); if ( initialCheckoutCommand ) { handler->SetOption("InitialCheckout", initialCheckoutCommand); } - if ( (!cmSystemTools::FileExists(source_dir) || - !cmSystemTools::FileIsDirectory(source_dir)) + if ( (!cmSystemTools::FileExists(source_dir.c_str()) || + !cmSystemTools::FileIsDirectory(source_dir.c_str())) && !initialCheckoutCommand ) { cmOStringStream str; - str << "cannot find source directory: " << source_dir << "."; - if ( !cmSystemTools::FileExists(source_dir) ) + str << "cannot find source directory: " << source_dir.c_str() << "."; + if ( !cmSystemTools::FileExists(source_dir.c_str()) ) { str << " Looks like it is not checked out yet. Please specify " "CTEST_CHECKOUT_COMMAND."; @@ -120,15 +86,7 @@ bool cmCTestUpdateCommand::InitialPass( this->SetError(str.str().c_str()); return false; } - handler->SetOption("SourceDirectory", source_dir); - int res = handler->ProcessHandler(); - if ( res_var ) - { - cmOStringStream str; - str << res; - this->Makefile->AddDefinition(res_var, str.str().c_str()); - } - return true; + return handler; } diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index cad95c4d6..a93b05acd 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -17,14 +17,14 @@ #ifndef cmCTestUpdateCommand_h #define cmCTestUpdateCommand_h -#include "cmCTestCommand.h" +#include "cmCTestHandlerCommand.h" /** \class cmCTestUpdate * \brief Run a ctest script * * cmCTestUpdateCommand defineds the command to updates the repository. */ -class cmCTestUpdateCommand : public cmCTestCommand +class cmCTestUpdateCommand : public cmCTestHandlerCommand { public: @@ -41,12 +41,6 @@ public: 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. */ @@ -72,8 +66,10 @@ public: "modified. If there is a problem, the variable will be -1."; } - cmTypeMacro(cmCTestUpdateCommand, cmCTestCommand); + cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand); +protected: + cmCTestGenericHandler* InitializeHandler(); }; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index e0779841f..f84430cb1 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1322,6 +1322,7 @@ int cmCTest::Run(std::vectorconst& args, std::string* output) if(this->CheckArgument(arg, "--debug")) { this->Debug = true; + this->ShowLineNumbers = true; } if(this->CheckArgument(arg, "--show-line-numbers")) { @@ -1948,12 +1949,14 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, { return; } + cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl); std::vector slist; cmSystemTools::ExpandListArgument(dval, slist); std::vector::iterator it; for ( it = slist.begin(); it != slist.end(); ++it ) { + cmCTestLog(this, DEBUG, " -- " << it->c_str() << std::endl); vec.push_back(it->c_str()); } } diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 4f0641ba6..f94cb1f51 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -129,9 +129,9 @@ public: //! Set the notes files to be created. void SetNotesFiles(const char* notes); - static void PopulateCustomVector(cmMakefile* mf, const char* definition, - VectorOfStrings& vec); - static void PopulateCustomInteger(cmMakefile* mf, const char* def, + void PopulateCustomVector(cmMakefile* mf, const char* definition, + VectorOfStrings& vec); + void PopulateCustomInteger(cmMakefile* mf, const char* def, int& val); ///! Get the current time as string diff --git a/Tests/CTestTest3/test.cmake.in b/Tests/CTestTest3/test.cmake.in index 35105003f..0be92483f 100644 --- a/Tests/CTestTest3/test.cmake.in +++ b/Tests/CTestTest3/test.cmake.in @@ -43,6 +43,8 @@ CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ CTEST_TEST_KWSYS:BOOL=ON ") +SET(CTEST_CUSTOM_WARNING_MATCH CommandLineArguments) + CTEST_START(Nightly) CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)