Commit 2cc5ed49 authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

ENH: Several improvements to CTest:

1. Support for showing line numbers when debugging ctest --show-line-numbers
2. Modify the ctest initialization code, so that it can be delayed
3. Handlers now have corresponding command if they were invoked from the command (so far only update actually use that)
4. Start command is simplified and the functionality is moved to CTest
5. Update can perform initial checkout if CTEST_CHECKOUT_COMMAND is set
6. Add test that checks out kwsys and perform tests on the fresh checkout
parent b156314a
......@@ -802,7 +802,13 @@ IF(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
ADD_TEST(CTestTest2 ${CMAKE_CTEST_COMMAND}
-S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
)
CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest3/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTest3/test.cmake" @ONLY ESCAPE_QUOTES)
ADD_TEST(CTestTest3 ${CMAKE_CTEST_COMMAND}
-S "${CMake_BINARY_DIR}/Tests/CTestTest3/test.cmake" -V
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest3/testOutput.log"
)
ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS)
......
......@@ -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;
}
......
......@@ -39,7 +39,6 @@ public:
cmCTestScriptHandler *m_CTestScriptHandler;
cmTypeMacro(cmCTestCommand, cmCommand);
};
......
......@@ -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
......
......@@ -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);
}
......@@ -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);
......
......@@ -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;
......
......@@ -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 )
{
......
......@@ -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;
......
......@@ -25,6 +25,7 @@
#include "cmGlob.h"
#include "cmDynamicLoader.h"
#include "cmGeneratedFileStream.h"
#include "cmCTestCommand.h"
#include "cmCTestBuildHandler.h"
#include "cmCTestBuildAndTestHandler.h"
......@@ -213,6 +214,7 @@ cmCTest::cmCTest()
m_TomorrowTag = false;
m_Verbose = false;
m_Debug = false;
m_ShowLineNumbers = false;
m_Quiet = false;
m_ExtraVerbose = false;
m_ProduceXML = false;
......@@ -264,7 +266,7 @@ cmCTest::~cmCTest()
}
//----------------------------------------------------------------------
int cmCTest::Initialize(const char* binary_dir, bool new_tag)
int cmCTest::Initialize(const char* binary_dir, bool new_tag, bool verbose_tag)
{
if(!m_InteractiveDebugMode)
{
......@@ -273,11 +275,25 @@ int cmCTest::Initialize(const char* binary_dir, bool new_tag)
m_BinaryDir = binary_dir;
cmSystemTools::ConvertToUnixSlashes(m_BinaryDir);
this->UpdateCTestConfiguration();
if ( m_ProduceXML )
{
cmCTestLog(this, DEBUG, "Produce XML is on" << std::endl);
if ( this->GetCTestConfiguration("NightlyStartTime").empty() )
{
cmCTestLog(this, DEBUG, "No nightly start time" << std::endl);
return 0;
}
}
if ( !this->ReadCustomConfigurationFileTree(m_BinaryDir.c_str()) )
{
cmCTestLog(this, DEBUG, "Cannot find custom configuration file tree" << std::endl);
return 0;
}
this->UpdateCTestConfiguration();
if ( m_ProduceXML )
{
std::string testingDir = m_BinaryDir + "/Testing";
......@@ -356,14 +372,72 @@ int cmCTest::Initialize(const char* binary_dir, bool new_tag)
ofs << this->GetTestModelString() << std::endl;
}
ofs.close();
cmCTestLog(this, OUTPUT, "Create new tag: " << tag << " - "
<< this->GetTestModelString() << std::endl);
if ( verbose_tag )
{
cmCTestLog(this, OUTPUT, "Create new tag: " << tag << " - "
<< this->GetTestModelString() << std::endl);
}
}
m_CurrentTag = tag;