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
This commit is contained in:
Andy Cedilnik 2005-06-16 13:18:21 -04:00
parent b156314ab3
commit 2cc5ed49d1
12 changed files with 272 additions and 102 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -39,7 +39,6 @@ public:
cmCTestScriptHandler *m_CTestScriptHandler;
cmTypeMacro(cmCTestCommand, cmCommand);
};

View File

@ -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

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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 )
{
handler->SetOption("SourceDirectory", source_dir);
this->SetError("source directory not specified. Please use SOURCE tag");
return false;
}
if ( initialCheckoutCommand )
{
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 )
{

View File

@ -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;

View File

@ -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;
}
return 1;
}
//----------------------------------------------------------------------
bool cmCTest::InitializeFromCommand(cmCTestCommand* command, bool first)
{
if ( !first && !m_CurrentTag.empty() )
{
return true;
}
const char* src_dir = this->GetCTestConfiguration("SourceDirectory").c_str();
const char* bld_dir = this->GetCTestConfiguration("BuildDirectory").c_str();
cmMakefile* mf = command->GetMakefile();
std::string fname = src_dir;
fname += "/CTestConfig.cmake";
cmSystemTools::ConvertToUnixSlashes(fname);
if ( cmSystemTools::FileExists(fname.c_str()) )
{
cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " << fname.c_str() << std::endl);
bool readit = mf->ReadListFile(mf->GetCurrentListFile(),
fname.c_str() );
if(!readit)
{
std::string m = "Could not find include file: ";
m += fname;
command->SetError(m.c_str());
return false;
}
}
else if ( !first )
{
cmCTestLog(this, WARNING, "Cannot locate CTest configuration: " << fname.c_str() << std::endl);
}
else
{
cmCTestLog(this, HANDLER_OUTPUT, " Cannot locate CTest configuration: " << fname.c_str() << std::endl
<< " Delay the initialization of CTest" << std::endl);
}
this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME");
this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE");
this->SetCTestConfigurationFromCMakeVariable(mf, "BuildName", "CTEST_BUILD_NAME");
if ( !this->Initialize(bld_dir, true, false) )
{
if ( this->GetCTestConfiguration("NightlyStartTime").empty() && first)
{
return true;
}
return false;
}
cmCTestLog(this, OUTPUT, " Use " << this->GetTestModelString() << " tag: " << this->GetCurrentTag() << std::endl);
return true;
}
//----------------------------------------------------------------------
bool cmCTest::UpdateCTestConfiguration()
{
@ -1101,6 +1175,10 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output)
{
this->m_Debug = true;
}
if( arg.find("--show-line-numbers",0) == 0 )
{
this->m_ShowLineNumbers = true;
}
if( arg.find("-Q",0) == 0 || arg.find("--quiet",0) == 0 )
{
this->m_Quiet = true;
@ -1842,7 +1920,7 @@ bool cmCTest::RunCommand(
default:
done = true;
}
if(m_ExtraVerbose)
if ( (res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) && m_ExtraVerbose )
{
cmSystemTools::Stdout(data, length);
}
@ -1927,7 +2005,13 @@ static const char* cmCTestStringLogType[] =
# undef cout
#endif
void cmCTest::Log(int logType, const char* msg)
#define cmCTestLogOutputFileLine(stream) \
if ( m_ShowLineNumbers ) \
{ \
(stream) << std::endl << file << ":" << line << " "; \
}
void cmCTest::Log(int logType, const char* file, int line, const char* msg)
{
if ( !msg || !*msg )
{
@ -1940,6 +2024,7 @@ void cmCTest::Log(int logType, const char* msg)
if ( logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !m_Debug && !m_ExtraVerbose ) { display = false; }
if ( display )
{
cmCTestLogOutputFileLine(*m_OutputLogFile);
if ( logType != m_OutputLogFileLastTag )
{
*m_OutputLogFile << "[";
@ -1968,6 +2053,7 @@ void cmCTest::Log(int logType, const char* msg)
case DEBUG:
if ( m_Debug )
{
cmCTestLogOutputFileLine(std::cout);
std::cout << msg;
std::cout.flush();
}
@ -1975,6 +2061,7 @@ void cmCTest::Log(int logType, const char* msg)
case OUTPUT: case HANDLER_OUTPUT:
if ( m_Debug || m_Verbose )
{
cmCTestLogOutputFileLine(std::cout);
std::cout << msg;
std::cout.flush();
}
@ -1982,19 +2069,23 @@ void cmCTest::Log(int logType, const char* msg)
case HANDLER_VERBOSE_OUTPUT:
if ( m_Debug || m_ExtraVerbose )
{
cmCTestLogOutputFileLine(std::cout);
std::cout << msg;
std::cout.flush();
}
break;
case WARNING:
cmCTestLogOutputFileLine(std::cerr);
std::cerr << msg;
std::cerr.flush();
break;
case ERROR_MESSAGE:
cmCTestLogOutputFileLine(std::cerr);
std::cerr << msg;
std::cerr.flush();
break;
default:
cmCTestLogOutputFileLine(std::cout);
std::cout << msg;
std::cout.flush();
}

View File

@ -26,12 +26,13 @@ class cmake;
class cmMakefile;
class cmCTestGenericHandler;
class cmGeneratedFileStream;
class cmCTestCommand;
#define cmCTestLog(ctSelf, logType, msg) \
do { \
cmOStringStream cmCTestLog_msg; \
cmCTestLog_msg << msg; \
(ctSelf)->Log(cmCTest::logType, cmCTestLog_msg.str().c_str());\
(ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__, cmCTestLog_msg.str().c_str());\
} while ( 0 )
#ifdef cerr
@ -55,7 +56,8 @@ public:
/**
* Initialize and finalize testing
*/
int Initialize(const char* binary_dir, bool new_tag = false);
int Initialize(const char* binary_dir, bool new_tag = false, bool verbose_tag = true);
bool InitializeFromCommand(cmCTestCommand* command, bool first = false);
void Finalize();
/**
@ -262,7 +264,7 @@ public:
};
//! Add log to the output
void Log(int logType, const char* msg);
void Log(int logType, const char* file, int line, const char* msg);
private:
std::string m_ConfigType;
@ -344,6 +346,7 @@ private:
bool m_SuppressUpdatingCTestConfiguration;
bool m_Debug;
bool m_ShowLineNumbers;
bool m_Quiet;

View File

@ -7,7 +7,7 @@ SET(CTEST_BUILD_NAME "KWSys-@BUILDNAME@-CTest2")
SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Source/kwsys")
SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTest2/kwsysBin")
SET(CTEST_CVS_COMMAND "@CVS@")
SET(CTEST_CVS_COMMAND "@CVSCOMMAND@")
SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
SET(CTEST_BUILD_CONFIGURATION "Release")
SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@")