diff options
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestBuildCommand.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestCommand.h | 1 | ||||
-rw-r--r-- | Source/CTest/cmCTestGenericHandler.h | 8 | ||||
-rw-r--r-- | Source/CTest/cmCTestStartCommand.cxx | 34 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitCommand.cxx | 1 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 116 | ||||
-rw-r--r-- | Source/CTest/cmCTestUpdateCommand.cxx | 29 | ||||
-rw-r--r-- | Source/CTest/cmCTestUpdateHandler.cxx | 61 |
8 files changed, 161 insertions, 91 deletions
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 4812152..79c4e3c 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -138,7 +138,7 @@ bool cmCTestBuildCommand::InitialPass( else { cmOStringStream ostr; - ostr << "CTEST_BUILD_COMMAND or CTEST_CMAKE_GENERATOR not specified. Please specify the CTEST_CMAKE_GENERATOR if this is a CMake project, or specify the CTEST_BUILD_COMMAND for cmake or any other project."; + ostr << "CTEST_BUILD_COMMAND or CTEST_CMAKE_GENERATOR not specified. Please specify the CTEST_CMAKE_GENERATOR and CTEST_PROJECT_NAME if this is a CMake project, or specify the CTEST_BUILD_COMMAND for cmake or any other project."; this->SetError(ostr.str().c_str()); return false; } diff --git a/Source/CTest/cmCTestCommand.h b/Source/CTest/cmCTestCommand.h index 9d4b7a8..418b5af 100644 --- a/Source/CTest/cmCTestCommand.h +++ b/Source/CTest/cmCTestCommand.h @@ -39,7 +39,6 @@ public: cmCTestScriptHandler *m_CTestScriptHandler; cmTypeMacro(cmCTestCommand, cmCommand); - }; diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index ca658b6..dccb70f 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -23,6 +23,7 @@ class cmCTest; class cmMakefile; +class cmCTestCommand; /** \class cmCTestGenericHandler * \brief A superclass of all CTest Handlers @@ -71,10 +72,17 @@ public: void SetOption(const char* op, const char* value); const char* GetOption(const char* op); + void SetCommand(cmCTestCommand* command) + { + m_Command = command; + } + protected: bool m_HandlerVerbose; cmCTest *m_CTest; t_StringToString m_Options; + + cmCTestCommand* m_Command; }; #endif diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 096be9e..d3d3648 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -64,43 +64,19 @@ bool cmCTestStartCommand::InitialPass( this->SetError("binary directory not specified. Specify binary directory as an argument or set CTEST_BINARY_DIRECTORY"); return false; } - cmCTestLog(m_CTest, OUTPUT, "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()) ) - { - cmCTestLog(m_CTest, OUTPUT, " 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->SetCTestConfigurationFromCMakeVariable(m_Makefile, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "Site", "CTEST_SITE"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "BuildName", "CTEST_BUILD_NAME"); m_CTest->SetCTestConfiguration("SourceDirectory", src_dir); m_CTest->SetCTestConfiguration("BuildDirectory", bld_dir); + cmCTestLog(m_CTest, OUTPUT, "Run dashboard with model " << smodel << std::endl + << " Source directory: " << src_dir << std::endl << " Build directory: " << bld_dir << std::endl); + m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF"); m_CTest->SetSuppressUpdatingCTestConfiguration(true); - int model = m_CTest->GetTestModelFromString(smodel); m_CTest->SetTestModel(model); m_CTest->SetProduceXML(true); - if ( !m_CTest->Initialize(bld_dir, true) ) - { - return false; - } - return true; + + return m_CTest->InitializeFromCommand(this, true); } diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index cc4abf5..f744947 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -70,6 +70,7 @@ bool cmCTestSubmitCommand::InitialPass( if ( !ctestTriggerSite ) { ctestTriggerSite = "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi"; + cmCTestLog(m_CTest, HANDLER_OUTPUT, "* Use default trigger site: " << ctestTriggerSite << std::endl;); } m_CTest->SetCTestConfiguration("DropMethod", ctestDropMethod); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 83127a7..930da22 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -120,7 +120,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, ftpfile = ::fopen(local_file.c_str(), "rb"); *m_LogFile << "\tUpload file: " << local_file.c_str() << " to " << upload_as.c_str() << std::endl; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " << upload_as.c_str() << std::endl); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); @@ -158,11 +158,11 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, fclose(ftpfile); if ( res ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl - << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); + *m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl + << " Error message was: " << error_buffer << std::endl + << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); ::curl_easy_cleanup(curl); @@ -171,7 +171,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, } // always cleanup ::curl_easy_cleanup(curl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file << std::endl); } } ::curl_global_cleanup(); @@ -270,7 +270,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, } ftpfile = ::fopen(local_file.c_str(), "rb"); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " << upload_as.c_str() << " Size: " << st.st_size << std::endl); @@ -307,11 +307,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, fclose(ftpfile); if ( res ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl - << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); + *m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl + << " Error message was: " << error_buffer << std::endl + << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); ::curl_easy_cleanup(curl); @@ -320,7 +320,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, } // always cleanup ::curl_easy_cleanup(curl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file << std::endl); } } ::curl_global_cleanup(); @@ -410,15 +410,15 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::vector<cmStdString>& file = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + "xmlfile=" + ofile; *m_LogFile << "Trigger url: " << turl.c_str() << std::endl; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " << turl.c_str() << std::endl); + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " << turl.c_str() << std::endl); curl_easy_setopt(curl, CURLOPT_URL, turl.c_str()); if ( curl_easy_perform(curl) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when triggering: " << turl.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when triggering: " << turl.c_str() << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *m_LogFile << "\tTrigerring failed with error: " << error_buffer << std::endl - << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + << " Error message was: " << error_buffer << std::endl + << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); ::curl_easy_cleanup(curl); @@ -437,7 +437,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::vector<cmStdString>& file } } ::curl_global_cleanup(); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Dart server triggered..." << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Dart server triggered..." << std::endl); return true; } @@ -553,14 +553,14 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, xmlrpc_env_init(&env); /* Call the famous server at UserLand. */ - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submitting to: " << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submitting to: " << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl); std::vector<cmStdString>::const_iterator it; for ( it = files.begin(); it != files.end(); ++it ) { xmlrpc_value *result; std::string local_file = localprefix + "/" + *it; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submit file: " << local_file.c_str() << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submit file: " << local_file.c_str() << std::endl); struct stat st; if ( ::stat(local_file.c_str(), &st) ) { @@ -687,11 +687,11 @@ int cmCTestSubmitHandler::ProcessHandler() if ( m_HTTPProxy.size() > 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use HTTP Proxy: " << m_HTTPProxy << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use HTTP Proxy: " << m_HTTPProxy << std::endl); } if ( m_FTPProxy.size() > 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use FTP Proxy: " << m_FTPProxy << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use FTP Proxy: " << m_FTPProxy << std::endl); } cmGeneratedFileStream ofs; m_CTest->OpenOutputFile("Temporary", "LastSubmit.log", ofs); @@ -748,74 +748,96 @@ int cmCTestSubmitHandler::ProcessHandler() m_CTest->GetCTestConfiguration("DropMethod") == "ftp" ) { ofs << "Using drop method: FTP" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using FTP submit method" << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using FTP submit method" << std::endl + << " Drop site: ftp://"); std::string url = "ftp://"; url += cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropSiteUser")) + ":" + cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropSitePassword")) + "@" + m_CTest->GetCTestConfiguration("DropSite") + cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropLocation")); + if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) + { + cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); + if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) + { + cmCTestLog(m_CTest, HANDLER_OUTPUT, ":******"); + } + cmCTestLog(m_CTest, HANDLER_OUTPUT, "@"); + } + cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSite") + << m_CTest->GetCTestConfiguration("DropLocation") << std::endl); if ( !this->SubmitUsingFTP(buildDirectory+"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via FTP" << std::endl); - ofs << " Problems when submitting via FTP" << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via FTP" << std::endl); + ofs << " Problems when submitting via FTP" << std::endl; return -1; } + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" << std::endl + << " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") << std::endl); if ( !this->TriggerUsingHTTP(files, prefix, m_CTest->GetCTestConfiguration("TriggerSite")) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when triggering via HTTP" << std::endl); - ofs << " Problems when triggering via HTTP" << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when triggering via HTTP" << std::endl); + ofs << " Problems when triggering via HTTP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); - ofs << " Submission successful" << std::endl; + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + ofs << " Submission successful" << std::endl; return 0; } else if ( m_CTest->GetCTestConfiguration("DropMethod") == "http" ) { ofs << "Using drop method: HTTP" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP submit method" << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP submit method" << std::endl + << " Drop site: http://"); std::string url = "http://"; if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) { url += m_CTest->GetCTestConfiguration("DropSiteUser"); + cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) { url += ":" + m_CTest->GetCTestConfiguration("DropSitePassword"); + cmCTestLog(m_CTest, HANDLER_OUTPUT, ":******"); } url += "@"; + cmCTestLog(m_CTest, HANDLER_OUTPUT, "@"); } url += m_CTest->GetCTestConfiguration("DropSite") + m_CTest->GetCTestConfiguration("DropLocation"); + cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSite") + << m_CTest->GetCTestConfiguration("DropLocation") << std::endl); if ( !this->SubmitUsingHTTP(buildDirectory +"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via HTTP" << std::endl); - ofs << " Problems when submitting via HTTP" << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via HTTP" << std::endl); + ofs << " Problems when submitting via HTTP" << std::endl; return -1; } + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" << std::endl + << " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") << std::endl); if ( !this->TriggerUsingHTTP(files, prefix, m_CTest->GetCTestConfiguration("TriggerSite")) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when triggering via HTTP" << std::endl); - ofs << " Problems when triggering via HTTP" << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when triggering via HTTP" << std::endl); + ofs << " Problems when triggering via HTTP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); - ofs << " Submission successful" << std::endl; + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + ofs << " Submission successful" << std::endl; return 0; } else if ( m_CTest->GetCTestConfiguration("DropMethod") == "xmlrpc" ) { ofs << "Using drop method: XML-RPC" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using XML-RPC submit method" << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using XML-RPC submit method" << std::endl); std::string url = m_CTest->GetCTestConfiguration("DropSite"); prefix = m_CTest->GetCTestConfiguration("DropLocation"); if ( !this->SubmitUsingXMLRPC(buildDirectory+"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via XML-RPC" << std::endl); - ofs << " Problems when submitting via XML-RPC" << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via XML-RPC" << std::endl); + ofs << " Problems when submitting via XML-RPC" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); - ofs << " Submission successful" << std::endl; + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + ofs << " Submission successful" << std::endl; return 0; } else if ( m_CTest->GetCTestConfiguration("DropMethod") == "scp" ) @@ -830,12 +852,12 @@ int cmCTestSubmitHandler::ProcessHandler() if ( !this->SubmitUsingSCP(m_CTest->GetCTestConfiguration("ScpCommand"), buildDirectory+"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via SCP" << std::endl); - ofs << " Problems when submitting via SCP" << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when submitting via SCP" << std::endl); + ofs << " Problems when submitting via SCP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); - ofs << " Submission successful" << std::endl; + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + ofs << " Submission successful" << std::endl; } cmCTestLog(m_CTest, ERROR_MESSAGE, " Unknown submission method: \"" << m_CTest->GetCTestConfiguration("DropMethod") << "\"" << std::endl); return -1; diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index c0e00ae..15b9e90 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -69,16 +69,41 @@ bool cmCTestUpdateCommand::InitialPass( m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "CVSCommand", "CTEST_CVS_COMMAND"); m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "SVNCommand", "CTEST_SVN_COMMAND"); + const char* initialCheckoutCommand = m_Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND"); + if ( !initialCheckoutCommand ) + { + initialCheckoutCommand = m_Makefile->GetDefinition("CTEST_CVS_CHECKOUT"); + } + cmCTestGenericHandler* handler = m_CTest->GetHandler("update"); if ( !handler ) { this->SetError("internal CTest error. Cannot instantiate update handler"); return false; } - if ( source_dir ) + handler->SetCommand(this); + if ( !source_dir ) + { + this->SetError("source directory not specified. Please use SOURCE tag"); + return false; + } + if ( initialCheckoutCommand ) { - handler->SetOption("SourceDirectory", source_dir); + handler->SetOption("InitialCheckout", initialCheckoutCommand); + } + if ( (!cmSystemTools::FileExists(source_dir) || !cmSystemTools::FileIsDirectory(source_dir)) + && !initialCheckoutCommand ) + { + cmOStringStream str; + str << "cannot find source directory: " << source_dir << "."; + if ( !cmSystemTools::FileExists(source_dir) ) + { + str << " Looks like it is not checked out yet. Please specify CTEST_CHECKOUT_COMMAND."; + } + this->SetError(str.str().c_str()); + return false; } + handler->SetOption("SourceDirectory", source_dir); int res = handler->ProcessHandler(); if ( res_var ) { diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 8b34ecb..4758436 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -198,7 +198,11 @@ int cmCTestUpdateHandler::ProcessHandler() int updateType = e_CVS; std::string::size_type cc, kk; bool updateProducedError = false; + std::string goutput; + std::string errors; + std::string checkoutErrorMessages; + int retVal = 0; // Get source dir const char* sourceDirectory = this->GetOption("SourceDirectory"); @@ -208,7 +212,50 @@ int cmCTestUpdateHandler::ProcessHandler() return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, "Updating the repository: " << sourceDirectory << std::endl); + cmGeneratedFileStream ofs; + if ( !m_CTest->GetShowOnly() ) + { + m_CTest->OpenOutputFile("Temporary", "LastUpdate.log", ofs); + } + + cmCTestLog(m_CTest, HANDLER_OUTPUT, "Updating the repository" << std::endl); + + const char* initialCheckoutCommand = this->GetOption("InitialCheckout"); + if ( initialCheckoutCommand ) + { + cmCTestLog(m_CTest, HANDLER_OUTPUT, " First perform the initil checkout: " << initialCheckoutCommand << std::endl); + cmStdString parent = cmSystemTools::GetParentDirectory(sourceDirectory); + if ( parent.empty() ) + { + cmCTestLog(m_CTest, ERROR_MESSAGE, + "Something went wrong when trying to determine the parent directory of " << sourceDirectory << std::endl); + return -1; + } + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Perform checkout in directory: " << parent.c_str() << std::endl); + if ( !cmSystemTools::MakeDirectory(parent.c_str()) ) + { + cmCTestLog(m_CTest, ERROR_MESSAGE, + "Cannot create parent directory: " << parent.c_str() << " of the source directory: " << sourceDirectory << std::endl); + return -1; + } + ofs << "* Run initial checkout" << std::endl; + ofs << " Command: " << initialCheckoutCommand << std::endl; + cmCTestLog(m_CTest, DEBUG, " Before: " << initialCheckoutCommand << std::endl); + bool retic = m_CTest->RunCommand(initialCheckoutCommand, &goutput, &errors, &retVal, parent.c_str(), 0 /* Timeout */); + cmCTestLog(m_CTest, DEBUG, " After: " << initialCheckoutCommand << std::endl); + ofs << " Output: " << goutput.c_str() << std::endl; + ofs << " Errors: " << errors.c_str() << std::endl; + if ( !retic || retVal ) + { + cmOStringStream ostr; + ostr << "Problem running initial checkout Output [" << goutput << "] Errors [" << errors << "]"; + cmCTestLog(m_CTest, HANDLER_OUTPUT, ostr.str().c_str() << std::endl); + checkoutErrorMessages += ostr.str(); + updateProducedError = true; + } + m_CTest->InitializeFromCommand(m_Command); + } + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Updating the repository: " << sourceDirectory << std::endl); // Get update command std::string updateCommand = m_CTest->GetCTestConfiguration("UpdateCommand"); @@ -295,21 +342,12 @@ int cmCTestUpdateHandler::ProcessHandler() break; } - cmGeneratedFileStream ofs; - if ( !m_CTest->GetShowOnly() ) - { - m_CTest->OpenOutputFile("Temporary", "LastUpdate.log", ofs); - } - // CVS variables // SVN variables int svn_current_revision = 0; int svn_latest_revision = 0; int svn_use_status = 0; - std::string goutput; - std::string errors; - int retVal = 0; bool res = true; @@ -416,6 +454,7 @@ int cmCTestUpdateHandler::ProcessHandler() if ( !res || retVal ) { updateProducedError = true; + checkoutErrorMessages += " " + goutput; } os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" @@ -833,7 +872,7 @@ int cmCTestUpdateHandler::ProcessHandler() if ( updateProducedError ) { os << "Update error: "; - os << m_CTest->MakeXMLSafe(goutput); + os << m_CTest->MakeXMLSafe(checkoutErrorMessages); cmCTestLog(m_CTest, ERROR_MESSAGE, " Update with command: " << command << " failed" << std::endl); } os << "</UpdateReturnStatus>" << std::endl; |