STYLE: Fix some style issues

This commit is contained in:
Andy Cedilnik 2006-03-09 11:17:10 -05:00
parent 10d1b20790
commit 6503a0eecc
32 changed files with 1500 additions and 937 deletions

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -55,9 +55,9 @@ int cmCTestBuildAndTestHandler::ProcessHandler()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, cmOStringStream &out, int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
std::string &cmakeOutString, std::string &cwd, cmOStringStream &out, std::string &cmakeOutString, std::string &cwd,
cmake *cm) cmake *cm)
{ {
unsigned int k; unsigned int k;
std::vector<std::string> args; std::vector<std::string> args;
@ -71,7 +71,8 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, cmOStringStream
} }
if ( m_CTest->GetConfigType().size() > 0 ) if ( m_CTest->GetConfigType().size() > 0 )
{ {
std::string btype = "-DCMAKE_BUILD_TYPE:STRING=" + m_CTest->GetConfigType(); std::string btype
= "-DCMAKE_BUILD_TYPE:STRING=" + m_CTest->GetConfigType();
args.push_back(btype); args.push_back(btype);
} }
@ -114,7 +115,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, cmOStringStream
} }
return 1; return 1;
} }
} }
return 0; return 0;
} }
@ -135,7 +136,7 @@ void CMakeStdoutCallback(const char* m, int len, void* s)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
{ {
unsigned int k; unsigned int k;
std::string cmakeOutString; std::string cmakeOutString;
cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString); cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString);
@ -143,23 +144,23 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cmOStringStream out; cmOStringStream out;
// What is this? double timeout = m_CTest->GetTimeOut(); // What is this? double timeout = m_CTest->GetTimeOut();
int retVal = 0; int retVal = 0;
// if the generator and make program are not specified then it is an error // if the generator and make program are not specified then it is an error
if (!m_BuildGenerator.size() || !m_BuildMakeProgram.size()) if (!m_BuildGenerator.size() || !m_BuildMakeProgram.size())
{ {
if(outstring) if(outstring)
{ {
*outstring = *outstring =
"--build-and-test requires that both the generator and makeprogram " "--build-and-test requires that both the generator and makeprogram "
"be provided using the --build-generator and --build-makeprogram " "be provided using the --build-generator and --build-makeprogram "
"command line options. "; "command line options. ";
} }
return 1; return 1;
} }
// make sure the binary dir is there // make sure the binary dir is there
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
out << "Internal cmake changing into directory: " << m_BinaryDir << "\n"; out << "Internal cmake changing into directory: " << m_BinaryDir << "\n";
if (!cmSystemTools::FileIsDirectory(m_BinaryDir.c_str())) if (!cmSystemTools::FileIsDirectory(m_BinaryDir.c_str()))
{ {
cmSystemTools::MakeDirectory(m_BinaryDir.c_str()); cmSystemTools::MakeDirectory(m_BinaryDir.c_str());
@ -169,7 +170,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
// should we cmake? // should we cmake?
cmake cm; cmake cm;
cm.SetGlobalGenerator(cm.CreateGlobalGenerator(m_BuildGenerator.c_str())); cm.SetGlobalGenerator(cm.CreateGlobalGenerator(m_BuildGenerator.c_str()));
if(!m_BuildNoCMake) if(!m_BuildNoCMake)
{ {
// do the cmake step // do the cmake step
@ -210,20 +211,20 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
{ {
*outstring = out.str(); *outstring = out.str();
} }
// if not test was specified then we are done // if not test was specified then we are done
if (!m_TestCommand.size()) if (!m_TestCommand.size())
{ {
return 0; return 0;
} }
// now run the compiled test if we can find it // now run the compiled test if we can find it
std::vector<std::string> attempted; std::vector<std::string> attempted;
std::vector<std::string> failed; std::vector<std::string> failed;
std::string tempPath; std::string tempPath;
std::string filepath = std::string filepath =
cmSystemTools::GetFilenamePath(m_TestCommand); cmSystemTools::GetFilenamePath(m_TestCommand);
std::string filename = std::string filename =
cmSystemTools::GetFilenameName(m_TestCommand); cmSystemTools::GetFilenameName(m_TestCommand);
// if full path specified then search that first // if full path specified then search that first
if (filepath.size()) if (filepath.size())
@ -282,9 +283,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
// store the final location in fullPath // store the final location in fullPath
std::string fullPath; std::string fullPath;
// now look in the paths we specified above // now look in the paths we specified above
for(unsigned int ai=0; for(unsigned int ai=0;
ai < attempted.size() && fullPath.size() == 0; ++ai) ai < attempted.size() && fullPath.size() == 0; ++ai)
{ {
// first check without exe extension // first check without exe extension
@ -396,7 +397,8 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
} }
else else
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "--build-and-test must have source and binary dir" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"--build-and-test must have source and binary dir" << std::endl);
return 0; return 0;
} }
} }
@ -433,7 +435,8 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
idx++; idx++;
m_BuildProject = allArgs[idx]; m_BuildProject = allArgs[idx];
} }
if(currentArg.find("--build-makeprogram",0) == 0 && idx < allArgs.size() - 1) if(currentArg.find("--build-makeprogram",0) == 0 &&
idx < allArgs.size() - 1)
{ {
idx++; idx++;
m_BuildMakeProgram = allArgs[idx]; m_BuildMakeProgram = allArgs[idx];
@ -449,8 +452,9 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
while(idx < allArgs.size() && !done) while(idx < allArgs.size() && !done)
{ {
m_BuildOptions.push_back(allArgs[idx]); m_BuildOptions.push_back(allArgs[idx]);
if(idx+1 < allArgs.size() if(idx+1 < allArgs.size()
&& (allArgs[idx+1] == "--build-target" || allArgs[idx+1] == "--test-command")) && (allArgs[idx+1] == "--build-target" ||
allArgs[idx+1] == "--test-command"))
{ {
done = true; done = true;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -63,16 +63,18 @@ bool cmCTestBuildCommand::InitialPass(
{ {
if ( res_var ) if ( res_var )
{ {
this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); this->SetError("called with incorrect number of arguments. "
"RETURN_VALUE specified twice.");
return false; return false;
} }
havereturn_variable = true; havereturn_variable = true;
} }
else if(args[i] == "BUILD") else if(args[i] == "BUILD")
{ {
if ( build_dir ) if ( build_dir )
{ {
this->SetError("called with incorrect number of arguments. BUILD specified twice."); this->SetError("called with incorrect number of arguments. "
"BUILD specified twice.");
return false; return false;
} }
havesource = true; havesource = true;
@ -80,7 +82,8 @@ bool cmCTestBuildCommand::InitialPass(
else else
{ {
cmOStringStream str; cmOStringStream str;
str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; str << "called with incorrect number of arguments. Extra argument is: "
<< args[i].c_str() << ".";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }
@ -97,18 +100,23 @@ bool cmCTestBuildCommand::InitialPass(
this->SetError("internal CTest error. Cannot instantiate build handler"); this->SetError("internal CTest error. Cannot instantiate build handler");
return false; return false;
} }
const char* ctestBuildCommand = m_Makefile->GetDefinition("CTEST_BUILD_COMMAND"); const char* ctestBuildCommand
= m_Makefile->GetDefinition("CTEST_BUILD_COMMAND");
if ( ctestBuildCommand && *ctestBuildCommand ) if ( ctestBuildCommand && *ctestBuildCommand )
{ {
m_CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand); m_CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand);
} }
else else
{ {
const char* cmakeGeneratorName = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); const char* cmakeGeneratorName
const char* cmakeProjectName = m_Makefile->GetDefinition("CTEST_PROJECT_NAME"); = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
const char* cmakeBuildConfiguration = m_Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); const char* cmakeProjectName
const char* cmakeBuildAdditionalFlags = m_Makefile->GetDefinition("CTEST_BUILD_FLAGS"); = m_Makefile->GetDefinition("CTEST_PROJECT_NAME");
const char* cmakeBuildConfiguration
= m_Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
const char* cmakeBuildAdditionalFlags
= m_Makefile->GetDefinition("CTEST_BUILD_FLAGS");
if ( cmakeGeneratorName && *cmakeGeneratorName && if ( cmakeGeneratorName && *cmakeGeneratorName &&
cmakeProjectName && *cmakeProjectName ) cmakeProjectName && *cmakeProjectName )
{ {
@ -126,25 +134,31 @@ bool cmCTestBuildCommand::InitialPass(
} }
if ( !m_GlobalGenerator ) if ( !m_GlobalGenerator )
{ {
m_GlobalGenerator = m_GlobalGenerator =
m_Makefile->GetCMakeInstance()->CreateGlobalGenerator(cmakeGeneratorName); m_Makefile->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGeneratorName);
} }
m_GlobalGenerator->FindMakeProgram(m_Makefile); m_GlobalGenerator->FindMakeProgram(m_Makefile);
const char* cmakeMakeProgram = m_Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); const char* cmakeMakeProgram
= m_Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
std::string buildCommand std::string buildCommand
= m_GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram, cmakeProjectName, = m_GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram,
cmakeProjectName,
cmakeBuildAdditionalFlags, 0, cmakeBuildConfiguration, true); cmakeBuildAdditionalFlags, 0, cmakeBuildConfiguration, true);
m_CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str()); m_CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str());
} }
else else
{ {
cmOStringStream ostr; cmOStringStream ostr;
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."; 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()); this->SetError(ostr.str().c_str());
return false; return false;
} }
} }
int res = handler->ProcessHandler(); int res = handler->ProcessHandler();
if ( res_var ) if ( res_var )
{ {

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -32,7 +32,7 @@
#include "windows.h" #include "windows.h"
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
@ -125,9 +125,9 @@ static const char* cmCTestWarningMatches[] = {
}; };
static const char* cmCTestWarningExceptions[] = { static const char* cmCTestWarningExceptions[] = {
"/usr/openwin/include/X11/Xlib\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", "/usr/.*/X11/Xlib\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
"/usr/openwin/include/X11/Xutil\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", "/usr/.*/X11/Xutil\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
"/usr/openwin/include/X11/XResource\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", "/usr/.*/X11/XResource\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
"WARNING 84 :", "WARNING 84 :",
"WARNING 47 :", "WARNING 47 :",
"makefile:", "makefile:",
@ -220,19 +220,19 @@ void cmCTestBuildHandler::Initialize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf) void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf)
{ {
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH",
m_CustomErrorMatches); m_CustomErrorMatches);
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION",
m_CustomErrorExceptions); m_CustomErrorExceptions);
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH",
m_CustomWarningMatches); m_CustomWarningMatches);
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION",
m_CustomWarningExceptions); m_CustomWarningExceptions);
cmCTest::PopulateCustomInteger(mf, cmCTest::PopulateCustomInteger(mf,
"CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS",
m_MaxErrors); m_MaxErrors);
cmCTest::PopulateCustomInteger(mf, cmCTest::PopulateCustomInteger(mf,
"CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS",
m_MaxWarnings); m_MaxWarnings);
} }
@ -244,7 +244,9 @@ int cmCTestBuildHandler::ProcessHandler()
cmCTestLog(m_CTest, HANDLER_OUTPUT, "Build project" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, "Build project" << std::endl);
int entry; int entry;
for ( entry = 0; cmCTestWarningErrorFileLine[entry].m_RegularExpressionString; ++ entry ) for ( entry = 0;
cmCTestWarningErrorFileLine[entry].m_RegularExpressionString;
++ entry )
{ {
cmCTestBuildHandler::cmCTestCompileErrorWarningRex r; cmCTestBuildHandler::cmCTestCompileErrorWarningRex r;
if ( r.m_RegularExpression.compile( if ( r.m_RegularExpression.compile(
@ -256,22 +258,30 @@ int cmCTestBuildHandler::ProcessHandler()
} }
else else
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem Compiling regular expression: " cmCTestLog(m_CTest, ERROR_MESSAGE,
<< cmCTestWarningErrorFileLine[entry].m_RegularExpressionString << std::endl); "Problem Compiling regular expression: "
<< cmCTestWarningErrorFileLine[entry].m_RegularExpressionString
<< std::endl);
} }
} }
// Determine build command and build directory // Determine build command and build directory
const std::string &makeCommand = m_CTest->GetCTestConfiguration("MakeCommand"); const std::string &makeCommand
= m_CTest->GetCTestConfiguration("MakeCommand");
if ( makeCommand.size() == 0 ) if ( makeCommand.size() == 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find MakeCommand key in the DartConfiguration.tcl" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot find MakeCommand key in the DartConfiguration.tcl"
<< std::endl);
return -1; return -1;
} }
const std::string &buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); const std::string &buildDirectory
= m_CTest->GetCTestConfiguration("BuildDirectory");
if ( buildDirectory.size() == 0 ) if ( buildDirectory.size() == 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
<< std::endl);
return -1; return -1;
} }
@ -280,7 +290,8 @@ int cmCTestBuildHandler::ProcessHandler()
double elapsed_time_start = cmSystemTools::GetTime(); double elapsed_time_start = cmSystemTools::GetTime();
if ( !this->StartLogFile("Build", ofs) ) if ( !this->StartLogFile("Build", ofs) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create build log file" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create build log file"
<< std::endl);
} }
// Create lists of regular expression strings for errors, error exceptions, // Create lists of regular expression strings for errors, error exceptions,
@ -312,10 +323,14 @@ int cmCTestBuildHandler::ProcessHandler()
{ \ { \
regexes.push_back(it->c_str()); \ regexes.push_back(it->c_str()); \
} }
cmCTestBuildHandlerPopulateRegexVector(m_CustomErrorMatches, m_ErrorMatchRegex); cmCTestBuildHandlerPopulateRegexVector(
cmCTestBuildHandlerPopulateRegexVector(m_CustomErrorExceptions, m_ErrorExceptionRegex); m_CustomErrorMatches, m_ErrorMatchRegex);
cmCTestBuildHandlerPopulateRegexVector(m_CustomWarningMatches, m_WarningMatchRegex); cmCTestBuildHandlerPopulateRegexVector(
cmCTestBuildHandlerPopulateRegexVector(m_CustomWarningExceptions, m_WarningExceptionRegex); m_CustomErrorExceptions, m_ErrorExceptionRegex);
cmCTestBuildHandlerPopulateRegexVector(
m_CustomWarningMatches, m_WarningMatchRegex);
cmCTestBuildHandlerPopulateRegexVector(
m_CustomWarningExceptions, m_WarningExceptionRegex);
// Determine source and binary tree substitutions to simplify the output. // Determine source and binary tree substitutions to simplify the output.
@ -323,7 +338,8 @@ int cmCTestBuildHandler::ProcessHandler()
m_SimplifyBuildDir = ""; m_SimplifyBuildDir = "";
if ( m_CTest->GetCTestConfiguration("SourceDirectory").size() > 20 ) if ( m_CTest->GetCTestConfiguration("SourceDirectory").size() > 20 )
{ {
std::string srcdir = m_CTest->GetCTestConfiguration("SourceDirectory") + "/"; std::string srcdir
= m_CTest->GetCTestConfiguration("SourceDirectory") + "/";
std::string srcdirrep; std::string srcdirrep;
for ( cc = srcdir.size()-2; cc > 0; cc -- ) for ( cc = srcdir.size()-2; cc > 0; cc -- )
{ {
@ -339,7 +355,8 @@ int cmCTestBuildHandler::ProcessHandler()
} }
if ( m_CTest->GetCTestConfiguration("BuildDirectory").size() > 20 ) if ( m_CTest->GetCTestConfiguration("BuildDirectory").size() > 20 )
{ {
std::string bindir = m_CTest->GetCTestConfiguration("BuildDirectory") + "/"; std::string bindir
= m_CTest->GetCTestConfiguration("BuildDirectory") + "/";
std::string bindirrep; std::string bindirrep;
for ( cc = bindir.size()-2; cc > 0; cc -- ) for ( cc = bindir.size()-2; cc > 0; cc -- )
{ {
@ -356,18 +373,20 @@ int cmCTestBuildHandler::ProcessHandler()
// Ok, let's do the build // Ok, let's do the build
// Remember start build time // Remember start build time
m_StartBuild = m_CTest->CurrentTime(); m_StartBuild = m_CTest->CurrentTime();
int retVal = 0; int retVal = 0;
int res = cmsysProcess_State_Exited; int res = cmsysProcess_State_Exited;
if ( !m_CTest->GetShowOnly() ) if ( !m_CTest->GetShowOnly() )
{ {
res = this->RunMakeCommand(makeCommand.c_str(), &retVal, buildDirectory.c_str(), 0, ofs); res = this->RunMakeCommand(makeCommand.c_str(), &retVal,
buildDirectory.c_str(), 0, ofs);
} }
else else
{ {
cmCTestLog(m_CTest, DEBUG, "Build with command: " << makeCommand << std::endl); cmCTestLog(m_CTest, DEBUG, "Build with command: " << makeCommand
<< std::endl);
} }
// Remember end build time and calculate elapsed time // Remember end build time and calculate elapsed time
@ -375,28 +394,39 @@ int cmCTestBuildHandler::ProcessHandler()
double elapsed_build_time = cmSystemTools::GetTime() - elapsed_time_start; double elapsed_build_time = cmSystemTools::GetTime() - elapsed_time_start;
if (res != cmsysProcess_State_Exited || retVal ) if (res != cmsysProcess_State_Exited || retVal )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when building project" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when building project"
<< std::endl);
} }
// Cleanups strings in the errors and warnings list. // Cleanups strings in the errors and warnings list.
t_ErrorsAndWarningsVector::iterator evit; t_ErrorsAndWarningsVector::iterator evit;
if ( !m_SimplifySourceDir.empty() ) if ( !m_SimplifySourceDir.empty() )
{ {
for ( evit = m_ErrorsAndWarnings.begin(); evit != m_ErrorsAndWarnings.end(); ++ evit ) for ( evit = m_ErrorsAndWarnings.begin();
evit != m_ErrorsAndWarnings.end();
++ evit )
{ {
cmSystemTools::ReplaceString(evit->m_Text, m_SimplifySourceDir.c_str(), "/.../"); cmSystemTools::ReplaceString(
cmSystemTools::ReplaceString(evit->m_PreContext, m_SimplifySourceDir.c_str(), "/.../"); evit->m_Text, m_SimplifySourceDir.c_str(), "/.../");
cmSystemTools::ReplaceString(evit->m_PostContext, m_SimplifySourceDir.c_str(), "/.../"); cmSystemTools::ReplaceString(
evit->m_PreContext, m_SimplifySourceDir.c_str(), "/.../");
cmSystemTools::ReplaceString(
evit->m_PostContext, m_SimplifySourceDir.c_str(), "/.../");
} }
} }
if ( !m_SimplifyBuildDir.empty() ) if ( !m_SimplifyBuildDir.empty() )
{ {
for ( evit = m_ErrorsAndWarnings.begin(); evit != m_ErrorsAndWarnings.end(); ++ evit ) for ( evit = m_ErrorsAndWarnings.begin();
evit != m_ErrorsAndWarnings.end();
++ evit )
{ {
cmSystemTools::ReplaceString(evit->m_Text, m_SimplifyBuildDir.c_str(), "/.../"); cmSystemTools::ReplaceString(
cmSystemTools::ReplaceString(evit->m_PreContext, m_SimplifyBuildDir.c_str(), "/.../"); evit->m_Text, m_SimplifyBuildDir.c_str(), "/.../");
cmSystemTools::ReplaceString(evit->m_PostContext, m_SimplifyBuildDir.c_str(), "/.../"); cmSystemTools::ReplaceString(
evit->m_PreContext, m_SimplifyBuildDir.c_str(), "/.../");
cmSystemTools::ReplaceString(
evit->m_PostContext, m_SimplifyBuildDir.c_str(), "/.../");
} }
} }
@ -412,28 +442,30 @@ int cmCTestBuildHandler::ProcessHandler()
cmGeneratedFileStream xofs; cmGeneratedFileStream xofs;
if( !this->StartResultingXML("Build", xofs)) if( !this->StartResultingXML("Build", xofs))
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create build XML file" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create build XML file"
<< std::endl);
return -1; return -1;
} }
this->GenerateDartBuildOutput(xofs, m_ErrorsAndWarnings, elapsed_build_time); this->GenerateDartBuildOutput(
xofs, m_ErrorsAndWarnings, elapsed_build_time);
return 0; return 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestBuildHandler::GenerateDartBuildOutput( void cmCTestBuildHandler::GenerateDartBuildOutput(
std::ostream& os, std::ostream& os,
std::vector<cmCTestBuildErrorWarning> ew, std::vector<cmCTestBuildErrorWarning> ew,
double elapsed_build_time) double elapsed_build_time)
{ {
m_CTest->StartXML(os); m_CTest->StartXML(os);
os << "<Build>\n" os << "<Build>\n"
<< "\t<StartDateTime>" << m_StartBuild << "</StartDateTime>\n" << "\t<StartDateTime>" << m_StartBuild << "</StartDateTime>\n"
<< "<BuildCommand>" << "<BuildCommand>"
<< m_CTest->MakeXMLSafe(m_CTest->GetCTestConfiguration("MakeCommand")) << m_CTest->MakeXMLSafe(m_CTest->GetCTestConfiguration("MakeCommand"))
<< "</BuildCommand>" << std::endl; << "</BuildCommand>" << std::endl;
std::vector<cmCTestBuildErrorWarning>::iterator it; std::vector<cmCTestBuildErrorWarning>::iterator it;
// only report the first 50 warnings and first 50 errors // only report the first 50 warnings and first 50 errors
unsigned short numErrorsAllowed = m_MaxErrors; unsigned short numErrorsAllowed = m_MaxErrors;
unsigned short numWarningsAllowed = m_MaxWarnings; unsigned short numWarningsAllowed = m_MaxWarnings;
@ -442,7 +474,7 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
// via a call to collapse full path. // via a call to collapse full path.
srcdir = cmSystemTools::CollapseFullPath(srcdir.c_str()); srcdir = cmSystemTools::CollapseFullPath(srcdir.c_str());
srcdir += "/"; srcdir += "/";
for ( it = ew.begin(); for ( it = ew.begin();
it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ ) it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ )
{ {
cmCTestBuildErrorWarning *cm = &(*it); cmCTestBuildErrorWarning *cm = &(*it);
@ -459,7 +491,7 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
} }
os << "\t<" << (cm->m_Error ? "Error" : "Warning") << ">\n" os << "\t<" << (cm->m_Error ? "Error" : "Warning") << ">\n"
<< "\t\t<BuildLogLine>" << cm->m_LogLine << "</BuildLogLine>\n" << "\t\t<BuildLogLine>" << cm->m_LogLine << "</BuildLogLine>\n"
<< "\t\t<Text>" << m_CTest->MakeXMLSafe(cm->m_Text) << "\t\t<Text>" << m_CTest->MakeXMLSafe(cm->m_Text)
<< "\n</Text>" << std::endl; << "\n</Text>" << std::endl;
std::vector<cmCTestCompileErrorWarningRex>::iterator rit; std::vector<cmCTestCompileErrorWarningRex>::iterator rit;
for ( rit = m_ErrorWarningFileLineRegex.begin(); for ( rit = m_ErrorWarningFileLineRegex.begin();
@ -469,7 +501,7 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
if ( re->find(cm->m_Text.c_str() ) ) if ( re->find(cm->m_Text.c_str() ) )
{ {
cm->m_SourceFile = re->match(rit->m_FileIndex); cm->m_SourceFile = re->match(rit->m_FileIndex);
// At this point we need to make m_SourceFile relative to // At this point we need to make m_SourceFile relative to
// the source root of the project, so cvs links will work // the source root of the project, so cvs links will work
cmSystemTools::ConvertToUnixSlashes(cm->m_SourceFile); cmSystemTools::ConvertToUnixSlashes(cm->m_SourceFile);
if(cm->m_SourceFile.find("/.../") != cm->m_SourceFile.npos) if(cm->m_SourceFile.find("/.../") != cm->m_SourceFile.npos)
@ -478,14 +510,17 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
std::string::size_type p = cm->m_SourceFile.find("/"); std::string::size_type p = cm->m_SourceFile.find("/");
if(p != cm->m_SourceFile.npos) if(p != cm->m_SourceFile.npos)
{ {
cm->m_SourceFile = cm->m_SourceFile.substr(p+1, cm->m_SourceFile.size()-p); cm->m_SourceFile = cm->m_SourceFile.substr(
p+1, cm->m_SourceFile.size()-p);
} }
} }
else else
{ {
// make sure it is a full path with the correct case // make sure it is a full path with the correct case
cm->m_SourceFile = cmSystemTools::CollapseFullPath(cm->m_SourceFile.c_str()); cm->m_SourceFile = cmSystemTools::CollapseFullPath(
cmSystemTools::ReplaceString(cm->m_SourceFile, srcdir.c_str(), ""); cm->m_SourceFile.c_str());
cmSystemTools::ReplaceString(
cm->m_SourceFile, srcdir.c_str(), "");
} }
cm->m_LineNumber = atoi(re->match(rit->m_LineIndex).c_str()); cm->m_LineNumber = atoi(re->match(rit->m_LineIndex).c_str());
break; break;
@ -493,31 +528,32 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
} }
if ( cm->m_SourceFile.size() > 0 ) if ( cm->m_SourceFile.size() > 0 )
{ {
os << "\t\t<SourceFile>" << cm->m_SourceFile << "</SourceFile>" os << "\t\t<SourceFile>" << cm->m_SourceFile << "</SourceFile>"
<< std::endl; << std::endl;
} }
if ( cm->m_SourceFileTail.size() > 0 ) if ( cm->m_SourceFileTail.size() > 0 )
{ {
os << "\t\t<SourceFileTail>" << cm->m_SourceFileTail os << "\t\t<SourceFileTail>" << cm->m_SourceFileTail
<< "</SourceFileTail>" << std::endl; << "</SourceFileTail>" << std::endl;
} }
if ( cm->m_LineNumber >= 0 ) if ( cm->m_LineNumber >= 0 )
{ {
os << "\t\t<SourceLineNumber>" << cm->m_LineNumber os << "\t\t<SourceLineNumber>" << cm->m_LineNumber
<< "</SourceLineNumber>" << std::endl; << "</SourceLineNumber>" << std::endl;
} }
os << "\t\t<PreContext>" << m_CTest->MakeXMLSafe(cm->m_PreContext) os << "\t\t<PreContext>" << m_CTest->MakeXMLSafe(cm->m_PreContext)
<< "</PreContext>\n" << "</PreContext>\n"
<< "\t\t<PostContext>" << m_CTest->MakeXMLSafe(cm->m_PostContext); << "\t\t<PostContext>" << m_CTest->MakeXMLSafe(cm->m_PostContext);
// is this the last warning or error, if so notify // is this the last warning or error, if so notify
if (cm->m_Error && !numErrorsAllowed || if (cm->m_Error && !numErrorsAllowed ||
!cm->m_Error && !numWarningsAllowed) !cm->m_Error && !numWarningsAllowed)
{ {
os << "\nThe maximum number of reported warnings or errors has been reached!!!\n"; os << "\nThe maximum number of reported warnings or errors has been "
"reached!!!\n";
} }
os << "</PostContext>\n" os << "</PostContext>\n"
<< "\t\t<RepeatCount>0</RepeatCount>\n" << "\t\t<RepeatCount>0</RepeatCount>\n"
<< "</" << (cm->m_Error ? "Error" : "Warning") << ">\n\n" << "</" << (cm->m_Error ? "Error" : "Warning") << ">\n\n"
<< std::endl; << std::endl;
} }
} }
@ -561,7 +597,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\""); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\"");
} }
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl);
// Now create process object // Now create process object
cmsysProcess* cp = cmsysProcess_New(); cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_SetCommand(cp, &*argv.begin()); cmsysProcess_SetCommand(cp, &*argv.begin());
@ -577,7 +613,8 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
char* data; char* data;
int length; int length;
cmCTestLog(m_CTest, HANDLER_OUTPUT, cmCTestLog(m_CTest, HANDLER_OUTPUT,
" Each symbol represents " << tick_len << " bytes of output." << std::endl " Each symbol represents " << tick_len << " bytes of output."
<< std::endl
<< " '!' represents an error and '*' a warning." << std::endl << " '!' represents an error and '*' a warning." << std::endl
<< " " << std::flush); << " " << std::flush);
@ -609,16 +646,19 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
// Process the chunk of data // Process the chunk of data
if ( res == cmsysProcess_Pipe_STDERR ) if ( res == cmsysProcess_Pipe_STDERR )
{ {
this->ProcessBuffer(data, length, tick, tick_len, ofs, &m_BuildProcessingErrorQueue); this->ProcessBuffer(data, length, tick, tick_len, ofs,
&m_BuildProcessingErrorQueue);
} }
else else
{ {
this->ProcessBuffer(data, length, tick, tick_len, ofs, &m_BuildProcessingQueue); this->ProcessBuffer(data, length, tick, tick_len, ofs,
&m_BuildProcessingQueue);
} }
} }
this->ProcessBuffer(0, 0, tick, tick_len, ofs, &m_BuildProcessingQueue); this->ProcessBuffer(0, 0, tick, tick_len, ofs, &m_BuildProcessingQueue);
this->ProcessBuffer(0, 0, tick, tick_len, ofs, &m_BuildProcessingErrorQueue); this->ProcessBuffer(0, 0, tick, tick_len, ofs,
&m_BuildProcessingErrorQueue);
cmCTestLog(m_CTest, OUTPUT, " Size of output: " cmCTestLog(m_CTest, OUTPUT, " Size of output: "
<< int(m_BuildOutputLogSize / 1024.0) << "K" << std::endl); << int(m_BuildOutputLogSize / 1024.0) << "K" << std::endl);
@ -629,30 +669,33 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
if(result == cmsysProcess_State_Exited) if(result == cmsysProcess_State_Exited)
{ {
*retVal = cmsysProcess_GetExitValue(cp); *retVal = cmsysProcess_GetExitValue(cp);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Command exited with the value: " << *retVal << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
"Command exited with the value: " << *retVal << std::endl);
} }
else if(result == cmsysProcess_State_Exception) else if(result == cmsysProcess_State_Exception)
{ {
*retVal = cmsysProcess_GetExitException(cp); *retVal = cmsysProcess_GetExitException(cp);
cmCTestLog(m_CTest, WARNING, "There was an exception: " << *retVal << std::endl); cmCTestLog(m_CTest, WARNING, "There was an exception: " << *retVal
<< std::endl);
} }
else if(result == cmsysProcess_State_Expired) else if(result == cmsysProcess_State_Expired)
{ {
cmCTestLog(m_CTest, WARNING, "There was a timeout" << std::endl); cmCTestLog(m_CTest, WARNING, "There was a timeout" << std::endl);
} }
else if(result == cmsysProcess_State_Error) else if(result == cmsysProcess_State_Error)
{ {
// If there was an error running command, report that on the dashboard. // If there was an error running command, report that on the dashboard.
cmCTestBuildErrorWarning errorwarning; cmCTestBuildErrorWarning errorwarning;
errorwarning.m_LogLine = 1; errorwarning.m_LogLine = 1;
errorwarning.m_Text = "*** ERROR executing: "; errorwarning.m_Text = "*** ERROR executing: ";
errorwarning.m_Text += cmsysProcess_GetErrorString(cp); errorwarning.m_Text += cmsysProcess_GetErrorString(cp);
errorwarning.m_PreContext = ""; errorwarning.m_PreContext = "";
errorwarning.m_PostContext = ""; errorwarning.m_PostContext = "";
errorwarning.m_Error = true; errorwarning.m_Error = true;
m_ErrorsAndWarnings.push_back(errorwarning); m_ErrorsAndWarnings.push_back(errorwarning);
m_TotalErrors ++; m_TotalErrors ++;
cmCTestLog(m_CTest, ERROR_MESSAGE, "There was an error: " << cmsysProcess_GetErrorString(cp) << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "There was an error: "
<< cmsysProcess_GetErrorString(cp) << std::endl);
} }
cmsysProcess_Delete(cp); cmsysProcess_Delete(cp);
@ -666,8 +709,9 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
//###################################################################### //######################################################################
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len, void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
std::ofstream& ofs, t_BuildProcessingQueueType* queue) size_t& tick, size_t tick_len, std::ofstream& ofs,
t_BuildProcessingQueueType* queue)
{ {
#undef cerr #undef cerr
const std::string::size_type tick_line_len = 50; const std::string::size_type tick_line_len = 50;
@ -693,7 +737,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti
} }
} }
// Once certain number of errors or warnings reached, ignore future errors or warnings. // Once certain number of errors or warnings reached, ignore future errors
// or warnings.
if ( m_TotalWarnings >= m_MaxWarnings ) if ( m_TotalWarnings >= m_MaxWarnings )
{ {
m_WarningQuotaReached = true; m_WarningQuotaReached = true;
@ -750,7 +795,9 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti
// Copy pre-context to report // Copy pre-context to report
std::deque<cmStdString>::iterator pcit; std::deque<cmStdString>::iterator pcit;
for ( pcit = m_PreContext.begin(); pcit != m_PreContext.end(); ++pcit ) for ( pcit = m_PreContext.begin();
pcit != m_PreContext.end();
++pcit )
{ {
errorwarning.m_PreContext += *pcit + "\n"; errorwarning.m_PreContext += *pcit + "\n";
} }
@ -765,7 +812,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti
{ {
// This is not an error or warning. // This is not an error or warning.
// So, figure out if this is a post-context line // So, figure out if this is a post-context line
if ( m_LastErrorOrWarning != m_ErrorsAndWarnings.end() && m_PostContextCount < m_MaxPostContext ) if ( m_LastErrorOrWarning != m_ErrorsAndWarnings.end() &&
m_PostContextCount < m_MaxPostContext )
{ {
m_PostContextCount ++; m_PostContextCount ++;
m_LastErrorOrWarning->m_PostContext += line; m_LastErrorOrWarning->m_PostContext += line;
@ -780,7 +828,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti
m_PreContext.push_back(line); m_PreContext.push_back(line);
if ( m_PreContext.size() > m_MaxPreContext ) if ( m_PreContext.size() > m_MaxPreContext )
{ {
m_PreContext.erase(m_PreContext.begin(), m_PreContext.end()-m_MaxPreContext); m_PreContext.erase(m_PreContext.begin(),
m_PreContext.end()-m_MaxPreContext);
} }
} }
} }
@ -829,11 +878,13 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
int errorLine = 0; int errorLine = 0;
// Check for regular expressions // Check for regular expressions
if ( !m_ErrorQuotaReached ) if ( !m_ErrorQuotaReached )
{ {
// Errors // Errors
for ( it = m_ErrorMatchRegex.begin(); it != m_ErrorMatchRegex.end(); ++ it ) for ( it = m_ErrorMatchRegex.begin();
it != m_ErrorMatchRegex.end();
++ it )
{ {
if ( it->find(data) ) if ( it->find(data) )
{ {
@ -842,13 +893,16 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
break; break;
} }
} }
// Error exceptions // Error exceptions
for ( it = m_ErrorExceptionRegex.begin(); it != m_ErrorExceptionRegex.end(); ++ it ) for ( it = m_ErrorExceptionRegex.begin();
it != m_ErrorExceptionRegex.end();
++ it )
{ {
if ( it->find(data) ) if ( it->find(data) )
{ {
errorLine = 0; errorLine = 0;
cmCTestLog(m_CTest, DEBUG, " Not an error Line: " << data << std::endl); cmCTestLog(m_CTest, DEBUG, " Not an error Line: " << data
<< std::endl);
break; break;
} }
} }
@ -856,25 +910,30 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
if ( !m_WarningQuotaReached ) if ( !m_WarningQuotaReached )
{ {
// Warnings // Warnings
for ( it = m_WarningMatchRegex.begin(); it != m_WarningMatchRegex.end(); ++ it ) for ( it = m_WarningMatchRegex.begin();
it != m_WarningMatchRegex.end();
++ it )
{ {
if ( it->find(data) ) if ( it->find(data) )
{ {
warningLine = 1; warningLine = 1;
cmCTestLog(m_CTest, DEBUG, " Warning Line: " << data << std::endl); cmCTestLog(m_CTest, DEBUG, " Warning Line: " << data << std::endl);
break; break;
} }
} }
// Warning exceptions // Warning exceptions
for ( it = m_WarningExceptionRegex.begin(); it != m_WarningExceptionRegex.end(); ++ it ) for ( it = m_WarningExceptionRegex.begin();
it != m_WarningExceptionRegex.end();
++ it )
{ {
if ( it->find(data) ) if ( it->find(data) )
{ {
warningLine = 0; warningLine = 0;
cmCTestLog(m_CTest, DEBUG, " Not a warning Line: " << data << std::endl); cmCTestLog(m_CTest, DEBUG, " Not a warning Line: " << data
<< std::endl);
break; break;
} }
} }
} }
if ( errorLine ) if ( errorLine )

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -39,21 +39,21 @@ public:
* The main entry point for this class * The main entry point for this class
*/ */
int ProcessHandler(); int ProcessHandler();
cmCTestBuildHandler(); cmCTestBuildHandler();
void PopulateCustomVectors(cmMakefile *mf); void PopulateCustomVectors(cmMakefile *mf);
/** /**
* Initialize handler * Initialize handler
*/ */
virtual void Initialize(); virtual void Initialize();
private: private:
//! Run command specialized for make and configure. Returns process status //! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception. // and retVal is return value or exception.
int RunMakeCommand(const char* command, int RunMakeCommand(const char* command,
int* retVal, const char* dir, int timeout, int* retVal, const char* dir, int timeout,
std::ofstream& ofs); std::ofstream& ofs);
enum { enum {
@ -84,14 +84,14 @@ private:
}; };
// generate the XML output // generate the XML output
void GenerateDartBuildOutput(std::ostream& os, void GenerateDartBuildOutput(std::ostream& os,
std::vector<cmCTestBuildErrorWarning>, std::vector<cmCTestBuildErrorWarning>,
double elapsed_time); double elapsed_time);
std::string m_StartBuild; std::string m_StartBuild;
std::string m_EndBuild; std::string m_EndBuild;
std::vector<cmStdString> m_CustomErrorMatches; std::vector<cmStdString> m_CustomErrorMatches;
std::vector<cmStdString> m_CustomErrorExceptions; std::vector<cmStdString> m_CustomErrorExceptions;
std::vector<cmStdString> m_CustomWarningMatches; std::vector<cmStdString> m_CustomWarningMatches;
@ -105,8 +105,8 @@ private:
typedef std::deque<char> t_BuildProcessingQueueType; typedef std::deque<char> t_BuildProcessingQueueType;
void ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len, void ProcessBuffer(const char* data, int length, size_t& tick,
std::ofstream& ofs, t_BuildProcessingQueueType* queue); size_t tick_len, std::ofstream& ofs, t_BuildProcessingQueueType* queue);
int ProcessSingleLine(const char* data); int ProcessSingleLine(const char* data);
t_BuildProcessingQueueType m_BuildProcessingQueue; t_BuildProcessingQueueType m_BuildProcessingQueue;

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -50,16 +50,18 @@ bool cmCTestConfigureCommand::InitialPass(
{ {
if ( res_var ) if ( res_var )
{ {
this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); this->SetError("called with incorrect number of arguments. "
"RETURN_VALUE specified twice.");
return false; return false;
} }
havereturn_variable = true; havereturn_variable = true;
} }
else if(args[i] == "SOURCE") else if(args[i] == "SOURCE")
{ {
if ( source_dir ) if ( source_dir )
{ {
this->SetError("called with incorrect number of arguments. SOURCE specified twice."); this->SetError("called with incorrect number of arguments. "
"SOURCE specified twice.");
return false; return false;
} }
havesource = true; havesource = true;
@ -68,7 +70,8 @@ bool cmCTestConfigureCommand::InitialPass(
{ {
if ( build_dir ) if ( build_dir )
{ {
this->SetError("called with incorrect number of arguments. BUILD specified twice."); this->SetError("called with incorrect number of arguments. "
"BUILD specified twice.");
return false; return false;
} }
havebuild = true; havebuild = true;
@ -76,7 +79,8 @@ bool cmCTestConfigureCommand::InitialPass(
else else
{ {
cmOStringStream str; cmOStringStream str;
str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; str << "called with incorrect number of arguments. Extra argument is: "
<< args[i].c_str() << ".";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }
@ -100,20 +104,24 @@ bool cmCTestConfigureCommand::InitialPass(
build_dir = m_Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"); build_dir = m_Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
if ( !build_dir ) if ( !build_dir )
{ {
this->SetError("Build directory not specified. Either use BUILD argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY variable"); this->SetError("Build directory not specified. Either use BUILD "
"argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY "
"variable");
return false; return false;
} }
} }
const char* ctestConfigureCommand = m_Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); const char* ctestConfigureCommand
= m_Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND");
if ( ctestConfigureCommand && *ctestConfigureCommand ) if ( ctestConfigureCommand && *ctestConfigureCommand )
{ {
m_CTest->SetCTestConfiguration("ConfigureCommand", ctestConfigureCommand); m_CTest->SetCTestConfiguration("ConfigureCommand", ctestConfigureCommand);
} }
else else
{ {
const char* cmakeGeneratorName = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); const char* cmakeGeneratorName
= m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
if ( cmakeGeneratorName && *cmakeGeneratorName ) if ( cmakeGeneratorName && *cmakeGeneratorName )
{ {
std::string cmakeConfigureCommand = "\""; std::string cmakeConfigureCommand = "\"";
@ -123,19 +131,24 @@ bool cmCTestConfigureCommand::InitialPass(
cmakeConfigureCommand += "\" \""; cmakeConfigureCommand += "\" \"";
cmakeConfigureCommand += source_dir; cmakeConfigureCommand += source_dir;
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
m_CTest->SetCTestConfiguration("ConfigureCommand", cmakeConfigureCommand.c_str()); m_CTest->SetCTestConfiguration("ConfigureCommand",
cmakeConfigureCommand.c_str());
} }
else else
{ {
this->SetError("Configure command is not specified. If this is a CMake project, specify CTEST_CMAKE_GENERATOR, or if this is not CMake project, specify CTEST_CONFIGURE_COMMAND."); this->SetError("Configure command is not specified. If this is a CMake "
"project, specify CTEST_CMAKE_GENERATOR, or if this is not CMake "
"project, specify CTEST_CONFIGURE_COMMAND.");
return false; return false;
} }
} }
cmCTestGenericHandler* handler = m_CTest->GetInitializedHandler("configure"); cmCTestGenericHandler* handler
= m_CTest->GetInitializedHandler("configure");
if ( !handler ) if ( !handler )
{ {
this->SetError("internal CTest error. Cannot instantiate configure handler"); this->SetError(
"internal CTest error. Cannot instantiate configure handler");
return false; return false;
} }
int res = handler->ProcessHandler(); int res = handler->ProcessHandler();

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -29,11 +29,11 @@ class cmCTestConfigureCommand : public cmCTestCommand
public: public:
cmCTestConfigureCommand() {} cmCTestConfigureCommand() {}
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestConfigureCommand* ni = new cmCTestConfigureCommand; cmCTestConfigureCommand* ni = new cmCTestConfigureCommand;
ni->m_CTest = this->m_CTest; ni->m_CTest = this->m_CTest;
@ -55,11 +55,11 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Configures the repository."; return "Configures the repository.";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -67,8 +67,9 @@ public:
{ {
return return
" CTEST_CONFIGURE(BUILD build_dir RETURN_VALUE res)\n" " CTEST_CONFIGURE(BUILD build_dir RETURN_VALUE res)\n"
"Configures the given build directory and stores results in Configure.xml. The " "Configures the given build directory and stores results in "
"second argument is a variable that will hold return value."; "Configure.xml. The second argument is a variable that will hold "
"return value.";
} }
cmTypeMacro(cmCTestConfigureCommand, cmCTestCommand); cmTypeMacro(cmCTestConfigureCommand, cmCTestCommand);

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -43,15 +43,19 @@ int cmCTestConfigureHandler::ProcessHandler()
std::string cCommand = m_CTest->GetCTestConfiguration("ConfigureCommand"); std::string cCommand = m_CTest->GetCTestConfiguration("ConfigureCommand");
if ( cCommand.size() == 0 ) if ( cCommand.size() == 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find ConfigureCommand key in the DartConfiguration.tcl" cmCTestLog(m_CTest, ERROR_MESSAGE,
<< std::endl); "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
<< std::endl);
return -1; return -1;
} }
std::string buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); std::string buildDirectory
= m_CTest->GetCTestConfiguration("BuildDirectory");
if ( buildDirectory.size() == 0 ) if ( buildDirectory.size() == 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
<< std::endl);
return -1; return -1;
} }
@ -61,18 +65,20 @@ int cmCTestConfigureHandler::ProcessHandler()
int res = 0; int res = 0;
if ( !m_CTest->GetShowOnly() ) if ( !m_CTest->GetShowOnly() )
{ {
cmGeneratedFileStream os; cmGeneratedFileStream os;
if ( !this->StartResultingXML("Configure", os) ) if ( !this->StartResultingXML("Configure", os) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open configure file" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open configure file"
<< std::endl);
return 1; return 1;
} }
std::string start_time = m_CTest->CurrentTime(); std::string start_time = m_CTest->CurrentTime();
cmGeneratedFileStream ofs; cmGeneratedFileStream ofs;
this->StartLogFile("Configure", ofs); this->StartLogFile("Configure", ofs);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " << cCommand.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: "
res = m_CTest->RunMakeCommand(cCommand.c_str(), &output, << cCommand.c_str() << std::endl);
res = m_CTest->RunMakeCommand(cCommand.c_str(), &output,
&retVal, buildDirectory.c_str(), &retVal, buildDirectory.c_str(),
0, ofs); 0, ofs);
@ -80,37 +86,41 @@ int cmCTestConfigureHandler::ProcessHandler()
{ {
ofs.close(); ofs.close();
} }
if ( os ) if ( os )
{ {
m_CTest->StartXML(os); m_CTest->StartXML(os);
os << "<Configure>\n" os << "<Configure>\n"
<< "\t<StartDateTime>" << start_time << "</StartDateTime>" << std::endl; << "\t<StartDateTime>" << start_time << "</StartDateTime>"
<< std::endl;
if ( res == cmsysProcess_State_Exited && retVal ) if ( res == cmsysProcess_State_Exited && retVal )
{ {
os << retVal; os << retVal;
} }
os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>" << std::endl; os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>"
<< std::endl;
cmCTestLog(m_CTest, DEBUG, "End" << std::endl); cmCTestLog(m_CTest, DEBUG, "End" << std::endl);
os << "<Log>" << cmCTest::MakeXMLSafe(output) << "</Log>" << std::endl; os << "<Log>" << cmCTest::MakeXMLSafe(output) << "</Log>" << std::endl;
std::string end_time = m_CTest->CurrentTime(); std::string end_time = m_CTest->CurrentTime();
os << "\t<ConfigureStatus>" << retVal << "</ConfigureStatus>\n" os << "\t<ConfigureStatus>" << retVal << "</ConfigureStatus>\n"
<< "\t<EndDateTime>" << end_time << "</EndDateTime>\n" << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
<< "<ElapsedMinutes>" << "<ElapsedMinutes>"
<< static_cast<int>( << static_cast<int>(
(cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0 (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
<< "</ElapsedMinutes>" << "</ElapsedMinutes>"
<< "</Configure>" << std::endl; << "</Configure>" << std::endl;
m_CTest->EndXML(os); m_CTest->EndXML(os);
} }
} }
else else
{ {
cmCTestLog(m_CTest, DEBUG, "Configure with command: " << cCommand << std::endl); cmCTestLog(m_CTest, DEBUG, "Configure with command: " << cCommand
<< std::endl);
} }
if (! res || retVal ) if (! res || retVal )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when updating the project" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when updating the project"
<< std::endl);
return -1; return -1;
} }
return 0; return 0;

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -35,7 +35,7 @@ public:
* The main entry point for this class * The main entry point for this class
*/ */
int ProcessHandler(); int ProcessHandler();
cmCTestConfigureHandler(); cmCTestConfigureHandler();
void Initialize(); void Initialize();

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -43,16 +43,18 @@ bool cmCTestCoverageCommand::InitialPass(
{ {
if ( res_var ) if ( res_var )
{ {
this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); this->SetError("called with incorrect number of arguments. "
"RETURN_VALUE specified twice.");
return false; return false;
} }
havereturn_variable = true; havereturn_variable = true;
} }
else if(args[i] == "BUILD") else if(args[i] == "BUILD")
{ {
if ( build_dir ) if ( build_dir )
{ {
this->SetError("called with incorrect number of arguments. BUILD specified twice."); this->SetError("called with incorrect number of arguments. "
"BUILD specified twice.");
return false; return false;
} }
havesource = true; havesource = true;
@ -60,7 +62,8 @@ bool cmCTestCoverageCommand::InitialPass(
else else
{ {
cmOStringStream str; cmOStringStream str;
str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; str << "called with incorrect number of arguments. Extra argument is: "
<< args[i].c_str() << ".";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }
@ -81,7 +84,8 @@ bool cmCTestCoverageCommand::InitialPass(
return false; return false;
} }
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(m_CTest->GetCTestConfiguration("BuildDirectory").c_str()); cmSystemTools::ChangeDirectory(
m_CTest->GetCTestConfiguration("BuildDirectory").c_str());
int res = handler->ProcessHandler(); int res = handler->ProcessHandler();
if ( res_var ) if ( res_var )
{ {

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -29,11 +29,11 @@ class cmCTestCoverageCommand : public cmCTestCommand
public: public:
cmCTestCoverageCommand() {} cmCTestCoverageCommand() {}
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestCoverageCommand* ni = new cmCTestCoverageCommand; cmCTestCoverageCommand* ni = new cmCTestCoverageCommand;
ni->m_CTest = this->m_CTest; ni->m_CTest = this->m_CTest;
@ -55,11 +55,11 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Tests the repository."; return "Tests the repository.";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -67,8 +67,9 @@ public:
{ {
return return
" CTEST_COVERAGE([BUILD build_dir] [RETURN_VALUE res])\n" " CTEST_COVERAGE([BUILD build_dir] [RETURN_VALUE res])\n"
"Perform the coverage of the given build directory and stores results in " "Perform the coverage of the given build directory and stores results "
"Coverage.xml. The second argument is a variable that will hold value."; "in Coverage.xml. The second argument is a variable that will hold "
"value.";
} }
cmTypeMacro(cmCTestCoverageCommand, cmCTestCommand); cmTypeMacro(cmCTestCoverageCommand, cmCTestCommand);

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -25,7 +25,7 @@
#include <cmsys/Process.h> #include <cmsys/Process.h>
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
@ -44,25 +44,30 @@ void cmCTestCoverageHandler::Initialize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestCoverageHandler::StartCoverageLogFile(cmGeneratedFileStream& covLogFile, int logFileCount) bool cmCTestCoverageHandler::StartCoverageLogFile(
cmGeneratedFileStream& covLogFile, int logFileCount)
{ {
char covLogFilename[1024]; char covLogFilename[1024];
sprintf(covLogFilename, "CoverageLog-%d", logFileCount); sprintf(covLogFilename, "CoverageLog-%d", logFileCount);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Open file: " << covLogFilename << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Open file: " << covLogFilename
<< std::endl);
if (!this->StartResultingXML(covLogFilename, covLogFile) ) if (!this->StartResultingXML(covLogFilename, covLogFile) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open log file: " << covLogFilename << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open log file: "
<< covLogFilename << std::endl);
return false; return false;
} }
std::string local_start_time = m_CTest->CurrentTime(); std::string local_start_time = m_CTest->CurrentTime();
m_CTest->StartXML(covLogFile); m_CTest->StartXML(covLogFile);
covLogFile << "<CoverageLog>" << std::endl covLogFile << "<CoverageLog>" << std::endl
<< "\t<StartDateTime>" << local_start_time << "</StartDateTime>" << std::endl; << "\t<StartDateTime>" << local_start_time << "</StartDateTime>"
<< std::endl;
return true; return true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount) void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr,
int logFileCount)
{ {
std::string local_end_time = m_CTest->CurrentTime(); std::string local_end_time = m_CTest->CurrentTime();
ostr << "\t<EndDateTime>" << local_end_time << "</EndDateTime>" << std::endl ostr << "\t<EndDateTime>" << local_end_time << "</EndDateTime>" << std::endl
@ -70,12 +75,14 @@ void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr, int
m_CTest->EndXML(ostr); m_CTest->EndXML(ostr);
char covLogFilename[1024]; char covLogFilename[1024];
sprintf(covLogFilename, "CoverageLog-%d.xml", logFileCount); sprintf(covLogFilename, "CoverageLog-%d.xml", logFileCount);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Close file: " << covLogFilename << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Close file: "
<< covLogFilename << std::endl);
ostr.Close(); ostr.Close();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* srcDir, bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
const char* srcDir,
const char* binDir) const char* binDir)
{ {
std::vector<cmsys::RegularExpression>::iterator sit; std::vector<cmsys::RegularExpression>::iterator sit;
@ -93,8 +100,10 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* src
std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir); std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir);
std::string fBinDir = cmSystemTools::CollapseFullPath(binDir); std::string fBinDir = cmSystemTools::CollapseFullPath(binDir);
std::string fFile = cmSystemTools::CollapseFullPath(file); std::string fFile = cmSystemTools::CollapseFullPath(file);
bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fSrcDir.c_str()); bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(),
bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fBinDir.c_str()); fSrcDir.c_str());
bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(),
fBinDir.c_str());
// Always check parent directory of the file. // Always check parent directory of the file.
std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str()); std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str());
std::string checkDir; std::string checkDir;
@ -124,7 +133,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* src
fFile.c_str(), checkDir.c_str()); fFile.c_str(), checkDir.c_str());
if ( ndc.size() ) if ( ndc.size() )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() << " so skip coverage of " << file << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str()
<< " so skip coverage of " << file << std::endl);
return false; return false;
} }
@ -154,7 +164,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* src
fFile.c_str(), checkDir.c_str()); fFile.c_str(), checkDir.c_str());
if ( ndc.size() ) if ( ndc.size() )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() << " so skip coverage of: " << file << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str()
<< " so skip coverage of: " << file << std::endl);
return false; return false;
} }
// Ok, nothing in source tree, nothing in binary tree // Ok, nothing in source tree, nothing in binary tree
@ -176,7 +187,8 @@ int cmCTestCoverageHandler::ProcessHandler()
double elapsed_time_start = cmSystemTools::GetTime(); double elapsed_time_start = cmSystemTools::GetTime();
if ( !this->StartLogFile("Coverage", ofs) ) if ( !this->StartLogFile("Coverage", ofs) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create LastCoverage.log file" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create LastCoverage.log file"
<< std::endl);
} }
ofs << "Performing coverage: " << elapsed_time_start << std::endl; ofs << "Performing coverage: " << elapsed_time_start << std::endl;
@ -186,39 +198,42 @@ int cmCTestCoverageHandler::ProcessHandler()
std::string asfGlob = sourceDir + "/*"; std::string asfGlob = sourceDir + "/*";
std::string abfGlob = binaryDir + "/*"; std::string abfGlob = binaryDir + "/*";
// Style 1 // Style 1
std::string st1gcovOutputRex1 = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$"; std::string st1gcovOutputRex1
= "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$";
std::string st1gcovOutputRex2 = "^Creating (.*\\.gcov)\\."; std::string st1gcovOutputRex2 = "^Creating (.*\\.gcov)\\.";
cmsys::RegularExpression st1re1(st1gcovOutputRex1.c_str()); cmsys::RegularExpression st1re1(st1gcovOutputRex1.c_str());
cmsys::RegularExpression st1re2(st1gcovOutputRex2.c_str()); cmsys::RegularExpression st1re2(st1gcovOutputRex2.c_str());
// Style 2 // Style 2
std::string st2gcovOutputRex1 = "^File *[`'](.*)'$"; std::string st2gcovOutputRex1 = "^File *[`'](.*)'$";
std::string st2gcovOutputRex2 = "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$"; std::string st2gcovOutputRex2
= "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$";
std::string st2gcovOutputRex3 = "^(.*):creating [`'](.*\\.gcov)'"; std::string st2gcovOutputRex3 = "^(.*):creating [`'](.*\\.gcov)'";
std::string st2gcovOutputRex4 = "^(.*):unexpected EOF *$"; std::string st2gcovOutputRex4 = "^(.*):unexpected EOF *$";
std::string st2gcovOutputRex5 = "^(.*):cannot open source file*$"; std::string st2gcovOutputRex5 = "^(.*):cannot open source file*$";
std::string st2gcovOutputRex6 = "^(.*):source file is newer than graph file `(.*)'$"; std::string st2gcovOutputRex6
= "^(.*):source file is newer than graph file `(.*)'$";
cmsys::RegularExpression st2re1(st2gcovOutputRex1.c_str()); cmsys::RegularExpression st2re1(st2gcovOutputRex1.c_str());
cmsys::RegularExpression st2re2(st2gcovOutputRex2.c_str()); cmsys::RegularExpression st2re2(st2gcovOutputRex2.c_str());
cmsys::RegularExpression st2re3(st2gcovOutputRex3.c_str()); cmsys::RegularExpression st2re3(st2gcovOutputRex3.c_str());
cmsys::RegularExpression st2re4(st2gcovOutputRex4.c_str()); cmsys::RegularExpression st2re4(st2gcovOutputRex4.c_str());
cmsys::RegularExpression st2re5(st2gcovOutputRex5.c_str()); cmsys::RegularExpression st2re5(st2gcovOutputRex5.c_str());
cmsys::RegularExpression st2re6(st2gcovOutputRex6.c_str()); cmsys::RegularExpression st2re6(st2gcovOutputRex6.c_str());
cmCTestLog(m_CTest, HANDLER_OUTPUT, "Performing coverage" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, "Performing coverage" << std::endl);
std::string coverage_start_time = m_CTest->CurrentTime(); std::string coverage_start_time = m_CTest->CurrentTime();
std::string testingDir = m_CTest->GetBinaryDir() + "/Testing"; std::string testingDir = m_CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo"; std::string tempDir = testingDir + "/CoverageInfo";
std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::MakeDirectory(tempDir.c_str()); cmSystemTools::MakeDirectory(tempDir.c_str());
cmSystemTools::ChangeDirectory(tempDir.c_str()); cmSystemTools::ChangeDirectory(tempDir.c_str());
cmGlob gl; cmGlob gl;
gl.RecurseOn(); gl.RecurseOn();
std::string daGlob = binaryDir + "/*.da"; std::string daGlob = binaryDir + "/*.da";
@ -229,10 +244,11 @@ int cmCTestCoverageHandler::ProcessHandler()
std::vector<std::string>& moreFiles = gl.GetFiles(); std::vector<std::string>& moreFiles = gl.GetFiles();
files.insert(files.end(), moreFiles.begin(), moreFiles.end()); files.insert(files.end(), moreFiles.begin(), moreFiles.end());
std::vector<std::string>::iterator it; std::vector<std::string>::iterator it;
if ( files.size() == 0 ) if ( files.size() == 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find any coverage files." << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find any coverage files."
<< std::endl);
// No coverage files is a valid thing, so the exit code is 0 // No coverage files is a valid thing, so the exit code is 0
return 0; return 0;
} }
@ -243,27 +259,30 @@ int cmCTestCoverageHandler::ProcessHandler()
rexIt != m_CustomCoverageExclude.end(); rexIt != m_CustomCoverageExclude.end();
++ rexIt ) ++ rexIt )
{ {
m_CustomCoverageExcludeRegex.push_back(cmsys::RegularExpression(rexIt->c_str())); m_CustomCoverageExcludeRegex.push_back(
cmsys::RegularExpression(rexIt->c_str()));
} }
typedef std::vector<int> singleFileCoverageVector; typedef std::vector<int> singleFileCoverageVector;
typedef std::map<std::string, singleFileCoverageVector> totalCoverageMap; typedef std::map<std::string, singleFileCoverageVector> totalCoverageMap;
totalCoverageMap totalCoverage; totalCoverageMap totalCoverage;
int gcovStyle = 0; int gcovStyle = 0;
std::set<std::string> missingFiles; std::set<std::string> missingFiles;
std::string actualSourceFile = ""; std::string actualSourceFile = "";
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Processing coverage (each . represents one file):" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT,
" Processing coverage (each . represents one file):" << std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); cmCTestLog(m_CTest, HANDLER_OUTPUT, " ");
int file_count = 0; int file_count = 0;
for ( it = files.begin(); it != files.end(); ++ it ) for ( it = files.begin(); it != files.end(); ++ it )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, "." << std::flush); cmCTestLog(m_CTest, HANDLER_OUTPUT, "." << std::flush);
std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str());
std::string command = "\"" + gcovCommand + "\" -l -o \"" + fileDir + "\" \"" + *it + "\""; std::string command = "\"" + gcovCommand + "\" -l -o \"" + fileDir
+ "\" \"" + *it + "\"";
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() << std::endl);
std::string output = ""; std::string output = "";
std::string errors = ""; std::string errors = "";
@ -272,36 +291,43 @@ int cmCTestCoverageHandler::ProcessHandler()
ofs << " Command: " << command.c_str() << std::endl; ofs << " Command: " << command.c_str() << std::endl;
int res = m_CTest->RunCommand(command.c_str(), &output, &errors, int res = m_CTest->RunCommand(command.c_str(), &output, &errors,
&retVal, tempDir.c_str(), 0 /*m_TimeOut*/); &retVal, tempDir.c_str(), 0 /*m_TimeOut*/);
ofs << " Output: " << output.c_str() << std::endl; ofs << " Output: " << output.c_str() << std::endl;
ofs << " Errors: " << errors.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl;
if ( ! res ) if ( ! res )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem running coverage on file: " << it->c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem running coverage on file: "
cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << errors << std::endl); << it->c_str() << std::endl);
cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << errors
<< std::endl);
error ++; error ++;
continue; continue;
} }
if ( retVal != 0 ) if ( retVal != 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Coverage command returned: " << retVal << " while processing: " << it->c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Coverage command returned: "
cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << error << std::endl); << retVal << " while processing: " << it->c_str() << std::endl);
cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << error
<< std::endl);
} }
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
"--------------------------------------------------------------" << std::endl "--------------------------------------------------------------"
<< std::endl
<< output << std::endl << output << std::endl
<< "--------------------------------------------------------------" << std::endl); << "--------------------------------------------------------------"
<< std::endl);
std::vector<cmStdString> lines; std::vector<cmStdString> lines;
std::vector<cmStdString>::iterator line; std::vector<cmStdString>::iterator line;
// Globals for storing current source file and current gcov file; // Globals for storing current source file and current gcov file;
cmSystemTools::Split(output.c_str(), lines); cmSystemTools::Split(output.c_str(), lines);
for ( line = lines.begin(); line != lines.end(); ++line) for ( line = lines.begin(); line != lines.end(); ++line)
{ {
std::string sourceFile; std::string sourceFile;
std::string gcovFile; std::string gcovFile;
cmCTestLog(m_CTest, DEBUG, "Line: [" << line->c_str() << "]" << std::endl); cmCTestLog(m_CTest, DEBUG, "Line: [" << line->c_str() << "]"
<< std::endl);
if ( line->size() == 0 ) if ( line->size() == 0 )
{ {
// Ignore empty line; probably style 2 // Ignore empty line; probably style 2
@ -312,13 +338,14 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( gcovStyle != 1 ) if ( gcovStyle != 1 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style"
<< std::endl);
error ++; error ++;
break; break;
} }
gcovStyle = 1; gcovStyle = 1;
} }
actualSourceFile = ""; actualSourceFile = "";
sourceFile = st1re1.match(2); sourceFile = st1re1.match(2);
} }
@ -328,13 +355,14 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( gcovStyle != 1 ) if ( gcovStyle != 1 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style"
<< std::endl);
error ++; error ++;
break; break;
} }
gcovStyle = 1; gcovStyle = 1;
} }
gcovFile = st1re2.match(1); gcovFile = st1re2.match(1);
} }
else if ( st2re1.find(line->c_str() ) ) else if ( st2re1.find(line->c_str() ) )
@ -343,13 +371,14 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( gcovStyle != 2 ) if ( gcovStyle != 2 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style"
<< std::endl);
error ++; error ++;
break; break;
} }
gcovStyle = 2; gcovStyle = 2;
} }
actualSourceFile = ""; actualSourceFile = "";
sourceFile = st2re1.match(1); sourceFile = st2re1.match(1);
} }
@ -359,7 +388,8 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( gcovStyle != 2 ) if ( gcovStyle != 2 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style"
<< std::endl);
error ++; error ++;
break; break;
} }
@ -372,13 +402,14 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( gcovStyle != 2 ) if ( gcovStyle != 2 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style"
<< std::endl);
error ++; error ++;
break; break;
} }
gcovStyle = 2; gcovStyle = 2;
} }
gcovFile = st2re3.match(2); gcovFile = st2re3.match(2);
} }
else if ( st2re4.find(line->c_str() ) ) else if ( st2re4.find(line->c_str() ) )
@ -387,14 +418,16 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( gcovStyle != 2 ) if ( gcovStyle != 2 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style"
<< std::endl);
error ++; error ++;
break; break;
} }
gcovStyle = 2; gcovStyle = 2;
} }
cmCTestLog(m_CTest, WARNING, "Warning: " << st2re4.match(1) << " had unexpected EOF" << std::endl); cmCTestLog(m_CTest, WARNING, "Warning: " << st2re4.match(1)
<< " had unexpected EOF" << std::endl);
} }
else if ( st2re5.find(line->c_str() ) ) else if ( st2re5.find(line->c_str() ) )
{ {
@ -402,14 +435,16 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( gcovStyle != 2 ) if ( gcovStyle != 2 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style"
<< std::endl);
error ++; error ++;
break; break;
} }
gcovStyle = 2; gcovStyle = 2;
} }
cmCTestLog(m_CTest, WARNING, "Warning: Cannot open file: " << st2re5.match(1) << std::endl); cmCTestLog(m_CTest, WARNING, "Warning: Cannot open file: "
<< st2re5.match(1) << std::endl);
} }
else if ( st2re6.find(line->c_str() ) ) else if ( st2re6.find(line->c_str() ) )
{ {
@ -417,30 +452,34 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( gcovStyle != 2 ) if ( gcovStyle != 2 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown gcov output style"
<< std::endl);
error ++; error ++;
break; break;
} }
gcovStyle = 2; gcovStyle = 2;
} }
cmCTestLog(m_CTest, WARNING, "Warning: File: " << st2re6.match(1) cmCTestLog(m_CTest, WARNING, "Warning: File: " << st2re6.match(1)
<< " is newer than " << st2re6.match(2) << std::endl); << " is newer than " << st2re6.match(2) << std::endl);
} }
else else
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown line: [" << line->c_str() << "]" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown line: [" << line->c_str()
<< "]" << std::endl);
error ++; error ++;
//abort(); //abort();
} }
if ( !gcovFile.empty() && actualSourceFile.size() ) if ( !gcovFile.empty() && actualSourceFile.size() )
{ {
singleFileCoverageVector* vec = &totalCoverage[actualSourceFile]; singleFileCoverageVector* vec = &totalCoverage[actualSourceFile];
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " in file: " << gcovFile << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " in file: "
<< gcovFile << std::endl);
std::ifstream ifile(gcovFile.c_str()); std::ifstream ifile(gcovFile.c_str());
if ( ! ifile ) if ( ! ifile )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open file: " << gcovFile << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open file: "
<< gcovFile << std::endl);
} }
else else
{ {
@ -449,30 +488,33 @@ int cmCTestCoverageHandler::ProcessHandler()
while ( cmSystemTools::GetLineFromStream(ifile, nl) ) while ( cmSystemTools::GetLineFromStream(ifile, nl) )
{ {
cnt ++; cnt ++;
//TODO: Handle gcov 3.0 non-coverage lines //TODO: Handle gcov 3.0 non-coverage lines
// Skip empty lines // Skip empty lines
if ( !nl.size() ) if ( !nl.size() )
{ {
continue; continue;
} }
// Skip unused lines // Skip unused lines
if ( nl.size() < 12 ) if ( nl.size() < 12 )
{ {
continue; continue;
} }
// Read the coverage count from the beginning of the gcov output line // Read the coverage count from the beginning of the gcov output
// line
std::string prefix = nl.substr(0, 12); std::string prefix = nl.substr(0, 12);
int cov = atoi(prefix.c_str()); int cov = atoi(prefix.c_str());
// Read the line number starting at the 10th character of the gcov output line // Read the line number starting at the 10th character of the gcov
// output line
std::string lineNumber = nl.substr(10, 5); std::string lineNumber = nl.substr(10, 5);
int lineIdx = atoi(lineNumber.c_str())-1; int lineIdx = atoi(lineNumber.c_str())-1;
if ( lineIdx >= 0 ) if ( lineIdx >= 0 )
{ {
while ( vec->size() <= static_cast<singleFileCoverageVector::size_type>(lineIdx) ) while ( vec->size() <=
static_cast<singleFileCoverageVector::size_type>(lineIdx) )
{ {
vec->push_back(-1); vec->push_back(-1);
} }
@ -499,28 +541,39 @@ int cmCTestCoverageHandler::ProcessHandler()
sourceFile.substr(0, sourceDir.size()) == sourceDir && sourceFile.substr(0, sourceDir.size()) == sourceDir &&
sourceFile[sourceDir.size()] == '/' ) sourceFile[sourceDir.size()] == '/' )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " << sourceFile.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced s: "
ofs << " produced in source dir: " << sourceFile.c_str() << std::endl; << sourceFile.c_str() << std::endl);
actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); ofs << " produced in source dir: " << sourceFile.c_str()
<< std::endl;
actualSourceFile
= cmSystemTools::CollapseFullPath(sourceFile.c_str());
} }
// Binary dir? // Binary dir?
if ( sourceFile.size() > binaryDir.size() && if ( sourceFile.size() > binaryDir.size() &&
sourceFile.substr(0, binaryDir.size()) == binaryDir && sourceFile.substr(0, binaryDir.size()) == binaryDir &&
sourceFile[binaryDir.size()] == '/' ) sourceFile[binaryDir.size()] == '/' )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " << sourceFile.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced b: "
ofs << " produced in binary dir: " << sourceFile.c_str() << std::endl; << sourceFile.c_str() << std::endl);
actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); ofs << " produced in binary dir: " << sourceFile.c_str()
<< std::endl;
actualSourceFile
= cmSystemTools::CollapseFullPath(sourceFile.c_str());
} }
if ( actualSourceFile.empty() ) if ( actualSourceFile.empty() )
{ {
if ( missingFiles.find(actualSourceFile) == missingFiles.end() ) if ( missingFiles.find(actualSourceFile) == missingFiles.end() )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Something went wrong" << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Something went wrong"
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "File: [" << sourceFile.c_str() << "]" << std::endl); << std::endl);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "s: [" << sourceFile.substr(0, sourceDir.size()) << "]" << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "File: ["
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "b: [" << sourceFile.substr(0, binaryDir.size()) << "]" << std::endl); << sourceFile.c_str() << "]" << std::endl);
ofs << " Something went wrong. Cannot find: " << sourceFile.c_str() cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "s: ["
<< sourceFile.substr(0, sourceDir.size()) << "]" << std::endl);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "b: ["
<< sourceFile.substr(0, binaryDir.size()) << "]" << std::endl);
ofs << " Something went wrong. Cannot find: "
<< sourceFile.c_str()
<< " in source dir: " << sourceDir.c_str() << " in source dir: " << sourceDir.c_str()
<< " or binary dir: " << binaryDir.c_str() << std::endl; << " or binary dir: " << binaryDir.c_str() << std::endl;
missingFiles.insert(actualSourceFile); missingFiles.insert(actualSourceFile);
@ -531,17 +584,19 @@ int cmCTestCoverageHandler::ProcessHandler()
file_count ++; file_count ++;
if ( file_count % 50 == 0 ) if ( file_count % 50 == 0 )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " processed: " << file_count << " out of " << files.size() << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " processed: " << file_count
<< " out of " << files.size() << std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); cmCTestLog(m_CTest, HANDLER_OUTPUT, " ");
} }
} }
cmGeneratedFileStream covSumFile; cmGeneratedFileStream covSumFile;
cmGeneratedFileStream covLogFile; cmGeneratedFileStream covLogFile;
if (!this->StartResultingXML("Coverage", covSumFile)) if (!this->StartResultingXML("Coverage", covSumFile))
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open coverage summary file." << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open coverage summary file."
<< std::endl);
return -1; return -1;
} }
@ -550,7 +605,8 @@ int cmCTestCoverageHandler::ProcessHandler()
// Produce output xml files // Produce output xml files
covSumFile << "<Coverage>" << std::endl covSumFile << "<Coverage>" << std::endl
<< "\t<StartDateTime>" << coverage_start_time << "</StartDateTime>" << std::endl; << "\t<StartDateTime>" << coverage_start_time << "</StartDateTime>"
<< std::endl;
int logFileCount = 0; int logFileCount = 0;
if ( !this->StartCoverageLogFile(covLogFile, logFileCount) ) if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
{ {
@ -563,7 +619,8 @@ int cmCTestCoverageHandler::ProcessHandler()
//std::string fullSourceDir = sourceDir + "/"; //std::string fullSourceDir = sourceDir + "/";
//std::string fullBinaryDir = binaryDir + "/"; //std::string fullBinaryDir = binaryDir + "/";
cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Acumulating results (each . represents one file):" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT,
" Acumulating results (each . represents one file):" << std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); cmCTestLog(m_CTest, HANDLER_OUTPUT, " ");
std::vector<std::string> errorsWhileAccumulating; std::vector<std::string> errorsWhileAccumulating;
@ -577,7 +634,8 @@ int cmCTestCoverageHandler::ProcessHandler()
file_count ++; file_count ++;
if ( file_count % 50 == 0 ) if ( file_count % 50 == 0 )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " processed: " << file_count << " out of " cmCTestLog(m_CTest, HANDLER_OUTPUT, " processed: " << file_count
<< " out of "
<< totalCoverage.size() << std::endl); << totalCoverage.size() << std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); cmCTestLog(m_CTest, HANDLER_OUTPUT, " ");
} }
@ -591,15 +649,19 @@ int cmCTestCoverageHandler::ProcessHandler()
} }
} }
const std::string fullFileName = fileIterator->first; const std::string fullFileName = fileIterator->first;
const std::string fileName = cmSystemTools::GetFilenameName(fullFileName.c_str()); const std::string fileName
std::string fullFilePath = cmSystemTools::GetFilenamePath(fullFileName.c_str()); = cmSystemTools::GetFilenameName(fullFileName.c_str());
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Process file: " << fullFileName << std::endl); std::string fullFilePath
= cmSystemTools::GetFilenamePath(fullFileName.c_str());
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Process file: "
<< fullFileName << std::endl);
cmSystemTools::ConvertToUnixSlashes(fullFilePath); cmSystemTools::ConvertToUnixSlashes(fullFilePath);
if ( !cmSystemTools::FileExists(fullFileName.c_str()) ) if ( !cmSystemTools::FileExists(fullFileName.c_str()) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find file: " << fullFileName.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find file: "
<< fullFileName.c_str() << std::endl);
continue; continue;
} }
@ -608,7 +670,8 @@ int cmCTestCoverageHandler::ProcessHandler()
sourceDir.c_str(), binaryDir.c_str()); sourceDir.c_str(), binaryDir.c_str());
if ( !shouldIDoCoverage ) if ( !shouldIDoCoverage )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: " cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
".NoDartCoverage found, so skip coverage check for: "
<< fullFileName.c_str() << fullFileName.c_str()
<< std::endl); << std::endl);
continue; continue;
@ -641,12 +704,14 @@ int cmCTestCoverageHandler::ProcessHandler()
if ( !cmSystemTools::GetLineFromStream(ifs, line) ) if ( !cmSystemTools::GetLineFromStream(ifs, line) )
{ {
cmOStringStream ostr; cmOStringStream ostr;
ostr << "Problem reading source file: " << fullFileName.c_str() << " line:" << cc; ostr << "Problem reading source file: " << fullFileName.c_str()
<< " line:" << cc;
errorsWhileAccumulating.push_back(ostr.str()); errorsWhileAccumulating.push_back(ostr.str());
error ++; error ++;
break; break;
} }
covLogFile << "\t\t<Line Number=\"" << cc << "\" Count=\"" << fcov[cc] << "\">" covLogFile << "\t\t<Line Number=\"" << cc << "\" Count=\"" << fcov[cc]
<< "\">"
<< m_CTest->MakeXMLSafe(line.c_str()) << "</Line>" << std::endl; << m_CTest->MakeXMLSafe(line.c_str()) << "</Line>" << std::endl;
if ( fcov[cc] == 0 ) if ( fcov[cc] == 0 )
{ {
@ -698,7 +763,8 @@ int cmCTestCoverageHandler::ProcessHandler()
if ( errorsWhileAccumulating.size() > 0 ) if ( errorsWhileAccumulating.size() > 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, std::endl);
cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) while acumulating results:" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) while acumulating results:"
<< std::endl);
std::vector<std::string>::iterator erIt; std::vector<std::string>::iterator erIt;
for ( erIt = errorsWhileAccumulating.begin(); for ( erIt = errorsWhileAccumulating.begin();
erIt != errorsWhileAccumulating.end(); erIt != errorsWhileAccumulating.end();
@ -726,16 +792,17 @@ int cmCTestCoverageHandler::ProcessHandler()
covSumFile.precision(2); covSumFile.precision(2);
covSumFile << (percent_coverage)<< "</PercentCoverage>\n" covSumFile << (percent_coverage)<< "</PercentCoverage>\n"
<< "\t<EndDateTime>" << end_time << "</EndDateTime>\n"; << "\t<EndDateTime>" << end_time << "</EndDateTime>\n";
covSumFile << "<ElapsedMinutes>" << covSumFile << "<ElapsedMinutes>" <<
static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0 static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
<< "</ElapsedMinutes>" << "</ElapsedMinutes>"
<< "</Coverage>" << std::endl; << "</Coverage>" << std::endl;
m_CTest->EndXML(covSumFile); m_CTest->EndXML(covSumFile);
cmCTestLog(m_CTest, HANDLER_OUTPUT, "\tCovered LOC: " << total_tested << std::endl cmCTestLog(m_CTest, HANDLER_OUTPUT, "\tCovered LOC: "
<< total_tested << std::endl
<< "\tNot covered LOC: " << total_untested << std::endl << "\tNot covered LOC: " << total_untested << std::endl
<< "\tTotal LOC: " << total_lines << std::endl << "\tTotal LOC: " << total_lines << std::endl
<< "\tPercentage Coverage: " << "\tPercentage Coverage: "
<< std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::fixed)
<< std::setprecision(2) << std::setprecision(2)
<< (percent_coverage) << "%" << std::endl); << (percent_coverage) << "%" << std::endl);
@ -743,7 +810,7 @@ int cmCTestCoverageHandler::ProcessHandler()
ofs << "\tCovered LOC: " << total_tested << std::endl ofs << "\tCovered LOC: " << total_tested << std::endl
<< "\tNot covered LOC: " << total_untested << std::endl << "\tNot covered LOC: " << total_untested << std::endl
<< "\tTotal LOC: " << total_lines << std::endl << "\tTotal LOC: " << total_lines << std::endl
<< "\tPercentage Coverage: " << "\tPercentage Coverage: "
<< std::setiosflags(std::ios::fixed) << std::setiosflags(std::ios::fixed)
<< std::setprecision(2) << std::setprecision(2)
<< (percent_coverage) << "%" << std::endl; << (percent_coverage) << "%" << std::endl;
@ -760,14 +827,16 @@ int cmCTestCoverageHandler::ProcessHandler()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf)
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude regular expressions." << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE", " Add coverage exclude regular expressions." << std::endl);
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE",
m_CustomCoverageExclude); m_CustomCoverageExclude);
std::vector<cmStdString>::iterator it; std::vector<cmStdString>::iterator it;
for ( it = m_CustomCoverageExclude.begin(); for ( it = m_CustomCoverageExclude.begin();
it != m_CustomCoverageExclude.end(); it != m_CustomCoverageExclude.end();
++ it ) ++ it )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: " << it->c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: "
<< it->c_str() << std::endl);
} }
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -39,16 +39,16 @@ public:
* The main entry point for this class * The main entry point for this class
*/ */
int ProcessHandler(); int ProcessHandler();
cmCTestCoverageHandler(); cmCTestCoverageHandler();
virtual void Initialize(); virtual void Initialize();
/** /**
* This method is called when reading CTest custom file * This method is called when reading CTest custom file
*/ */
void PopulateCustomVectors(cmMakefile *mf); void PopulateCustomVectors(cmMakefile *mf);
private: private:
bool ShouldIDoCoverage(const char* file, const char* srcDir, bool ShouldIDoCoverage(const char* file, const char* srcDir,
const char* binDir); const char* binDir);

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -30,13 +30,14 @@ class cmCTestEmptyBinaryDirectoryCommand : public cmCTestCommand
public: public:
cmCTestEmptyBinaryDirectoryCommand() {} cmCTestEmptyBinaryDirectoryCommand() {}
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestEmptyBinaryDirectoryCommand* ni = new cmCTestEmptyBinaryDirectoryCommand; cmCTestEmptyBinaryDirectoryCommand* ni
= new cmCTestEmptyBinaryDirectoryCommand;
ni->m_CTest = this->m_CTest; ni->m_CTest = this->m_CTest;
ni->m_CTestScriptHandler = this->m_CTestScriptHandler; ni->m_CTestScriptHandler = this->m_CTestScriptHandler;
return ni; return ni;
@ -56,11 +57,11 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "empties the binary directory"; return "empties the binary directory";
} }
/** /**
* More documentation. * More documentation.
*/ */

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -41,7 +41,7 @@ void cmCTestGenericHandler::SetOption(const char* op, const char* value)
} }
if ( !value ) if ( !value )
{ {
cmCTestGenericHandler::t_StringToString::iterator remit cmCTestGenericHandler::t_StringToString::iterator remit
= m_Options.find(op); = m_Options.find(op);
if ( remit != m_Options.end() ) if ( remit != m_Options.end() )
{ {
@ -62,7 +62,7 @@ void cmCTestGenericHandler::Initialize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* cmCTestGenericHandler::GetOption(const char* op) const char* cmCTestGenericHandler::GetOption(const char* op)
{ {
cmCTestGenericHandler::t_StringToString::iterator remit cmCTestGenericHandler::t_StringToString::iterator remit
= m_Options.find(op); = m_Options.find(op);
if ( remit == m_Options.end() ) if ( remit == m_Options.end() )
{ {
@ -72,11 +72,14 @@ const char* cmCTestGenericHandler::GetOption(const char* op)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestGenericHandler::StartResultingXML(const char* name, cmGeneratedFileStream& xofs) bool cmCTestGenericHandler::StartResultingXML(const char* name,
cmGeneratedFileStream& xofs)
{ {
if ( !name ) if ( !name )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create resulting XML file without providing the name" << std::endl;); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot create resulting XML file without providing the name"
<< std::endl;);
return false; return false;
} }
cmOStringStream ostr; cmOStringStream ostr;
@ -86,9 +89,11 @@ bool cmCTestGenericHandler::StartResultingXML(const char* name, cmGeneratedFileS
ostr << "_" << m_SubmitIndex; ostr << "_" << m_SubmitIndex;
} }
ostr << ".xml"; ostr << ".xml";
if( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), ostr.str().c_str(), xofs, true) ) if( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), ostr.str().c_str(),
xofs, true) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create resulting XML file: " << ostr.str().c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create resulting XML file: "
<< ostr.str().c_str() << std::endl);
return false; return false;
} }
m_CTest->AddSubmitFile(ostr.str().c_str()); m_CTest->AddSubmitFile(ostr.str().c_str());
@ -96,11 +101,13 @@ bool cmCTestGenericHandler::StartResultingXML(const char* name, cmGeneratedFileS
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestGenericHandler::StartLogFile(const char* name, cmGeneratedFileStream& xofs) bool cmCTestGenericHandler::StartLogFile(const char* name,
cmGeneratedFileStream& xofs)
{ {
if ( !name ) if ( !name )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create log file without providing the name" << std::endl;); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot create log file without providing the name" << std::endl;);
return false; return false;
} }
cmOStringStream ostr; cmOStringStream ostr;
@ -116,7 +123,8 @@ bool cmCTestGenericHandler::StartLogFile(const char* name, cmGeneratedFileStream
ostr << ".log"; ostr << ".log";
if( !m_CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) ) if( !m_CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create log file: " << ostr.str().c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create log file: "
<< ostr.str().c_str() << std::endl);
return false; return false;
} }
return true; return true;

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -89,7 +89,7 @@ public:
protected: protected:
bool StartResultingXML(const char* name, cmGeneratedFileStream& xofs); bool StartResultingXML(const char* name, cmGeneratedFileStream& xofs);
bool StartLogFile(const char* name, cmGeneratedFileStream& xofs); bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
bool m_HandlerVerbose; bool m_HandlerVerbose;
cmCTest *m_CTest; cmCTest *m_CTest;
t_StringToString m_Options; t_StringToString m_Options;

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -38,7 +38,8 @@ cmCTestHandlerCommand::cmCTestHandlerCommand()
bool cmCTestHandlerCommand::InitialPass( bool cmCTestHandlerCommand::InitialPass(
std::vector<std::string> const& args) std::vector<std::string> const& args)
{ {
if ( !this->ProcessArguments(args, m_Last, &*m_Arguments.begin(), m_Values) ) if ( !this->ProcessArguments(args, m_Last, &*m_Arguments.begin(),
m_Values) )
{ {
return false; return false;
} }
@ -58,8 +59,11 @@ bool cmCTestHandlerCommand::InitialPass(
{ {
if ( m_CTest->GetDartVersion() <= 1 ) if ( m_CTest->GetDartVersion() <= 1 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Dart before version 2.0 does not support collecting submissions." << std::endl cmCTestLog(m_CTest, ERROR_MESSAGE,
<< "Please upgrade the server to Dart 2 or higher, or do not use SUBMIT_INDEX." << std::endl); "Dart before version 2.0 does not support collecting submissions."
<< std::endl
<< "Please upgrade the server to Dart 2 or higher, or do not use "
"SUBMIT_INDEX." << std::endl);
} }
else else
{ {
@ -69,7 +73,8 @@ bool cmCTestHandlerCommand::InitialPass(
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(m_CTest->GetCTestConfiguration("BuildDirectory").c_str()); cmSystemTools::ChangeDirectory(
m_CTest->GetCTestConfiguration("BuildDirectory").c_str());
int res = handler->ProcessHandler(); int res = handler->ProcessHandler();
if ( m_Values[ct_RETURN_VALUE] && *m_Values[ct_RETURN_VALUE]) if ( m_Values[ct_RETURN_VALUE] && *m_Values[ct_RETURN_VALUE])
{ {
@ -81,8 +86,9 @@ bool cmCTestHandlerCommand::InitialPass(
return true; return true;
} }
bool cmCTestHandlerCommand::ProcessArguments(std::vector<std::string> const& args, bool cmCTestHandlerCommand::ProcessArguments(
int last, const char** strings, std::vector<const char*>& values) std::vector<std::string> const& args, int last, const char** strings,
std::vector<const char*>& values)
{ {
int state = 0; int state = 0;
int cc; int cc;
@ -98,7 +104,8 @@ bool cmCTestHandlerCommand::ProcessArguments(std::vector<std::string> const& arg
{ {
values[state] = args[i].c_str(); values[state] = args[i].c_str();
#undef cerr #undef cerr
cmCTestLog(m_CTest, DEBUG, "Set " << strings[state] << " to " << args[i].c_str() << std::endl); cmCTestLog(m_CTest, DEBUG, "Set " << strings[state] << " to "
<< args[i].c_str() << std::endl);
state = 0; state = 0;
} }
else else
@ -112,7 +119,8 @@ bool cmCTestHandlerCommand::ProcessArguments(std::vector<std::string> const& arg
if ( values[state] ) if ( values[state] )
{ {
cmOStringStream ostr; cmOStringStream ostr;
ostr << "called with incorrect number of arguments. " << strings[state] << " specified twice."; ostr << "called with incorrect number of arguments. "
<< strings[state] << " specified twice.";
this->SetError(ostr.str().c_str()); this->SetError(ostr.str().c_str());
return false; return false;
} }
@ -123,7 +131,9 @@ bool cmCTestHandlerCommand::ProcessArguments(std::vector<std::string> const& arg
if ( !found ) if ( !found )
{ {
cmOStringStream str; cmOStringStream str;
str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; str
<< "called with incorrect number of arguments. Extra argument is: "
<< args[i].c_str() << ".";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -31,11 +31,11 @@ class cmCTestMemCheckCommand : public cmCTestTestCommand
public: public:
cmCTestMemCheckCommand() {} cmCTestMemCheckCommand() {}
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestMemCheckCommand* ni = new cmCTestMemCheckCommand; cmCTestMemCheckCommand* ni = new cmCTestMemCheckCommand;
ni->m_CTest = this->m_CTest; ni->m_CTest = this->m_CTest;
@ -51,11 +51,11 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Tests the repository."; return "Tests the repository.";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -64,8 +64,8 @@ public:
return return
" CTEST_MEMCHECK([BUILD build_dir] [RETURN_VALUE res])\n" " CTEST_MEMCHECK([BUILD build_dir] [RETURN_VALUE res])\n"
"Performs a memory checking of tests in the given build directory and " "Performs a memory checking of tests in the given build directory and "
"stores results in MemCheck.xml. The second argument is a variable that " "stores results in MemCheck.xml. The second argument is a variable "
"will hold value."; "that will hold value.";
} }
cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand); cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand);

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -25,7 +25,7 @@
#include <cmsys/Base64.h> #include <cmsys/Base64.h>
#include "cmMakefile.h" #include "cmMakefile.h"
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
@ -117,7 +117,8 @@ int cmCTestMemCheckHandler::PreProcessHandler()
if ( !this->ExecuteCommands(m_CustomPreMemCheck) ) if ( !this->ExecuteCommands(m_CustomPreMemCheck) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem executing pre-memcheck command(s)." << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Problem executing pre-memcheck command(s)." << std::endl);
return 0; return 0;
} }
return 1; return 1;
@ -128,14 +129,16 @@ int cmCTestMemCheckHandler::PostProcessHandler()
{ {
if ( !this->ExecuteCommands(m_CustomPostMemCheck) ) if ( !this->ExecuteCommands(m_CustomPostMemCheck) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem executing post-memcheck command(s)." << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Problem executing post-memcheck command(s)." << std::endl);
return 0; return 0;
} }
return 1; return 1;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestMemCheckHandler::GenerateTestCommand(std::vector<const char*>& args) void cmCTestMemCheckHandler::GenerateTestCommand(
std::vector<const char*>& args)
{ {
std::vector<cmStdString>::size_type pp; std::vector<cmStdString>::size_type pp;
args.push_back(m_MemoryTester.c_str()); args.push_back(m_MemoryTester.c_str());
@ -145,22 +148,24 @@ void cmCTestMemCheckHandler::GenerateTestCommand(std::vector<const char*>& args)
{ {
args.push_back(m_MemoryTesterOptionsParsed[pp].c_str()); args.push_back(m_MemoryTesterOptionsParsed[pp].c_str());
memcheckcommand += " "; memcheckcommand += " ";
memcheckcommand += cmSystemTools::EscapeSpaces(m_MemoryTesterOptionsParsed[pp].c_str()); memcheckcommand += cmSystemTools::EscapeSpaces(
m_MemoryTesterOptionsParsed[pp].c_str());
} }
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: " << memcheckcommand << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: "
<< memcheckcommand << std::endl);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf) void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf)
{ {
this->cmCTestTestHandler::PopulateCustomVectors(mf); this->cmCTestTestHandler::PopulateCustomVectors(mf);
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK",
m_CustomPreMemCheck); m_CustomPreMemCheck);
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK",
m_CustomPostMemCheck); m_CustomPostMemCheck);
cmCTest::PopulateCustomVector(mf, cmCTest::PopulateCustomVector(mf,
"CTEST_CUSTOM_MEMCHECK_IGNORE", "CTEST_CUSTOM_MEMCHECK_IGNORE",
m_CustomTestsIgnore); m_CustomTestsIgnore);
} }
@ -202,7 +207,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
<< "</Test>" << std::endl; << "</Test>" << std::endl;
} }
os << "\t</TestList>\n"; os << "\t</TestList>\n";
cmCTestLog(m_CTest, HANDLER_OUTPUT, "-- Processing memory checking output: "); cmCTestLog(m_CTest, HANDLER_OUTPUT,
"-- Processing memory checking output: ");
unsigned int total = m_TestResults.size(); unsigned int total = m_TestResults.size();
unsigned int step = total / 10; unsigned int step = total / 10;
unsigned int current = 0; unsigned int current = 0;
@ -212,7 +218,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
std::string memcheckstr; std::string memcheckstr;
int memcheckresults[cmCTestMemCheckHandler::NO_MEMORY_FAULT]; int memcheckresults[cmCTestMemCheckHandler::NO_MEMORY_FAULT];
int kk; int kk;
bool res = this->ProcessMemCheckOutput(result->m_Output, memcheckstr, memcheckresults); bool res = this->ProcessMemCheckOutput(result->m_Output, memcheckstr,
memcheckresults);
if ( res && result->m_Status == cmCTestMemCheckHandler::COMPLETED ) if ( res && result->m_Status == cmCTestMemCheckHandler::COMPLETED )
{ {
continue; continue;
@ -237,21 +244,22 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
m_CTest->GetShortPathToFile(result->m_Path.c_str())) << "</Path>\n" m_CTest->GetShortPathToFile(result->m_Path.c_str())) << "</Path>\n"
<< "\t\t<FullName>" << cmCTest::MakeXMLSafe( << "\t\t<FullName>" << cmCTest::MakeXMLSafe(
m_CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n" m_CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n"
<< "\t\t<FullCommandLine>" << "\t\t<FullCommandLine>"
<< cmCTest::MakeXMLSafe(result->m_FullCommandLine) << cmCTest::MakeXMLSafe(result->m_FullCommandLine)
<< "</FullCommandLine>\n" << "</FullCommandLine>\n"
<< "\t\t<Results>" << std::endl; << "\t\t<Results>" << std::endl;
for ( kk = 0; cmCTestMemCheckResultLongStrings[kk]; kk ++ ) for ( kk = 0; cmCTestMemCheckResultLongStrings[kk]; kk ++ )
{ {
if ( memcheckresults[kk] ) if ( memcheckresults[kk] )
{ {
os << "\t\t\t<Defect type=\"" << cmCTestMemCheckResultLongStrings[kk] << "\">" os << "\t\t\t<Defect type=\"" << cmCTestMemCheckResultLongStrings[kk]
<< memcheckresults[kk] << "\">"
<< memcheckresults[kk]
<< "</Defect>" << std::endl; << "</Defect>" << std::endl;
} }
m_MemoryTesterGlobalResults[kk] += memcheckresults[kk]; m_MemoryTesterGlobalResults[kk] += memcheckresults[kk];
} }
os os
<< "\t\t</Results>\n" << "\t\t</Results>\n"
<< "\t<Log>\n" << memcheckstr << std::endl << "\t<Log>\n" << memcheckstr << std::endl
<< "\t</Log>\n" << "\t</Log>\n"
@ -263,7 +271,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
} }
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, "Memory checking results:" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, "Memory checking results:"
<< std::endl);
os << "\t<DefectList>" << std::endl; os << "\t<DefectList>" << std::endl;
for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ )
{ {
@ -274,18 +283,20 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
#endif #endif
std::cerr.width(35); std::cerr.width(35);
#define cerr no_cerr #define cerr no_cerr
cmCTestLog(m_CTest, HANDLER_OUTPUT, cmCTestMemCheckResultLongStrings[cc] << " - " cmCTestLog(m_CTest, HANDLER_OUTPUT, cmCTestMemCheckResultLongStrings[cc]
<< " - "
<< m_MemoryTesterGlobalResults[cc] << std::endl); << m_MemoryTesterGlobalResults[cc] << std::endl);
os << "\t\t<Defect Type=\"" << cmCTestMemCheckResultLongStrings[cc] << "\"/>" << std::endl; os << "\t\t<Defect Type=\"" << cmCTestMemCheckResultLongStrings[cc]
<< "\"/>" << std::endl;
} }
} }
os << "\t</DefectList>" << std::endl; os << "\t</DefectList>" << std::endl;
os << "\t<EndDateTime>" << m_EndTest << "</EndDateTime>" << std::endl; os << "\t<EndDateTime>" << m_EndTest << "</EndDateTime>" << std::endl;
os << "<ElapsedMinutes>" os << "<ElapsedMinutes>"
<< static_cast<int>(m_ElapsedTestingTime/6)/10.0 << static_cast<int>(m_ElapsedTestingTime/6)/10.0
<< "</ElapsedMinutes>\n"; << "</ElapsedMinutes>\n";
os << "</DynamicAnalysis>" << std::endl; os << "</DynamicAnalysis>" << std::endl;
m_CTest->EndXML(os); m_CTest->EndXML(os);
@ -296,29 +307,37 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
bool cmCTestMemCheckHandler::InitializeMemoryChecking() bool cmCTestMemCheckHandler::InitializeMemoryChecking()
{ {
// Setup the command // Setup the command
if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("MemoryCheckCommand").c_str()) ) if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration(
"MemoryCheckCommand").c_str()) )
{ {
m_MemoryTester m_MemoryTester
= cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("MemoryCheckCommand").c_str()); = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration(
"MemoryCheckCommand").c_str());
} }
else if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("PurifyCommand").c_str()) ) else if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration(
"PurifyCommand").c_str()) )
{ {
m_MemoryTester m_MemoryTester
= cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("PurifyCommand").c_str()); = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration(
"PurifyCommand").c_str());
} }
else if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("ValgrindCommand").c_str()) ) else if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration(
"ValgrindCommand").c_str()) )
{ {
m_MemoryTester m_MemoryTester
= cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("ValgrindCommand").c_str()); = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration(
"ValgrindCommand").c_str());
} }
else else
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Memory checker (MemoryCheckCommand) not set, or cannot find the specified program." cmCTestLog(m_CTest, ERROR_MESSAGE, "Memory checker (MemoryCheckCommand) "
"not set, or cannot find the specified program."
<< std::endl); << std::endl);
return false; return false;
} }
if ( m_MemoryTester[0] == '\"' && m_MemoryTester[m_MemoryTester.size()-1] == '\"' ) if ( m_MemoryTester[0] == '\"' &&
m_MemoryTester[m_MemoryTester.size()-1] == '\"' )
{ {
m_MemoryTester = m_MemoryTester.substr(1, m_MemoryTester.size()-2); m_MemoryTester = m_MemoryTester.substr(1, m_MemoryTester.size()-2);
} }
@ -326,32 +345,42 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
// Setup the options // Setup the options
if ( m_CTest->GetCTestConfiguration("MemoryCheckCommandOptions").size() ) if ( m_CTest->GetCTestConfiguration("MemoryCheckCommandOptions").size() )
{ {
m_MemoryTesterOptions = m_CTest->GetCTestConfiguration("MemoryCheckCommandOptions"); m_MemoryTesterOptions = m_CTest->GetCTestConfiguration(
"MemoryCheckCommandOptions");
} }
else if ( m_CTest->GetCTestConfiguration("ValgrindCommandOptions").size() ) else if ( m_CTest->GetCTestConfiguration("ValgrindCommandOptions").size() )
{ {
m_MemoryTesterOptions = m_CTest->GetCTestConfiguration("ValgrindCommandOptions"); m_MemoryTesterOptions = m_CTest->GetCTestConfiguration(
"ValgrindCommandOptions");
} }
m_MemoryTesterOutputFile = m_CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; m_MemoryTesterOutputFile
m_MemoryTesterOutputFile = cmSystemTools::EscapeSpaces(m_MemoryTesterOutputFile.c_str()); = m_CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log";
m_MemoryTesterOutputFile
= cmSystemTools::EscapeSpaces(m_MemoryTesterOutputFile.c_str());
if ( m_MemoryTester.find("valgrind") != std::string::npos ) if ( m_MemoryTester.find("valgrind") != std::string::npos )
{ {
m_MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; m_MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
if ( !m_MemoryTesterOptions.size() ) if ( !m_MemoryTesterOptions.size() )
{ {
m_MemoryTesterOptions = "-q --tool=memcheck --leak-check=yes --show-reachable=yes --workaround-gcc296-bugs=yes --num-callers=100"; m_MemoryTesterOptions = "-q --tool=memcheck --leak-check=yes "
"--show-reachable=yes --workaround-gcc296-bugs=yes --num-callers=100";
} }
if ( m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").size() ) if ( m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").size() )
{ {
if ( !cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").c_str()) ) if ( !cmSystemTools::FileExists(m_CTest->GetCTestConfiguration(
"MemoryCheckSuppressionFile").c_str()) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find memory checker suppression file: " cmCTestLog(m_CTest, ERROR_MESSAGE,
<< m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").c_str() << std::endl); "Cannot find memory checker suppression file: "
<< m_CTest->GetCTestConfiguration(
"MemoryCheckSuppressionFile").c_str() << std::endl);
return false; return false;
} }
m_MemoryTesterOptions += " --suppressions=" + cmSystemTools::EscapeSpaces(m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").c_str()) + ""; m_MemoryTesterOptions += " --suppressions=" +
cmSystemTools::EscapeSpaces(m_CTest->GetCTestConfiguration(
"MemoryCheckSuppressionFile").c_str()) + "";
} }
} }
else if ( m_MemoryTester.find("purify") != std::string::npos ) else if ( m_MemoryTester.find("purify") != std::string::npos )
@ -366,16 +395,19 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
else if ( m_MemoryTester.find("boundschecker") != std::string::npos ) else if ( m_MemoryTester.find("boundschecker") != std::string::npos )
{ {
m_MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; m_MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
cmCTestLog(m_CTest, ERROR_MESSAGE, "Bounds checker not yet implemented" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Bounds checker not yet implemented"
<< std::endl);
return false; return false;
} }
else else
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Do not understand memory checker: " << m_MemoryTester.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Do not understand memory checker: "
<< m_MemoryTester.c_str() << std::endl);
return false; return false;
} }
m_MemoryTesterOptionsParsed = cmSystemTools::ParseArguments(m_MemoryTesterOptions.c_str()); m_MemoryTesterOptionsParsed
= cmSystemTools::ParseArguments(m_MemoryTesterOptions.c_str());
std::vector<cmStdString>::size_type cc; std::vector<cmStdString>::size_type cc;
for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ )
{ {
@ -385,7 +417,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str, bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str,
std::string& log, int* results) std::string& log, int* results)
{ {
std::string::size_type cc; std::string::size_type cc;
@ -420,7 +452,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str,
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
const std::string&, std::string& log, const std::string&, std::string& log,
int* results) int* results)
{ {
if ( !cmSystemTools::FileExists(m_MemoryTesterOutputFile.c_str()) ) if ( !cmSystemTools::FileExists(m_MemoryTesterOutputFile.c_str()) )
@ -462,8 +494,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
} }
if ( cc == cmCTestMemCheckHandler::NO_MEMORY_FAULT ) if ( cc == cmCTestMemCheckHandler::NO_MEMORY_FAULT )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown Purify memory fault: " << pfW.match(1) << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown Purify memory fault: "
ostr << "*** Unknown Purify memory fault: " << pfW.match(1) << std::endl; << pfW.match(1) << std::endl);
ostr << "*** Unknown Purify memory fault: " << pfW.match(1)
<< std::endl;
} }
} }
if ( failure != NO_MEMORY_FAULT ) if ( failure != NO_MEMORY_FAULT )
@ -485,12 +519,12 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
const std::string& str, std::string& log, const std::string& str, std::string& log,
int* results) int* results)
{ {
std::vector<cmStdString> lines; std::vector<cmStdString> lines;
cmSystemTools::Split(str.c_str(), lines); cmSystemTools::Split(str.c_str(), lines);
std::string::size_type cc; std::string::size_type cc;
cmOStringStream ostr; cmOStringStream ostr;
@ -517,13 +551,15 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
" in loss record [0-9][0-9]* of [0-9]"); " in loss record [0-9][0-9]* of [0-9]");
cmsys::RegularExpression vgUMC( cmsys::RegularExpression vgUMC(
"== .*Conditional jump or move depends on uninitialised value\\(s\\)"); "== .*Conditional jump or move depends on uninitialised value\\(s\\)");
cmsys::RegularExpression vgUMR1("== .*Use of uninitialised value of size [0-9][0-9]*"); cmsys::RegularExpression vgUMR1(
"== .*Use of uninitialised value of size [0-9][0-9]*");
cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9][0-9]*"); cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9][0-9]*");
cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address "); cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address ");
cmsys::RegularExpression vgUMR4( cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains "
"== .*Syscall param .* contains uninitialised or unaddressable byte\\(s\\)"); "uninitialised or unaddressable byte\\(s\\)");
cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9]"); cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9]");
cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is locked by a different thread"); cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
"locked by a different thread");
double sttime = cmSystemTools::GetTime(); double sttime = cmSystemTools::GetTime();
cmCTestLog(m_CTest, DEBUG, "Start test: " << lines.size() << std::endl); cmCTestLog(m_CTest, DEBUG, "Start test: " << lines.size() << std::endl);
@ -532,19 +568,58 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
if ( valgrindLine.find(lines[cc]) ) if ( valgrindLine.find(lines[cc]) )
{ {
int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT; int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
if ( vgFIM.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::FIM; } if ( vgFIM.find(lines[cc]) )
else if ( vgFMM.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::FMM; } {
else if ( vgMLK.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::MLK; } failure = cmCTestMemCheckHandler::FIM;
else if ( vgPAR.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::PAR; } }
else if ( vgMPK1.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::MPK; } else if ( vgFMM.find(lines[cc]) )
else if ( vgMPK2.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::MPK; } {
else if ( vgUMC.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::UMC; } failure = cmCTestMemCheckHandler::FMM;
else if ( vgUMR1.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::UMR; } }
else if ( vgUMR2.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::UMR; } else if ( vgMLK.find(lines[cc]) )
else if ( vgUMR3.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::UMR; } {
else if ( vgUMR4.find(lines[cc]) ){ failure = cmCTestMemCheckHandler::UMR; } failure = cmCTestMemCheckHandler::MLK;
else if ( vgIPW.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::IPW; } }
else if ( vgABR.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::ABR; } else if ( vgPAR.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::PAR;
}
else if ( vgMPK1.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::MPK;
}
else if ( vgMPK2.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::MPK;
}
else if ( vgUMC.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::UMC;
}
else if ( vgUMR1.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::UMR;
}
else if ( vgUMR2.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::UMR;
}
else if ( vgUMR3.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::UMR;
}
else if ( vgUMR4.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::UMR;
}
else if ( vgIPW.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::IPW;
}
else if ( vgABR.find(lines[cc]) )
{
failure = cmCTestMemCheckHandler::ABR;
}
if ( failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT ) if ( failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT )
{ {
@ -555,7 +630,8 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
ostr << cmCTest::MakeXMLSafe(lines[cc]) << std::endl; ostr << cmCTest::MakeXMLSafe(lines[cc]) << std::endl;
} }
} }
cmCTestLog(m_CTest, DEBUG, "End test (elapsed: " << (cmSystemTools::GetTime() - sttime) << std::endl); cmCTestLog(m_CTest, DEBUG, "End test (elapsed: "
<< (cmSystemTools::GetTime() - sttime) << std::endl);
log = ostr.str(); log = ostr.str();
if ( defects ) if ( defects )
{ {

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -18,7 +18,8 @@
#include "cmCTestScriptHandler.h" #include "cmCTestScriptHandler.h"
bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args) bool cmCTestRunScriptCommand::InitialPass(
std::vector<std::string> const& args)
{ {
if(args.size() < 1 ) if(args.size() < 1 )
{ {

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -33,7 +33,7 @@
#include "windows.h" #include "windows.h"
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
@ -67,13 +67,13 @@ public:
cmMakefile &mf); cmMakefile &mf);
//virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf); //virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
//virtual void ScopeEnded(cmMakefile &mf); //virtual void ScopeEnded(cmMakefile &mf);
cmCTestScriptHandler* m_CTestScriptHandler; cmCTestScriptHandler* m_CTestScriptHandler;
}; };
// simply update the time and don't block anything // simply update the time and don't block anything
bool cmCTestScriptFunctionBlocker:: bool cmCTestScriptFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& , cmMakefile &) IsFunctionBlocked(const cmListFileFunction& , cmMakefile &)
{ {
m_CTestScriptHandler->UpdateElapsedTime(); m_CTestScriptHandler->UpdateElapsedTime();
return false; return false;
@ -82,7 +82,7 @@ IsFunctionBlocked(const cmListFileFunction& , cmMakefile &)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCTestScriptHandler::cmCTestScriptHandler() cmCTestScriptHandler::cmCTestScriptHandler()
{ {
m_Backup = false; m_Backup = false;
m_EmptyBinDir = false; m_EmptyBinDir = false;
m_EmptyBinDirOnce = false; m_EmptyBinDirOnce = false;
m_Makefile = 0; m_Makefile = 0;
@ -91,7 +91,7 @@ cmCTestScriptHandler::cmCTestScriptHandler()
m_GlobalGenerator = 0; m_GlobalGenerator = 0;
m_ScriptStartTime = 0; m_ScriptStartTime = 0;
// the *60 is becuase the settings are in minutes but GetTime is seconds // the *60 is becuase the settings are in minutes but GetTime is seconds
m_MinimumInterval = 30*60; m_MinimumInterval = 30*60;
m_ContinuousDuration = -1; m_ContinuousDuration = -1;
@ -104,7 +104,7 @@ void cmCTestScriptHandler::Initialize()
m_Backup = false; m_Backup = false;
m_EmptyBinDir = false; m_EmptyBinDir = false;
m_EmptyBinDirOnce = false; m_EmptyBinDirOnce = false;
m_SourceDir = ""; m_SourceDir = "";
m_BinaryDir = ""; m_BinaryDir = "";
m_BackupSourceDir = ""; m_BackupSourceDir = "";
@ -124,7 +124,7 @@ void cmCTestScriptHandler::Initialize()
// what time in seconds did this script start running // what time in seconds did this script start running
m_ScriptStartTime = 0; m_ScriptStartTime = 0;
m_Makefile = 0; m_Makefile = 0;
if (m_LocalGenerator) if (m_LocalGenerator)
{ {
@ -232,7 +232,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
script = total_script_arg.substr(0,total_script_arg.find(",")); script = total_script_arg.substr(0,total_script_arg.find(","));
script_arg = total_script_arg.substr(total_script_arg.find(",")+1); script_arg = total_script_arg.substr(total_script_arg.find(",")+1);
} }
// make sure the file exists // make sure the file exists
if (!cmSystemTools::FileExists(script.c_str())) if (!cmSystemTools::FileExists(script.c_str()))
{ {
@ -256,7 +256,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
m_LocalGenerator = m_GlobalGenerator->CreateLocalGenerator(); m_LocalGenerator = m_GlobalGenerator->CreateLocalGenerator();
m_LocalGenerator->SetGlobalGenerator(m_GlobalGenerator); m_LocalGenerator->SetGlobalGenerator(m_GlobalGenerator);
m_Makefile = m_LocalGenerator->GetMakefile(); m_Makefile = m_LocalGenerator->GetMakefile();
// set a variable with the path to the current script // set a variable with the path to the current script
m_Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY", m_Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY",
cmSystemTools::GetFilenamePath(script).c_str()); cmSystemTools::GetFilenamePath(script).c_str());
@ -268,7 +268,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
m_CTest->GetCMakeExecutable()); m_CTest->GetCMakeExecutable());
m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true); m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true);
this->UpdateElapsedTime(); this->UpdateElapsedTime();
// add any ctest specific commands, probably should have common superclass // add any ctest specific commands, probably should have common superclass
// for ctest commands to clean this up. If a couple more commands are // for ctest commands to clean this up. If a couple more commands are
// created with the same format lets do that - ken // created with the same format lets do that - ken
@ -283,7 +283,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
this->AddCTestCommand(new cmCTestSubmitCommand); this->AddCTestCommand(new cmCTestSubmitCommand);
this->AddCTestCommand(new cmCTestTestCommand); this->AddCTestCommand(new cmCTestTestCommand);
this->AddCTestCommand(new cmCTestUpdateCommand); this->AddCTestCommand(new cmCTestUpdateCommand);
// add the script arg if defined // add the script arg if defined
if (script_arg.size()) if (script_arg.size())
{ {
@ -294,13 +294,13 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
cmCTestScriptFunctionBlocker *f = new cmCTestScriptFunctionBlocker(); cmCTestScriptFunctionBlocker *f = new cmCTestScriptFunctionBlocker();
f->m_CTestScriptHandler = this; f->m_CTestScriptHandler = this;
m_Makefile->AddFunctionBlocker(f); m_Makefile->AddFunctionBlocker(f);
// finally read in the script // finally read in the script
if (!m_Makefile->ReadListFile(0, script.c_str())) if (!m_Makefile->ReadListFile(0, script.c_str()))
{ {
return 2; return 2;
} }
return 0; return 0;
} }
@ -322,13 +322,16 @@ int cmCTestScriptHandler::ExtractVariables()
m_CTestEnv = m_Makefile->GetSafeDefinition("CTEST_ENVIRONMENT"); m_CTestEnv = m_Makefile->GetSafeDefinition("CTEST_ENVIRONMENT");
m_InitCache = m_Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE"); m_InitCache = m_Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE");
m_CMakeCmd = m_Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND"); m_CMakeCmd = m_Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND");
m_CMOutFile = m_Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME"); m_CMOutFile
= m_Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME");
m_Backup = m_Makefile->IsOn("CTEST_BACKUP_AND_RESTORE"); m_Backup = m_Makefile->IsOn("CTEST_BACKUP_AND_RESTORE");
m_EmptyBinDir = m_Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY"); m_EmptyBinDir = m_Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY");
m_EmptyBinDirOnce = m_Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE"); m_EmptyBinDirOnce
= m_Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE");
minInterval = m_Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL"); minInterval
= m_Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL");
contDuration = m_Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION"); contDuration = m_Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION");
char updateVar[40]; char updateVar[40];
@ -341,7 +344,8 @@ int cmCTestScriptHandler::ExtractVariables()
{ {
if ( m_CVSCmd.empty() ) if ( m_CVSCmd.empty() )
{ {
cmSystemTools::Error(updateVar, " specified without specifying CTEST_CVS_COMMAND."); cmSystemTools::Error(updateVar,
" specified without specifying CTEST_CVS_COMMAND.");
return 12; return 12;
} }
m_ExtraUpdates.push_back(updateVal); m_ExtraUpdates.push_back(updateVal);
@ -352,13 +356,13 @@ int cmCTestScriptHandler::ExtractVariables()
if (m_Backup && m_CVSCheckOut.empty()) if (m_Backup && m_CVSCheckOut.empty())
{ {
cmSystemTools::Error( cmSystemTools::Error(
"Backup was requested without specifying CTEST_CVS_CHECKOUT."); "Backup was requested without specifying CTEST_CVS_CHECKOUT.");
return 3; return 3;
} }
// make sure the required info is here // make sure the required info is here
if (this->m_SourceDir.empty() || if (this->m_SourceDir.empty() ||
this->m_BinaryDir.empty() || this->m_BinaryDir.empty() ||
this->m_CTestCmd.empty()) this->m_CTestCmd.empty())
{ {
std::string message = "CTEST_SOURCE_DIRECTORY = "; std::string message = "CTEST_SOURCE_DIRECTORY = ";
@ -372,7 +376,7 @@ int cmCTestScriptHandler::ExtractVariables()
message.c_str()); message.c_str());
return 4; return 4;
} }
// if the dashboard root isn't specified then we can compute it from the // if the dashboard root isn't specified then we can compute it from the
// m_SourceDir // m_SourceDir
if (m_CTestRoot.empty() ) if (m_CTestRoot.empty() )
@ -389,8 +393,8 @@ int cmCTestScriptHandler::ExtractVariables()
{ {
m_ContinuousDuration = 60.0 * atof(contDuration); m_ContinuousDuration = 60.0 * atof(contDuration);
} }
this->UpdateElapsedTime(); this->UpdateElapsedTime();
return 0; return 0;
@ -408,20 +412,21 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// run a specific script // run a specific script
int cmCTestScriptHandler::RunConfigurationScript(const std::string& total_script_arg) int cmCTestScriptHandler::RunConfigurationScript(
const std::string& total_script_arg)
{ {
int result; int result;
m_ScriptStartTime = m_ScriptStartTime =
cmSystemTools::GetTime(); cmSystemTools::GetTime();
// read in the script // read in the script
result = this->ReadInScript(total_script_arg); result = this->ReadInScript(total_script_arg);
if (result) if (result)
{ {
return result; return result;
} }
// only run the curent script if we should // only run the curent script if we should
if (m_Makefile && m_Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT")) if (m_Makefile && m_Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT"))
{ {
@ -440,14 +445,14 @@ int cmCTestScriptHandler::RunCurrentScript()
// no popup widows // no popup widows
cmSystemTools::SetRunCommandHideConsole(true); cmSystemTools::SetRunCommandHideConsole(true);
// extract the vars from the cache and store in ivars // extract the vars from the cache and store in ivars
result = this->ExtractVariables(); result = this->ExtractVariables();
if (result) if (result)
{ {
return result; return result;
} }
// set any environment variables // set any environment variables
if (!m_CTestEnv.empty()) if (!m_CTestEnv.empty())
{ {
@ -503,21 +508,22 @@ int cmCTestScriptHandler::CheckOutSourceDir()
std::string command; std::string command;
std::string output; std::string output;
int retVal; int retVal;
bool res; bool res;
if (!cmSystemTools::FileExists(m_SourceDir.c_str()) && if (!cmSystemTools::FileExists(m_SourceDir.c_str()) &&
!m_CVSCheckOut.empty()) !m_CVSCheckOut.empty())
{ {
// we must now checkout the src dir // we must now checkout the src dir
output = ""; output = "";
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << m_CVSCheckOut << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << m_CVSCheckOut
res = cmSystemTools::RunSingleCommand(m_CVSCheckOut.c_str(), &output, << std::endl);
res = cmSystemTools::RunSingleCommand(m_CVSCheckOut.c_str(), &output,
&retVal, m_CTestRoot.c_str(), &retVal, m_CTestRoot.c_str(),
m_HandlerVerbose, 0 /*m_TimeOut*/); m_HandlerVerbose, 0 /*m_TimeOut*/);
if (!res || retVal != 0) if (!res || retVal != 0)
{ {
cmSystemTools::Error("Unable to perform cvs checkout:\n", cmSystemTools::Error("Unable to perform cvs checkout:\n",
output.c_str()); output.c_str());
return 6; return 6;
} }
} }
@ -534,7 +540,7 @@ int cmCTestScriptHandler::BackupDirectories()
m_BackupSourceDir += "_CMakeBackup"; m_BackupSourceDir += "_CMakeBackup";
m_BackupBinaryDir = m_BinaryDir; m_BackupBinaryDir = m_BinaryDir;
m_BackupBinaryDir += "_CMakeBackup"; m_BackupBinaryDir += "_CMakeBackup";
// backup the binary and src directories if requested // backup the binary and src directories if requested
if (m_Backup) if (m_Backup)
{ {
@ -547,11 +553,11 @@ int cmCTestScriptHandler::BackupDirectories()
{ {
cmSystemTools::RemoveADirectory(m_BackupBinaryDir.c_str()); cmSystemTools::RemoveADirectory(m_BackupBinaryDir.c_str());
} }
// first rename the src and binary directories // first rename the src and binary directories
rename(m_SourceDir.c_str(), m_BackupSourceDir.c_str()); rename(m_SourceDir.c_str(), m_BackupSourceDir.c_str());
rename(m_BinaryDir.c_str(), m_BackupBinaryDir.c_str()); rename(m_BinaryDir.c_str(), m_BackupBinaryDir.c_str());
// we must now checkout the src dir // we must now checkout the src dir
retVal = this->CheckOutSourceDir(); retVal = this->CheckOutSourceDir();
if (retVal) if (retVal)
@ -571,7 +577,7 @@ int cmCTestScriptHandler::PerformExtraUpdates()
std::string command; std::string command;
std::string output; std::string output;
int retVal; int retVal;
bool res; bool res;
// do an initial cvs update as required // do an initial cvs update as required
command = m_CVSCmd; command = m_CVSCmd;
@ -587,13 +593,14 @@ int cmCTestScriptHandler::PerformExtraUpdates()
fullCommand += cvsArgs[1]; fullCommand += cvsArgs[1];
output = ""; output = "";
retVal = 0; retVal = 0;
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run CVS: " << fullCommand.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run CVS: "
res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, << fullCommand.c_str() << std::endl);
res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output,
&retVal, cvsArgs[0].c_str(), &retVal, cvsArgs[0].c_str(),
m_HandlerVerbose, 0 /*m_TimeOut*/); m_HandlerVerbose, 0 /*m_TimeOut*/);
if (!res || retVal != 0) if (!res || retVal != 0)
{ {
cmSystemTools::Error("Unable to perform extra cvs updates:\n", cmSystemTools::Error("Unable to perform extra cvs updates:\n",
output.c_str()); output.c_str());
return 0; return 0;
} }
@ -611,7 +618,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
std::string command; std::string command;
std::string output; std::string output;
int retVal; int retVal;
bool res; bool res;
// make sure the src directory is there, if it isn't then we might be able // make sure the src directory is there, if it isn't then we might be able
// to check it out from cvs // to check it out from cvs
@ -627,24 +634,25 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
{ {
return retVal; return retVal;
} }
// clear the binary directory? // clear the binary directory?
if (m_EmptyBinDir) if (m_EmptyBinDir)
{ {
if ( !cmCTestScriptHandler::EmptyBinaryDirectory(m_BinaryDir.c_str()) ) if ( !cmCTestScriptHandler::EmptyBinaryDirectory(m_BinaryDir.c_str()) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem removing the binary directory" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Problem removing the binary directory" << std::endl);
} }
} }
// make sure the binary directory exists if it isn't the srcdir // make sure the binary directory exists if it isn't the srcdir
if (!cmSystemTools::FileExists(m_BinaryDir.c_str()) && if (!cmSystemTools::FileExists(m_BinaryDir.c_str()) &&
m_SourceDir != m_BinaryDir) m_SourceDir != m_BinaryDir)
{ {
if (!cmSystemTools::MakeDirectory(m_BinaryDir.c_str())) if (!cmSystemTools::MakeDirectory(m_BinaryDir.c_str()))
{ {
cmSystemTools::Error("Unable to create the binary directory:\n", cmSystemTools::Error("Unable to create the binary directory:\n",
m_BinaryDir.c_str()); m_BinaryDir.c_str());
this->RestoreBackupDirectories(); this->RestoreBackupDirectories();
return 7; return 7;
} }
@ -658,10 +666,14 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
// make sure we have the required info // make sure we have the required info
if (m_CVSCheckOut.empty()) if (m_CVSCheckOut.empty())
{ {
cmSystemTools::Error("You have specified the source and binary directories to be the same (an in source build). You have also specified that the binary directory is to be erased. This means that the source will have to be checked out from CVS. But you have not specified CTEST_CVS_CHECKOUT"); cmSystemTools::Error("You have specified the source and binary "
"directories to be the same (an in source build). You have also "
"specified that the binary directory is to be erased. This means "
"that the source will have to be checked out from CVS. But you have "
"not specified CTEST_CVS_CHECKOUT");
return 8; return 8;
} }
// we must now checkout the src dir // we must now checkout the src dir
retVal = this->CheckOutSourceDir(); retVal = this->CheckOutSourceDir();
if (retVal) if (retVal)
@ -670,7 +682,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
return retVal; return retVal;
} }
} }
// backup the dirs if requested // backup the dirs if requested
retVal = this->PerformExtraUpdates(); retVal = this->PerformExtraUpdates();
if (retVal) if (retVal)
@ -710,8 +722,9 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
output = ""; output = "";
command += "\""; command += "\"";
retVal = 0; retVal = 0;
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " << command.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: "
res = cmSystemTools::RunSingleCommand(command.c_str(), &output, << command.c_str() << std::endl);
res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
&retVal, m_BinaryDir.c_str(), &retVal, m_BinaryDir.c_str(),
m_HandlerVerbose, 0 /*m_TimeOut*/); m_HandlerVerbose, 0 /*m_TimeOut*/);
@ -723,7 +736,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
cmakeOutputFile = m_BinaryDir + "/" + cmakeOutputFile; cmakeOutputFile = m_BinaryDir + "/" + cmakeOutputFile;
} }
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Write CMake output to file: " << cmakeOutputFile.c_str() cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
"Write CMake output to file: " << cmakeOutputFile.c_str()
<< std::endl); << std::endl);
cmGeneratedFileStream fout(cmakeOutputFile.c_str()); cmGeneratedFileStream fout(cmakeOutputFile.c_str());
if ( fout ) if ( fout )
@ -753,11 +767,12 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
command = ctestCommands[i]; command = ctestCommands[i];
output = ""; output = "";
retVal = 0; retVal = 0;
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " << command.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: "
res = cmSystemTools::RunSingleCommand(command.c_str(), &output, << command.c_str() << std::endl);
res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
&retVal, m_BinaryDir.c_str(), &retVal, m_BinaryDir.c_str(),
m_HandlerVerbose, 0 /*m_TimeOut*/); m_HandlerVerbose, 0 /*m_TimeOut*/);
// did something critical fail in ctest // did something critical fail in ctest
if (!res || cmakeFailed || if (!res || cmakeFailed ||
retVal & cmCTest::BUILD_ERRORS) retVal & cmCTest::BUILD_ERRORS)
@ -778,7 +793,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
return retVal * 100; return retVal * 100;
} }
} }
// if all was succesful, delete the backup dirs to free up disk space // if all was succesful, delete the backup dirs to free up disk space
if (m_Backup) if (m_Backup)
{ {
@ -786,7 +801,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
cmSystemTools::RemoveADirectory(m_BackupBinaryDir.c_str()); cmSystemTools::RemoveADirectory(m_BackupBinaryDir.c_str());
} }
return 0; return 0;
} }
@ -806,7 +821,7 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
{ {
cmSystemTools::RemoveADirectory(m_BinaryDir.c_str()); cmSystemTools::RemoveADirectory(m_BinaryDir.c_str());
} }
// rename the src and binary directories // rename the src and binary directories
rename(m_BackupSourceDir.c_str(), m_SourceDir.c_str()); rename(m_BackupSourceDir.c_str(), m_SourceDir.c_str());
rename(m_BackupBinaryDir.c_str(), m_BinaryDir.c_str()); rename(m_BackupBinaryDir.c_str(), m_BinaryDir.c_str());
} }
@ -829,7 +844,7 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname)
{ {
return false; return false;
} }
// try to avoid deleting directories that we shouldn't // try to avoid deleting directories that we shouldn't
std::string check = sname; std::string check = sname;
check += "/CMakeCache.txt"; check += "/CMakeCache.txt";

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -56,19 +56,22 @@ bool cmCTestStartCommand::InitialPass(
} }
if ( !src_dir ) if ( !src_dir )
{ {
this->SetError("source directory not specified. Specify source directory as an argument or set CTEST_SOURCE_DIRECTORY"); this->SetError("source directory not specified. Specify source directory "
"as an argument or set CTEST_SOURCE_DIRECTORY");
return false; return false;
} }
if ( !bld_dir) if ( !bld_dir)
{ {
this->SetError("binary directory not specified. Specify binary directory as an argument or set CTEST_BINARY_DIRECTORY"); this->SetError("binary directory not specified. Specify binary directory "
"as an argument or set CTEST_BINARY_DIRECTORY");
return false; return false;
} }
m_CTest->EmptyCTestConfiguration(); m_CTest->EmptyCTestConfiguration();
m_CTest->SetCTestConfiguration("SourceDirectory", src_dir); m_CTest->SetCTestConfiguration("SourceDirectory", src_dir);
m_CTest->SetCTestConfiguration("BuildDirectory", bld_dir); m_CTest->SetCTestConfiguration("BuildDirectory", bld_dir);
cmCTestLog(m_CTest, HANDLER_OUTPUT, "Run dashboard with model " << smodel << std::endl cmCTestLog(m_CTest, HANDLER_OUTPUT, "Run dashboard with model " << smodel
<< std::endl
<< " Source directory: " << src_dir << std::endl << " Source directory: " << src_dir << std::endl
<< " Build directory: " << bld_dir << std::endl); << " Build directory: " << bld_dir << std::endl);

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -29,11 +29,11 @@ class cmCTestStartCommand : public cmCTestCommand
public: public:
cmCTestStartCommand() {} cmCTestStartCommand() {}
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestStartCommand* ni = new cmCTestStartCommand; cmCTestStartCommand* ni = new cmCTestStartCommand;
ni->m_CTest = this->m_CTest; ni->m_CTest = this->m_CTest;
@ -55,11 +55,11 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Starts the testing for a given model"; return "Starts the testing for a given model";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -67,10 +67,10 @@ public:
{ {
return return
" CTEST_START(Model [source [binary]])\n" " CTEST_START(Model [source [binary]])\n"
"Starts the testing for a given model. The command should be called after " "Starts the testing for a given model. The command should be called "
"the binary directory is initialized. If the 'source' and 'binary' " "after the binary directory is initialized. If the 'source' and "
"directory are not specified, it reads the CTEST_SOURCE_DIRECTORY and " "'binary' directory are not specified, it reads the "
"CTEST_BINARY_DIRECTORY."; "CTEST_SOURCE_DIRECTORY and CTEST_BINARY_DIRECTORY.";
} }
cmTypeMacro(cmCTestStartCommand, cmCTestCommand); cmTypeMacro(cmCTestStartCommand, cmCTestCommand);

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -36,24 +36,30 @@ bool cmCTestSubmitCommand::InitialPass(
{ {
if ( res_var ) if ( res_var )
{ {
this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); this->SetError("called with incorrect number of arguments. "
"RETURN_VALUE specified twice.");
return false; return false;
} }
havereturn_variable = true; havereturn_variable = true;
} }
else else
{ {
cmOStringStream str; cmOStringStream str;
str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; str << "called with incorrect number of arguments. Extra argument is: "
<< args[i].c_str() << ".";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }
} }
const char* ctestDropMethod = m_Makefile->GetDefinition("CTEST_DROP_METHOD"); const char* ctestDropMethod
const char* ctestDropSite = m_Makefile->GetDefinition("CTEST_DROP_SITE"); = m_Makefile->GetDefinition("CTEST_DROP_METHOD");
const char* ctestDropLocation = m_Makefile->GetDefinition("CTEST_DROP_LOCATION"); const char* ctestDropSite
const char* ctestTriggerSite = m_Makefile->GetDefinition("CTEST_TRIGGER_SITE"); = m_Makefile->GetDefinition("CTEST_DROP_SITE");
const char* ctestDropLocation
= m_Makefile->GetDefinition("CTEST_DROP_LOCATION");
const char* ctestTriggerSite
= m_Makefile->GetDefinition("CTEST_TRIGGER_SITE");
if ( !ctestDropMethod ) if ( !ctestDropMethod )
{ {
@ -69,8 +75,10 @@ bool cmCTestSubmitCommand::InitialPass(
} }
if ( !ctestTriggerSite ) if ( !ctestTriggerSite )
{ {
ctestTriggerSite = "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi"; ctestTriggerSite
cmCTestLog(m_CTest, HANDLER_OUTPUT, "* Use default trigger site: " << ctestTriggerSite << std::endl;); = "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); m_CTest->SetCTestConfiguration("DropMethod", ctestDropMethod);
@ -78,18 +86,22 @@ bool cmCTestSubmitCommand::InitialPass(
m_CTest->SetCTestConfiguration("DropLocation", ctestDropLocation); m_CTest->SetCTestConfiguration("DropLocation", ctestDropLocation);
m_CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite); m_CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite);
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER"); m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD"); "DropSiteUser", "CTEST_DROP_SITE_USER");
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "ScpCommand", "CTEST_SCP_COMMAND"); m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
"DropSitePassword", "CTEST_DROP_SITE_PASSWORD");
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
"ScpCommand", "CTEST_SCP_COMMAND");
const char* notesFilesVariable = m_Makefile->GetDefinition("CTEST_NOTES_FILES"); const char* notesFilesVariable
= m_Makefile->GetDefinition("CTEST_NOTES_FILES");
if (notesFilesVariable) if (notesFilesVariable)
{ {
std::vector<std::string> notesFiles; std::vector<std::string> notesFiles;
std::vector<cmStdString> newNotesFiles; std::vector<cmStdString> newNotesFiles;
cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles); cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
std::vector<std::string>::iterator it; std::vector<std::string>::iterator it;
for ( it = notesFiles.begin(); for ( it = notesFiles.begin();
it != notesFiles.end(); it != notesFiles.end();
++ it ) ++ it )
{ {
@ -97,14 +109,15 @@ bool cmCTestSubmitCommand::InitialPass(
} }
m_CTest->GenerateNotesFile(newNotesFiles); m_CTest->GenerateNotesFile(newNotesFiles);
} }
const char* extraFilesVariable = m_Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES"); const char* extraFilesVariable
= m_Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
if (extraFilesVariable) if (extraFilesVariable)
{ {
std::vector<std::string> extraFiles; std::vector<std::string> extraFiles;
std::vector<cmStdString> newExtraFiles; std::vector<cmStdString> newExtraFiles;
cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles); cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
std::vector<std::string>::iterator it; std::vector<std::string>::iterator it;
for ( it = extraFiles.begin(); for ( it = extraFiles.begin();
it != extraFiles.end(); it != extraFiles.end();
++ it ) ++ it )
{ {

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -22,18 +22,19 @@
/** \class cmCTestSubmit /** \class cmCTestSubmit
* \brief Run a ctest script * \brief Run a ctest script
* *
* cmCTestSubmitCommand defineds the command to submit the test results for the project. * cmCTestSubmitCommand defineds the command to submit the test results for
* the project.
*/ */
class cmCTestSubmitCommand : public cmCTestCommand class cmCTestSubmitCommand : public cmCTestCommand
{ {
public: public:
cmCTestSubmitCommand() {} cmCTestSubmitCommand() {}
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestSubmitCommand* ni = new cmCTestSubmitCommand; cmCTestSubmitCommand* ni = new cmCTestSubmitCommand;
ni->m_CTest = this->m_CTest; ni->m_CTest = this->m_CTest;
@ -55,11 +56,11 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Submits the repository."; return "Submits the repository.";
} }
/** /**
* More documentation. * More documentation.
*/ */

View File

@ -9,8 +9,8 @@ Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -36,11 +36,13 @@ PURPOSE. See the above copyright notices for more information.
typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar; typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
static size_t static size_t
cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
void *data)
{ {
register int realsize = size * nmemb; register int realsize = size * nmemb;
cmCTestSubmitHandlerVectorOfChar *vec = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data); cmCTestSubmitHandlerVectorOfChar *vec
= static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
const char* chPtr = static_cast<char*>(ptr); const char* chPtr = static_cast<char*>(ptr);
vec->insert(vec->end(), chPtr, chPtr + realsize); vec->insert(vec->end(), chPtr, chPtr + realsize);
@ -48,9 +50,11 @@ cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, vo
} }
static size_t static size_t
cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr, size_t size, void *data) cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr,
size_t size, void *data)
{ {
cmCTestSubmitHandlerVectorOfChar *vec = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data); cmCTestSubmitHandlerVectorOfChar *vec
= static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
vec->insert(vec->end(), chPtr, chPtr + size); vec->insert(vec->end(), chPtr, chPtr + size);
return size; return size;
@ -80,9 +84,9 @@ void cmCTestSubmitHandler::Initialize()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
const std::set<cmStdString>& files, const std::set<cmStdString>& files,
const cmStdString& remoteprefix, const cmStdString& remoteprefix,
const cmStdString& url) const cmStdString& url)
{ {
CURL *curl; CURL *curl;
@ -98,12 +102,12 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
{ {
/* get a curl handle */ /* get a curl handle */
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) if(curl)
{ {
// Using proxy // Using proxy
if ( m_FTPProxyType > 0 ) if ( m_FTPProxyType > 0 )
{ {
curl_easy_setopt(curl, CURLOPT_PROXY, m_FTPProxy.c_str()); curl_easy_setopt(curl, CURLOPT_PROXY, m_FTPProxy.c_str());
switch (m_FTPProxyType) switch (m_FTPProxyType)
{ {
case 2: case 2:
@ -113,7 +117,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
break; break;
default: default:
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
} }
} }
@ -125,21 +129,24 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
{ {
local_file = localprefix + "/" + *file; local_file = localprefix + "/" + *file;
} }
cmStdString upload_as = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); cmStdString upload_as
= url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
struct stat st; struct stat st;
if ( ::stat(local_file.c_str(), &st) ) if ( ::stat(local_file.c_str(), &st) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: " << local_file.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: "
<< local_file.c_str() << std::endl);
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);
::curl_global_cleanup(); ::curl_global_cleanup();
return false; return false;
} }
ftpfile = ::fopen(local_file.c_str(), "rb"); ftpfile = ::fopen(local_file.c_str(), "rb");
*m_LogFile << "\tUpload file: " << local_file.c_str() << " to " *m_LogFile << "\tUpload file: " << local_file.c_str() << " to "
<< upload_as.c_str() << std::endl; << 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); << upload_as.c_str() << std::endl);
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
@ -151,14 +158,17 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
// and give the size of the upload (optional) // and give the size of the upload (optional)
::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(st.st_size)); ::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
static_cast<long>(st.st_size));
// and give curl the buffer for errors // and give curl the buffer for errors
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
// specify handler for output // specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */ /* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunk;
@ -172,42 +182,50 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
if ( chunk.size() > 0 ) if ( chunk.size() > 0 )
{ {
cmCTestLog(m_CTest, DEBUG, "CURL output: [" cmCTestLog(m_CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
} }
if ( chunkDebug.size() > 0 ) if ( chunkDebug.size() > 0 )
{ {
cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" cmCTestLog(m_CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
<< std::endl);
} }
fclose(ftpfile); fclose(ftpfile);
if ( res ) if ( res )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: "
cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); << local_file.c_str() << std::endl);
*m_LogFile << " 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 << " Error message was: " << error_buffer << std::endl
<< " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; << " Curl output was: "
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);
::curl_global_cleanup(); ::curl_global_cleanup();
return false; return false;
} }
// always cleanup // always cleanup
::curl_easy_cleanup(curl); ::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(); ::curl_global_cleanup();
return true; return true;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Uploading files is simpler // Uploading files is simpler
bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
const std::set<cmStdString>& files, const std::set<cmStdString>& files,
const cmStdString& remoteprefix, const cmStdString& remoteprefix,
const cmStdString& url) const cmStdString& url)
{ {
CURL *curl; CURL *curl;
@ -224,13 +242,13 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
{ {
/* get a curl handle */ /* get a curl handle */
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) if(curl)
{ {
// Using proxy // Using proxy
if ( m_HTTPProxyType > 0 ) if ( m_HTTPProxyType > 0 )
{ {
curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str()); curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str());
switch (m_HTTPProxyType) switch (m_HTTPProxyType)
{ {
case 2: case 2:
@ -261,7 +279,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
{ {
local_file = localprefix + "/" + *file; local_file = localprefix + "/" + *file;
} }
cmStdString remote_file = remoteprefix + cmSystemTools::GetFilenameName(*file); cmStdString remote_file
= remoteprefix + cmSystemTools::GetFilenameName(*file);
*m_LogFile << "\tUpload file: " << local_file.c_str() << " to " *m_LogFile << "\tUpload file: " << local_file.c_str() << " to "
<< remote_file.c_str() << std::endl; << remote_file.c_str() << std::endl;
@ -285,25 +304,27 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
sprintf(hexCh, "%%%02X", (int)c); sprintf(hexCh, "%%%02X", (int)c);
ofile.append(hexCh); ofile.append(hexCh);
break; break;
default: default:
ofile.append(hexCh); ofile.append(hexCh);
} }
} }
cmStdString upload_as cmStdString upload_as
= url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&")
+ "FileName=" + ofile; + "FileName=" + ofile;
struct stat st; struct stat st;
if ( ::stat(local_file.c_str(), &st) ) if ( ::stat(local_file.c_str(), &st) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: " << local_file.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: "
<< local_file.c_str() << std::endl);
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);
::curl_global_cleanup(); ::curl_global_cleanup();
return false; return false;
} }
ftpfile = ::fopen(local_file.c_str(), "rb"); 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); << upload_as.c_str() << " Size: " << st.st_size << std::endl);
@ -314,14 +335,17 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
// and give the size of the upload (optional) // and give the size of the upload (optional)
::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(st.st_size)); ::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
static_cast<long>(st.st_size));
// and give curl the buffer for errors // and give curl the buffer for errors
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
// specify handler for output // specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */ /* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunk;
@ -335,40 +359,49 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
if ( chunk.size() > 0 ) if ( chunk.size() > 0 )
{ {
cmCTestLog(m_CTest, DEBUG, "CURL output: [" cmCTestLog(m_CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
} }
if ( chunkDebug.size() > 0 ) if ( chunkDebug.size() > 0 )
{ {
cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" cmCTestLog(m_CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
<< std::endl);
} }
fclose(ftpfile); fclose(ftpfile);
if ( res ) if ( res )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: "
cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); << local_file.c_str() << std::endl);
*m_LogFile << " 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 << " Error message was: " << error_buffer << std::endl
<< " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; << " Curl output was: "
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);
::curl_global_cleanup(); ::curl_global_cleanup();
return false; return false;
} }
// always cleanup // always cleanup
::curl_easy_cleanup(curl); ::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(); ::curl_global_cleanup();
return true; return true;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<cmStdString>& files, bool cmCTestSubmitHandler::TriggerUsingHTTP(
const cmStdString& remoteprefix, const std::set<cmStdString>& files,
const cmStdString& remoteprefix,
const cmStdString& url) const cmStdString& url)
{ {
CURL *curl; CURL *curl;
@ -382,12 +415,12 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<cmStdString>& files,
{ {
/* get a curl handle */ /* get a curl handle */
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) if(curl)
{ {
// Using proxy // Using proxy
if ( m_HTTPProxyType > 0 ) if ( m_HTTPProxyType > 0 )
{ {
curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str()); curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str());
switch (m_HTTPProxyType) switch (m_HTTPProxyType)
{ {
case 2: case 2:
@ -397,7 +430,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<cmStdString>& files,
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
break; break;
default: default:
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
if (m_HTTPProxyAuth.size() > 0) if (m_HTTPProxyAuth.size() > 0)
{ {
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
@ -412,8 +445,10 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<cmStdString>& files,
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
// specify handler for output // specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */ /* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunk;
@ -421,7 +456,8 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<cmStdString>& files,
::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
cmStdString rfile = remoteprefix + cmSystemTools::GetFilenameName(*file); cmStdString rfile
= remoteprefix + cmSystemTools::GetFilenameName(*file);
cmStdString ofile = ""; cmStdString ofile = "";
cmStdString::iterator kk; cmStdString::iterator kk;
for ( kk = rfile.begin(); kk < rfile.end(); ++ kk) for ( kk = rfile.begin(); kk < rfile.end(); ++ kk)
@ -442,39 +478,47 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<cmStdString>& files,
sprintf(hexCh, "%%%02X", (int)c); sprintf(hexCh, "%%%02X", (int)c);
ofile.append(hexCh); ofile.append(hexCh);
break; break;
default: default:
ofile.append(hexCh); ofile.append(hexCh);
} }
} }
cmStdString turl cmStdString turl
= url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&")
+ "xmlfile=" + ofile; + "xmlfile=" + ofile;
*m_LogFile << "Trigger url: " << turl.c_str() << std::endl; *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()); curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
if ( curl_easy_perform(curl) ) if ( curl_easy_perform(curl) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when triggering: " << turl.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when triggering: "
cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); << turl.c_str() << std::endl);
*m_LogFile << "\tTrigerring failed with error: " << error_buffer << 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 << " Error message was: " << error_buffer << std::endl
<< " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; << " Curl output was: "
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: [" cmCTestLog(m_CTest, ERROR_MESSAGE, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);
::curl_global_cleanup(); ::curl_global_cleanup();
return false; return false;
} }
if ( chunk.size() > 0 ) if ( chunk.size() > 0 )
{ {
cmCTestLog(m_CTest, DEBUG, "CURL output: [" cmCTestLog(m_CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
} }
if ( chunkDebug.size() > 0 ) if ( chunkDebug.size() > 0 )
{ {
cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" cmCTestLog(m_CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size())
<< "]" << std::endl);
} }
// always cleanup // always cleanup
@ -482,17 +526,18 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<cmStdString>& files,
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl);
} }
} }
::curl_global_cleanup(); ::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; return true;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmCTestSubmitHandler::SubmitUsingSCP( bool cmCTestSubmitHandler::SubmitUsingSCP(
const cmStdString& scp_command, const cmStdString& scp_command,
const cmStdString& localprefix, const cmStdString& localprefix,
const std::set<cmStdString>& files, const std::set<cmStdString>& files,
const cmStdString& remoteprefix, const cmStdString& remoteprefix,
const cmStdString& url) const cmStdString& url)
{ {
if ( !scp_command.size() || !localprefix.size() || if ( !scp_command.size() || !localprefix.size() ||
@ -524,9 +569,10 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
argv[1] = lfname.c_str(); argv[1] = lfname.c_str();
std::string rfname = url + "/" + remoteprefix + *file; std::string rfname = url + "/" + remoteprefix + *file;
argv[2] = rfname.c_str(); argv[2] = rfname.c_str();
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \"" cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Execute \"" << argv[0]
<< "\" \"" << argv[1] << "\" \""
<< argv[2] << "\"" << std::endl); << argv[2] << "\"" << std::endl);
*m_LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \"" *m_LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
<< argv[2] << "\"" << std::endl; << argv[2] << "\"" << std::endl;
cmsysProcess_SetCommand(cp, &*argv.begin()); cmsysProcess_SetCommand(cp, &*argv.begin());
@ -536,7 +582,8 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
while(cmsysProcess_WaitForData(cp, &data, &length, 0)) while(cmsysProcess_WaitForData(cp, &data, &length, 0))
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length)); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
cmCTestLogWrite(data, length));
} }
cmsysProcess_WaitForExit(cp, 0); cmsysProcess_WaitForExit(cp, 0);
@ -548,7 +595,8 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
retVal = cmsysProcess_GetExitValue(cp); retVal = cmsysProcess_GetExitValue(cp);
if ( retVal != 0 ) if ( retVal != 0 )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "\tSCP returned: " << retVal << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "\tSCP returned: "
<< retVal << std::endl);
*m_LogFile << "\tSCP returned: " << retVal << std::endl; *m_LogFile << "\tSCP returned: " << retVal << std::endl;
problems ++; problems ++;
} }
@ -556,16 +604,18 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
else if(result == cmsysProcess_State_Exception) else if(result == cmsysProcess_State_Exception)
{ {
retVal = cmsysProcess_GetExitException(cp); retVal = cmsysProcess_GetExitException(cp);
cmCTestLog(m_CTest, ERROR_MESSAGE, "\tThere was an exception: " << retVal << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "\tThere was an exception: "
<< retVal << std::endl);
*m_LogFile << "\tThere was an exception: " << retVal << std::endl; *m_LogFile << "\tThere was an exception: " << retVal << std::endl;
problems ++; problems ++;
} }
else if(result == cmsysProcess_State_Expired) else if(result == cmsysProcess_State_Expired)
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "\tThere was a timeout" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "\tThere was a timeout"
<< std::endl);
*m_LogFile << "\tThere was a timeout" << std::endl; *m_LogFile << "\tThere was a timeout" << std::endl;
problems ++; problems ++;
} }
else if(result == cmsysProcess_State_Error) else if(result == cmsysProcess_State_Error)
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "\tError executing SCP: " cmCTestLog(m_CTest, ERROR_MESSAGE, "\tError executing SCP: "
@ -584,9 +634,9 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
const std::set<cmStdString>& files, const std::set<cmStdString>& files,
const cmStdString& remoteprefix, const cmStdString& remoteprefix,
const cmStdString& url) const cmStdString& url)
{ {
xmlrpc_env env; xmlrpc_env env;
@ -601,7 +651,8 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
xmlrpc_env_init(&env); xmlrpc_env_init(&env);
/* Call the famous server at UserLand. */ /* 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);
cmCTest::tm_SetOfStrings::const_iterator file; cmCTest::tm_SetOfStrings::const_iterator file;
for ( file = files.begin(); file != files.end(); ++file ) for ( file = files.begin(); file != files.end(); ++file )
{ {
@ -612,11 +663,13 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
{ {
local_file = localprefix + "/" + *file; local_file = localprefix + "/" + *file;
} }
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; struct stat st;
if ( ::stat(local_file.c_str(), &st) ) if ( ::stat(local_file.c_str(), &st) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: " << local_file.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot find file: "
<< local_file.c_str() << std::endl);
return false; return false;
} }
@ -624,7 +677,8 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
FILE* fp = fopen(local_file.c_str(), "rb"); FILE* fp = fopen(local_file.c_str(), "rb");
if ( !fp ) if ( !fp )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot open file: " << local_file.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot open file: "
<< local_file.c_str() << std::endl);
return false; return false;
} }
@ -633,7 +687,8 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
{ {
delete [] fileBuffer; delete [] fileBuffer;
fclose(fp); fclose(fp);
cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot read file: " << local_file.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Cannot read file: "
<< local_file.c_str() << std::endl);
return false; return false;
} }
fclose(fp); fclose(fp);
@ -647,7 +702,8 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
if ( env.fault_occurred ) if ( env.fault_occurred )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " Submission problem: " << env.fault_string << " (" << env.fault_code << ")" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Submission problem: "
<< env.fault_string << " (" << env.fault_code << ")" << std::endl);
xmlrpc_env_clean(&env); xmlrpc_env_clean(&env);
xmlrpc_client_cleanup(); xmlrpc_client_cleanup();
return false; return false;
@ -668,10 +724,13 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int cmCTestSubmitHandler::ProcessHandler() int cmCTestSubmitHandler::ProcessHandler()
{ {
const std::string &buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); const std::string &buildDirectory
= m_CTest->GetCTestConfiguration("BuildDirectory");
if ( buildDirectory.size() == 0 ) if ( buildDirectory.size() == 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
<< std::endl);
return -1; return -1;
} }
@ -742,11 +801,13 @@ int cmCTestSubmitHandler::ProcessHandler()
if ( m_HTTPProxy.size() > 0 ) 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 ) 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; cmGeneratedFileStream ofs;
this->StartLogFile("Submit", ofs); this->StartLogFile("Submit", ofs);
@ -762,17 +823,20 @@ int cmCTestSubmitHandler::ProcessHandler()
if ( m_CTest->AddIfExists(files, "Coverage.xml") ) if ( m_CTest->AddIfExists(files, "Coverage.xml") )
{ {
cmCTest::tm_VectorOfStrings gfiles; cmCTest::tm_VectorOfStrings gfiles;
std::string gpath = buildDirectory + "/Testing/" + m_CTest->GetCurrentTag(); std::string gpath
= buildDirectory + "/Testing/" + m_CTest->GetCurrentTag();
std::string::size_type glen = gpath.size() + 1; std::string::size_type glen = gpath.size() + 1;
gpath = gpath + "/CoverageLog*"; gpath = gpath + "/CoverageLog*";
cmCTestLog(m_CTest, DEBUG, "Globbing for: " << gpath.c_str() << std::endl); cmCTestLog(m_CTest, DEBUG, "Globbing for: " << gpath.c_str()
<< std::endl);
if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) ) if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) )
{ {
size_t cc; size_t cc;
for ( cc = 0; cc < gfiles.size(); cc ++ ) for ( cc = 0; cc < gfiles.size(); cc ++ )
{ {
gfiles[cc] = gfiles[cc].substr(glen); gfiles[cc] = gfiles[cc].substr(glen);
cmCTestLog(m_CTest, DEBUG, "Glob file: " << gfiles[cc].c_str() << std::endl); cmCTestLog(m_CTest, DEBUG, "Glob file: " << gfiles[cc].c_str()
<< std::endl);
files.insert(gfiles[cc]); files.insert(gfiles[cc]);
} }
} }
@ -803,60 +867,75 @@ int cmCTestSubmitHandler::ProcessHandler()
cnt ++; cnt ++;
} }
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, "Submit files (using " << m_CTest->GetCTestConfiguration("DropMethod") << ")" cmCTestLog(m_CTest, HANDLER_OUTPUT, "Submit files (using "
<< m_CTest->GetCTestConfiguration("DropMethod") << ")"
<< std::endl); << std::endl);
this->SetLogFile(&ofs); this->SetLogFile(&ofs);
if ( m_CTest->GetCTestConfiguration("DropMethod") == "" || if ( m_CTest->GetCTestConfiguration("DropMethod") == "" ||
m_CTest->GetCTestConfiguration("DropMethod") == "ftp" ) m_CTest->GetCTestConfiguration("DropMethod") == "ftp" )
{ {
ofs << "Using drop method: FTP" << std::endl; 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://"); << " Drop site: ftp://");
std::string url = "ftp://"; std::string url = "ftp://";
url += cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropSiteUser")) + ":" + url += cmCTest::MakeURLSafe(
cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropSitePassword")) + "@" + m_CTest->GetCTestConfiguration("DropSiteUser")) + ":" +
m_CTest->GetCTestConfiguration("DropSite") + cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration(
"DropSitePassword")) + "@" +
m_CTest->GetCTestConfiguration("DropSite") +
cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropLocation")); cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropLocation"));
if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration(
"DropSiteUser").c_str());
if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, ":******"); cmCTestLog(m_CTest, HANDLER_OUTPUT, ":******");
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, "@"); cmCTestLog(m_CTest, HANDLER_OUTPUT, "@");
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSite") cmCTestLog(m_CTest, HANDLER_OUTPUT,
m_CTest->GetCTestConfiguration("DropSite")
<< m_CTest->GetCTestConfiguration("DropLocation") << std::endl); << m_CTest->GetCTestConfiguration("DropLocation") << std::endl);
if ( !this->SubmitUsingFTP(buildDirectory+"/Testing/"+m_CTest->GetCurrentTag(), if ( !this->SubmitUsingFTP(buildDirectory + "/Testing/"
+ m_CTest->GetCurrentTag(),
files, prefix, url) ) files, prefix, url) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " 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; ofs << " Problems when submitting via FTP" << std::endl;
return -1; return -1;
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" << std::endl cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
<< " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") << std::endl); << std::endl
if ( !this->TriggerUsingHTTP(files, prefix, m_CTest->GetCTestConfiguration("TriggerSite")) ) << " 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); cmCTestLog(m_CTest, ERROR_MESSAGE,
" Problems when triggering via HTTP" << std::endl);
ofs << " Problems when triggering via HTTP" << std::endl; ofs << " Problems when triggering via HTTP" << std::endl;
return -1; return -1;
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful"
<< std::endl);
ofs << " Submission successful" << std::endl; ofs << " Submission successful" << std::endl;
return 0; return 0;
} }
else if ( m_CTest->GetCTestConfiguration("DropMethod") == "http" ) else if ( m_CTest->GetCTestConfiguration("DropMethod") == "http" )
{ {
ofs << "Using drop method: HTTP" << std::endl; 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://"); << " Drop site: http://");
std::string url = "http://"; std::string url = "http://";
if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
{ {
url += m_CTest->GetCTestConfiguration("DropSiteUser"); url += m_CTest->GetCTestConfiguration("DropSiteUser");
cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); cmCTestLog(m_CTest, HANDLER_OUTPUT,
m_CTest->GetCTestConfiguration("DropSiteUser").c_str());
if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
{ {
url += ":" + m_CTest->GetCTestConfiguration("DropSitePassword"); url += ":" + m_CTest->GetCTestConfiguration("DropSitePassword");
@ -865,40 +944,53 @@ int cmCTestSubmitHandler::ProcessHandler()
url += "@"; url += "@";
cmCTestLog(m_CTest, HANDLER_OUTPUT, "@"); cmCTestLog(m_CTest, HANDLER_OUTPUT, "@");
} }
url += m_CTest->GetCTestConfiguration("DropSite") + m_CTest->GetCTestConfiguration("DropLocation"); url += m_CTest->GetCTestConfiguration("DropSite") +
cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSite") m_CTest->GetCTestConfiguration("DropLocation");
cmCTestLog(m_CTest, HANDLER_OUTPUT,
m_CTest->GetCTestConfiguration("DropSite")
<< m_CTest->GetCTestConfiguration("DropLocation") << std::endl); << m_CTest->GetCTestConfiguration("DropLocation") << std::endl);
if ( !this->SubmitUsingHTTP(buildDirectory +"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) if ( !this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
m_CTest->GetCurrentTag(), files, prefix, url) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " 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; ofs << " Problems when submitting via HTTP" << std::endl;
return -1; return -1;
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" << std::endl cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
<< " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") << std::endl); << std::endl
if ( !this->TriggerUsingHTTP(files, prefix, m_CTest->GetCTestConfiguration("TriggerSite")) ) << " 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); cmCTestLog(m_CTest, ERROR_MESSAGE,
" Problems when triggering via HTTP" << std::endl);
ofs << " Problems when triggering via HTTP" << std::endl; ofs << " Problems when triggering via HTTP" << std::endl;
return -1; return -1;
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful"
<< std::endl);
ofs << " Submission successful" << std::endl; ofs << " Submission successful" << std::endl;
return 0; return 0;
} }
else if ( m_CTest->GetCTestConfiguration("DropMethod") == "xmlrpc" ) else if ( m_CTest->GetCTestConfiguration("DropMethod") == "xmlrpc" )
{ {
ofs << "Using drop method: XML-RPC" << std::endl; 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"); std::string url = m_CTest->GetCTestConfiguration("DropSite");
prefix = m_CTest->GetCTestConfiguration("DropLocation"); prefix = m_CTest->GetCTestConfiguration("DropLocation");
if ( !this->SubmitUsingXMLRPC(buildDirectory+"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) if ( !this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
m_CTest->GetCurrentTag(), files, prefix, url) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, " 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; ofs << " Problems when submitting via XML-RPC" << std::endl;
return -1; return -1;
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful"
<< std::endl);
ofs << " Submission successful" << std::endl; ofs << " Submission successful" << std::endl;
return 0; return 0;
} }
@ -910,7 +1002,8 @@ int cmCTestSubmitHandler::ProcessHandler()
{ {
url += m_CTest->GetCTestConfiguration("DropSiteUser") + "@"; url += m_CTest->GetCTestConfiguration("DropSiteUser") + "@";
} }
url += m_CTest->GetCTestConfiguration("DropSite") + ":" + m_CTest->GetCTestConfiguration("DropLocation"); url += m_CTest->GetCTestConfiguration("DropSite") + ":" +
m_CTest->GetCTestConfiguration("DropLocation");
// change to the build directory so that we can uses a relative path // change to the build directory so that we can uses a relative path
// on windows since scp dosn't support "c:" a drive in the path // on windows since scp dosn't support "c:" a drive in the path
@ -921,17 +1014,20 @@ int cmCTestSubmitHandler::ProcessHandler()
"Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) "Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) )
{ {
cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str());
cmCTestLog(m_CTest, ERROR_MESSAGE, " 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; ofs << " Problems when submitting via SCP" << std::endl;
return -1; return -1;
} }
cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str());
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful"
<< std::endl);
ofs << " Submission successful" << std::endl; ofs << " Submission successful" << std::endl;
return 0; return 0;
} }
cmCTestLog(m_CTest, ERROR_MESSAGE, " Unknown submission method: \"" << m_CTest->GetCTestConfiguration("DropMethod") << "\"" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Unknown submission method: \""
<< m_CTest->GetCTestConfiguration("DropMethod") << "\"" << std::endl);
return -1; return -1;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -63,7 +63,8 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
{ {
testsToRunString << m_Values[ctt_STRIDE]; testsToRunString << m_Values[ctt_STRIDE];
} }
handler->SetOption("TestsToRunInformation", testsToRunString.str().c_str()); handler->SetOption("TestsToRunInformation",
testsToRunString.str().c_str());
} }
return handler; return handler;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -29,7 +29,7 @@
#include "cmCommand.h" #include "cmCommand.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
@ -42,7 +42,7 @@ public:
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestSubdirCommand* c = new cmCTestSubdirCommand; cmCTestSubdirCommand* c = new cmCTestSubdirCommand;
c->m_TestHandler = m_TestHandler; c->m_TestHandler = m_TestHandler;
@ -78,14 +78,14 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args)
return false; return false;
} }
std::vector<std::string>::const_iterator it; std::vector<std::string>::const_iterator it;
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
for ( it = args.begin(); it != args.end(); ++ it ) for ( it = args.begin(); it != args.end(); ++ it )
{ {
cmSystemTools::ChangeDirectory(cwd.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str());
std::string fname = cwd; std::string fname = cwd;
fname += "/"; fname += "/";
fname += *it; fname += *it;
if ( !cmSystemTools::FileExists(fname.c_str()) ) if ( !cmSystemTools::FileExists(fname.c_str()) )
{ {
// No subdirectory? So what... // No subdirectory? So what...
@ -111,7 +111,8 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args)
} }
fname += "/"; fname += "/";
fname += testFilename; fname += testFilename;
bool readit = m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(), fname.c_str()); bool readit = m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(),
fname.c_str());
cmSystemTools::ChangeDirectory(cwd.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str());
if(!readit) if(!readit)
{ {
@ -131,7 +132,7 @@ public:
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestAddTestCommand* c = new cmCTestAddTestCommand; cmCTestAddTestCommand* c = new cmCTestAddTestCommand;
c->m_TestHandler = m_TestHandler; c->m_TestHandler = m_TestHandler;
@ -176,9 +177,10 @@ public:
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestSetTestsPropertiesCommand* c = new cmCTestSetTestsPropertiesCommand; cmCTestSetTestsPropertiesCommand* c
= new cmCTestSetTestsPropertiesCommand;
c->m_TestHandler = m_TestHandler; c->m_TestHandler = m_TestHandler;
return c; return c;
} }
@ -204,7 +206,8 @@ public:
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestSetTestsPropertiesCommand::InitialPass(std::vector<std::string> const& args) bool cmCTestSetTestsPropertiesCommand::InitialPass(
std::vector<std::string> const& args)
{ {
return m_TestHandler->SetTestsProperties(args); return m_TestHandler->SetTestsProperties(args);
} }
@ -224,15 +227,15 @@ bool TryExecutable(const char *dir, const char *file,
tryPath = dir; tryPath = dir;
tryPath += "/"; tryPath += "/";
} }
if (subdir && strcmp(subdir,"")) if (subdir && strcmp(subdir,""))
{ {
tryPath += subdir; tryPath += subdir;
tryPath += "/"; tryPath += "/";
} }
tryPath += file; tryPath += file;
// find the file without an executable extension // find the file without an executable extension
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))
{ {
@ -247,7 +250,7 @@ bool TryExecutable(const char *dir, const char *file,
*fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); *fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
return true; return true;
} }
// not found at all, return false // not found at all, return false
return false; return false;
} }
@ -255,9 +258,9 @@ bool TryExecutable(const char *dir, const char *file,
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// get the next number in a string with numbers separated by , // get the next number in a string with numbers separated by ,
// pos is the start of the search and pos2 is the end of the search // pos is the start of the search and pos2 is the end of the search
// pos becomes pos2 after a call to GetNextNumber. // pos becomes pos2 after a call to GetNextNumber.
// -1 is returned at the end of the list. // -1 is returned at the end of the list.
inline int GetNextNumber(std::string const& in, inline int GetNextNumber(std::string const& in,
int& val, int& val,
std::string::size_type& pos, std::string::size_type& pos,
std::string::size_type& pos2) std::string::size_type& pos2)
@ -293,9 +296,9 @@ inline int GetNextNumber(std::string const& in,
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// get the next number in a string with numbers separated by , // get the next number in a string with numbers separated by ,
// pos is the start of the search and pos2 is the end of the search // pos is the start of the search and pos2 is the end of the search
// pos becomes pos2 after a call to GetNextNumber. // pos becomes pos2 after a call to GetNextNumber.
// -1 is returned at the end of the list. // -1 is returned at the end of the list.
inline int GetNextRealNumber(std::string const& in, inline int GetNextRealNumber(std::string const& in,
double& val, double& val,
std::string::size_type& pos, std::string::size_type& pos,
std::string::size_type& pos2) std::string::size_type& pos2)
@ -328,19 +331,19 @@ inline int GetNextRealNumber(std::string const& in,
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCTestTestHandler::cmCTestTestHandler() cmCTestTestHandler::cmCTestTestHandler()
{ {
m_UseUnion = false; m_UseUnion = false;
m_UseIncludeRegExp = false; m_UseIncludeRegExp = false;
m_UseExcludeRegExp = false; m_UseExcludeRegExp = false;
m_UseExcludeRegExpFirst = false; m_UseExcludeRegExpFirst = false;
m_CustomMaximumPassedTestOutputSize = 1 * 1024; m_CustomMaximumPassedTestOutputSize = 1 * 1024;
m_CustomMaximumFailedTestOutputSize = 300 * 1024; m_CustomMaximumFailedTestOutputSize = 300 * 1024;
m_MemCheck = false; m_MemCheck = false;
m_LogFile = 0; m_LogFile = 0;
@ -382,18 +385,18 @@ void cmCTestTestHandler::Initialize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf) void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf)
{ {
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST",
m_CustomPreTest); m_CustomPreTest);
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST",
m_CustomPostTest); m_CustomPostTest);
cmCTest::PopulateCustomVector(mf, cmCTest::PopulateCustomVector(mf,
"CTEST_CUSTOM_TESTS_IGNORE", "CTEST_CUSTOM_TESTS_IGNORE",
m_CustomTestsIgnore); m_CustomTestsIgnore);
cmCTest::PopulateCustomInteger(mf, cmCTest::PopulateCustomInteger(mf,
"CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE", "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE",
m_CustomMaximumPassedTestOutputSize); m_CustomMaximumPassedTestOutputSize);
cmCTest::PopulateCustomInteger(mf, cmCTest::PopulateCustomInteger(mf,
"CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE", "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE",
m_CustomMaximumFailedTestOutputSize); m_CustomMaximumFailedTestOutputSize);
} }
@ -402,7 +405,8 @@ int cmCTestTestHandler::PreProcessHandler()
{ {
if ( !this->ExecuteCommands(m_CustomPreTest) ) if ( !this->ExecuteCommands(m_CustomPreTest) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem executing pre-test command(s)." << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Problem executing pre-test command(s)." << std::endl);
return 0; return 0;
} }
return 1; return 1;
@ -413,7 +417,8 @@ int cmCTestTestHandler::PostProcessHandler()
{ {
if ( !this->ExecuteCommands(m_CustomPostTest) ) if ( !this->ExecuteCommands(m_CustomPostTest) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem executing post-test command(s)." << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Problem executing post-test command(s)." << std::endl);
return 0; return 0;
} }
return 1; return 1;
@ -443,7 +448,8 @@ int cmCTestTestHandler::ProcessHandler()
m_TestResults.clear(); m_TestResults.clear();
cmCTestLog(m_CTest, HANDLER_OUTPUT, (m_MemCheck ? "Memory check" : "Test") << " project" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, (m_MemCheck ? "Memory check" : "Test")
<< " project" << std::endl);
if ( ! this->PreProcessHandler() ) if ( ! this->PreProcessHandler() )
{ {
return -1; return -1;
@ -465,18 +471,20 @@ int cmCTestTestHandler::ProcessHandler()
{ {
if ( !m_CTest->GetShowOnly() ) if ( !m_CTest->GetShowOnly() )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "No tests were found!!!" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "No tests were found!!!"
<< std::endl);
} }
} }
else else
{ {
if (m_HandlerVerbose && passed.size() && if (m_HandlerVerbose && passed.size() &&
(m_UseIncludeRegExp || m_UseExcludeRegExp)) (m_UseIncludeRegExp || m_UseExcludeRegExp))
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl << "The following tests passed:" << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl
<< "The following tests passed:" << std::endl);
for(std::vector<cmStdString>::iterator j = passed.begin(); for(std::vector<cmStdString>::iterator j = passed.begin();
j != passed.end(); ++j) j != passed.end(); ++j)
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j << std::endl);
} }
} }
@ -486,16 +494,18 @@ int cmCTestTestHandler::ProcessHandler()
{ {
percent = 99; percent = 99;
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl << static_cast<int>(percent + .5) << "% tests passed, " cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl
<< static_cast<int>(percent + .5) << "% tests passed, "
<< failed.size() << " tests failed out of " << total << std::endl); << failed.size() << " tests failed out of " << total << std::endl);
//fprintf(stderr,"\n%.0f%% tests passed, %i tests failed out of %i\n", //fprintf(stderr,"\n%.0f%% tests passed, %i tests failed out of %i\n",
// percent, int(failed.size()), total); // percent, int(failed.size()), total);
if (failed.size()) if (failed.size())
{ {
cmGeneratedFileStream ofs; cmGeneratedFileStream ofs;
cmCTestLog(m_CTest, ERROR_MESSAGE, std::endl << "The following tests FAILED:" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, std::endl
<< "The following tests FAILED:" << std::endl);
this->StartLogFile("TestsFailed", ofs); this->StartLogFile("TestsFailed", ofs);
std::vector<cmCTestTestHandler::cmCTestTestResult>::iterator ftit; std::vector<cmCTestTestHandler::cmCTestTestResult>::iterator ftit;
@ -505,9 +515,9 @@ int cmCTestTestHandler::ProcessHandler()
if ( ftit->m_Status != cmCTestTestHandler::COMPLETED ) if ( ftit->m_Status != cmCTestTestHandler::COMPLETED )
{ {
ofs << ftit->m_TestCount << ":" << ftit->m_Name << std::endl; ofs << ftit->m_TestCount << ":" << ftit->m_Name << std::endl;
cmCTestLog(m_CTest, HANDLER_OUTPUT, "\t" << std::setw(3) << ftit->m_TestCount << " - " << ftit->m_Name.c_str() << " (" << this->GetTestStatus(ftit->m_Status) << ")" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, "\t" << std::setw(3)
//fprintf(stderr, "\t%3d - %s (%s)\n", ftit->m_TestCount, ftit->m_Name.c_str(), << ftit->m_TestCount << " - " << ftit->m_Name.c_str() << " ("
// this->GetTestStatus(ftit->m_Status)); << this->GetTestStatus(ftit->m_Status) << ")" << std::endl);
} }
} }
@ -517,9 +527,11 @@ int cmCTestTestHandler::ProcessHandler()
if ( m_CTest->GetProduceXML() ) if ( m_CTest->GetProduceXML() )
{ {
cmGeneratedFileStream xmlfile; cmGeneratedFileStream xmlfile;
if( !this->StartResultingXML((m_MemCheck ? "DynamicAnalysis" : "Test"), xmlfile) ) if( !this->StartResultingXML((m_MemCheck ? "DynamicAnalysis" : "Test"),
xmlfile) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create " << (m_MemCheck ? "memory check" : "testing") cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create "
<< (m_MemCheck ? "memory check" : "testing")
<< " XML file" << std::endl); << " XML file" << std::endl);
m_LogFile = 0; m_LogFile = 0;
return 1; return 1;
@ -543,7 +555,7 @@ int cmCTestTestHandler::ProcessHandler()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
std::vector<cmStdString> &failed) std::vector<cmStdString> &failed)
{ {
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
@ -578,7 +590,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
{ {
this->ExpandTestsToRunInformation(inREcnt); this->ExpandTestsToRunInformation(inREcnt);
} }
int cnt = 0; int cnt = 0;
inREcnt = 0; inREcnt = 0;
std::string last_directory = ""; std::string last_directory = "";
@ -599,7 +611,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
if (!(last_directory == it->m_Directory)) if (!(last_directory == it->m_Directory))
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Changing directory into " cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Changing directory into "
<< it->m_Directory.c_str() << "\n"); << it->m_Directory.c_str() << "\n");
*m_LogFile << "Changing directory into: " << it->m_Directory.c_str() *m_LogFile << "Changing directory into: " << it->m_Directory.c_str()
<< std::endl; << std::endl;
@ -608,12 +620,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
} }
cres.m_Name = testname; cres.m_Name = testname;
cres.m_Path = it->m_Directory.c_str(); cres.m_Path = it->m_Directory.c_str();
if (m_UseUnion) if (m_UseUnion)
{ {
// if it is not in the list and not in the regexp then skip // if it is not in the list and not in the regexp then skip
if ((m_TestsToRun.size() && if ((m_TestsToRun.size() &&
std::find(m_TestsToRun.begin(), m_TestsToRun.end(), cnt) std::find(m_TestsToRun.begin(), m_TestsToRun.end(), cnt)
== m_TestsToRun.end()) && !it->m_IsInBasedOnREOptions) == m_TestsToRun.end()) && !it->m_IsInBasedOnREOptions)
{ {
continue; continue;
@ -622,8 +634,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
else else
{ {
// is this test in the list of tests to run? If not then skip it // is this test in the list of tests to run? If not then skip it
if ((m_TestsToRun.size() && if ((m_TestsToRun.size() &&
std::find(m_TestsToRun.begin(), m_TestsToRun.end(), inREcnt) std::find(m_TestsToRun.begin(), m_TestsToRun.end(), inREcnt)
== m_TestsToRun.end()) || !it->m_IsInBasedOnREOptions) == m_TestsToRun.end()) || !it->m_IsInBasedOnREOptions)
{ {
continue; continue;
@ -654,11 +666,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, outname.c_str()); cmCTestLog(m_CTest, HANDLER_OUTPUT, outname.c_str());
} }
cmCTestLog(m_CTest, DEBUG, "Testing " << args[0].c_str() << " ... "); cmCTestLog(m_CTest, DEBUG, "Testing " << args[0].c_str() << " ... ");
// find the test executable // find the test executable
std::string actualCommand = this->FindTheExecutable(args[1].c_str()); std::string actualCommand = this->FindTheExecutable(args[1].c_str());
std::string testCommand = cmSystemTools::ConvertToOutputPath(actualCommand.c_str()); std::string testCommand
= cmSystemTools::ConvertToOutputPath(actualCommand.c_str());
// continue if we did not find the executable // continue if we did not find the executable
if (testCommand == "") if (testCommand == "")
@ -670,7 +683,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
if ( !m_CTest->GetShowOnly() ) if ( !m_CTest->GetShowOnly() )
{ {
cres.m_FullCommandLine = actualCommand; cres.m_FullCommandLine = actualCommand;
m_TestResults.push_back( cres ); m_TestResults.push_back( cres );
failed.push_back(testname); failed.push_back(testname);
continue; continue;
} }
@ -698,8 +711,10 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
int retVal = 0; int retVal = 0;
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl << (m_MemCheck?"MemCheck":"Test") << " command: " << testCommand << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl
*m_LogFile << cnt << "/" << tmsize << (m_MemCheck?"MemCheck":"Test") << " command: " << testCommand
<< std::endl);
*m_LogFile << cnt << "/" << tmsize
<< " Test: " << testname.c_str() << std::endl; << " Test: " << testname.c_str() << std::endl;
*m_LogFile << "Command: "; *m_LogFile << "Command: ";
std::vector<cmStdString>::size_type ll; std::vector<cmStdString>::size_type ll;
@ -707,12 +722,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
{ {
*m_LogFile << "\"" << arguments[ll] << "\" "; *m_LogFile << "\"" << arguments[ll] << "\" ";
} }
*m_LogFile *m_LogFile
<< std::endl << std::endl
<< "Directory: " << it->m_Directory << std::endl << "Directory: " << it->m_Directory << std::endl
<< "\"" << testname.c_str() << "\" start time: " << "\"" << testname.c_str() << "\" start time: "
<< m_CTest->CurrentTime() << std::endl << m_CTest->CurrentTime() << std::endl
<< "Output:" << std::endl << "Output:" << std::endl
<< "----------------------------------------------------------" << "----------------------------------------------------------"
<< std::endl; << std::endl;
int res = 0; int res = 0;
@ -734,12 +749,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
int seconds = static_cast<int>(ttime) % 60; int seconds = static_cast<int>(ttime) % 60;
char buffer[100]; char buffer[100];
sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds); sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds);
*m_LogFile *m_LogFile
<< "----------------------------------------------------------" << "----------------------------------------------------------"
<< std::endl << std::endl
<< "\"" << testname.c_str() << "\" end time: " << "\"" << testname.c_str() << "\" end time: "
<< m_CTest->CurrentTime() << std::endl << m_CTest->CurrentTime() << std::endl
<< "\"" << testname.c_str() << "\" time elapsed: " << "\"" << testname.c_str() << "\" time elapsed: "
<< buffer << std::endl << buffer << std::endl
<< "----------------------------------------------------------" << "----------------------------------------------------------"
<< std::endl << std::endl; << std::endl << std::endl;
@ -783,8 +798,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
} }
} }
if (res == cmsysProcess_State_Exited && if (res == cmsysProcess_State_Exited &&
(retVal == 0 || it->m_RequiredRegularExpressions.size()) && (retVal == 0 || it->m_RequiredRegularExpressions.size()) &&
!forceFail) !forceFail)
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Passed"); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Passed");
@ -839,7 +854,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
} }
else if ( res == cmsysProcess_State_Error ) else if ( res == cmsysProcess_State_Error )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, "***Bad command " << res << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, "***Bad command " << res
<< std::endl);
cres.m_Status = cmCTestTestHandler::BAD_COMMAND; cres.m_Status = cmCTestTestHandler::BAD_COMMAND;
} }
else else
@ -869,18 +885,21 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
{ {
std::string dartString = m_DartStuff.match(1); std::string dartString = m_DartStuff.match(1);
cmSystemTools::ReplaceString(output, dartString.c_str(),""); cmSystemTools::ReplaceString(output, dartString.c_str(),"");
cres.m_RegressionImages = this->GenerateRegressionImages(dartString); cres.m_RegressionImages
= this->GenerateRegressionImages(dartString);
} }
} }
} }
if ( cres.m_Status == cmCTestTestHandler::COMPLETED ) if ( cres.m_Status == cmCTestTestHandler::COMPLETED )
{ {
this->CleanTestOutput(output, static_cast<size_t>(m_CustomMaximumPassedTestOutputSize)); this->CleanTestOutput(output, static_cast<size_t>(
m_CustomMaximumPassedTestOutputSize));
} }
else else
{ {
this->CleanTestOutput(output, static_cast<size_t>(m_CustomMaximumFailedTestOutputSize)); this->CleanTestOutput(output, static_cast<size_t>(
m_CustomMaximumFailedTestOutputSize));
} }
cres.m_Output = output; cres.m_Output = output;
@ -948,29 +967,34 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
m_CTest->GetShortPathToFile(result->m_Path.c_str())) << "</Path>\n" m_CTest->GetShortPathToFile(result->m_Path.c_str())) << "</Path>\n"
<< "\t\t<FullName>" << cmCTest::MakeXMLSafe( << "\t\t<FullName>" << cmCTest::MakeXMLSafe(
m_CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n" m_CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n"
<< "\t\t<FullCommandLine>" << "\t\t<FullCommandLine>"
<< cmCTest::MakeXMLSafe(result->m_FullCommandLine) << cmCTest::MakeXMLSafe(result->m_FullCommandLine)
<< "</FullCommandLine>\n" << "</FullCommandLine>\n"
<< "\t\t<Results>" << std::endl; << "\t\t<Results>" << std::endl;
if ( result->m_Status != cmCTestTestHandler::NOT_RUN ) if ( result->m_Status != cmCTestTestHandler::NOT_RUN )
{ {
if ( result->m_Status != cmCTestTestHandler::COMPLETED || result->m_ReturnValue ) if ( result->m_Status != cmCTestTestHandler::COMPLETED ||
result->m_ReturnValue )
{ {
os << "\t\t\t<NamedMeasurement type=\"text/string\" name=\"Exit Code\"><Value>" os << "\t\t\t<NamedMeasurement type=\"text/string\" "
<< this->GetTestStatus(result->m_Status) << "</Value></NamedMeasurement>\n" "name=\"Exit Code\"><Value>"
<< "\t\t\t<NamedMeasurement type=\"text/string\" name=\"Exit Value\"><Value>" << this->GetTestStatus(result->m_Status) << "</Value>"
<< result->m_ReturnValue << "</Value></NamedMeasurement>" << std::endl; "</NamedMeasurement>\n"
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
"name=\"Exit Value\"><Value>"
<< result->m_ReturnValue << "</Value></NamedMeasurement>"
<< std::endl;
} }
os << result->m_RegressionImages; os << result->m_RegressionImages;
os << "\t\t\t<NamedMeasurement type=\"numeric/double\" " os << "\t\t\t<NamedMeasurement type=\"numeric/double\" "
<< "name=\"Execution Time\"><Value>" << "name=\"Execution Time\"><Value>"
<< result->m_ExecutionTime << "</Value></NamedMeasurement>\n"; << result->m_ExecutionTime << "</Value></NamedMeasurement>\n";
os os
<< "\t\t\t<NamedMeasurement type=\"text/string\" " << "\t\t\t<NamedMeasurement type=\"text/string\" "
<< "name=\"Completion Status\"><Value>" << "name=\"Completion Status\"><Value>"
<< result->m_CompletionStatus << "</Value></NamedMeasurement>\n"; << result->m_CompletionStatus << "</Value></NamedMeasurement>\n";
} }
os os
<< "\t\t\t<Measurement>\n" << "\t\t\t<Measurement>\n"
<< "\t\t\t\t<Value>"; << "\t\t\t\t<Value>";
os << cmCTest::MakeXMLSafe(result->m_Output); os << cmCTest::MakeXMLSafe(result->m_Output);
@ -982,7 +1006,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
} }
os << "\t<EndDateTime>" << m_EndTest << "</EndDateTime>\n" os << "\t<EndDateTime>" << m_EndTest << "</EndDateTime>\n"
<< "<ElapsedMinutes>" << "<ElapsedMinutes>"
<< static_cast<int>(m_ElapsedTestingTime/6)/10.0 << static_cast<int>(m_ElapsedTestingTime/6)/10.0
<< "</ElapsedMinutes>" << "</ElapsedMinutes>"
<< "</Testing>" << std::endl; << "</Testing>" << std::endl;
@ -996,11 +1020,13 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec)
for ( it = vec.begin(); it != vec.end(); ++it ) for ( it = vec.begin(); it != vec.end(); ++it )
{ {
int retVal = 0; int retVal = 0;
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it
if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, true /*m_Verbose*/) || << std::endl);
retVal != 0 ) if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, true
/*m_Verbose*/) || retVal != 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem running command: " << *it << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem running command: " << *it
<< std::endl);
return 0; return 0;
} }
} }
@ -1017,9 +1043,10 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe)
std::string file; std::string file;
cmSystemTools::SplitProgramPath(exe, dir, file); cmSystemTools::SplitProgramPath(exe, dir, file);
// first try to find the executable given a config type subdir if there is one // first try to find the executable given a config type subdir if there is
if(m_CTest->GetConfigType() != "" && // one
::TryExecutable(dir.c_str(), file.c_str(), &fullPath, if(m_CTest->GetConfigType() != "" &&
::TryExecutable(dir.c_str(), file.c_str(), &fullPath,
m_CTest->GetConfigType().c_str())) m_CTest->GetConfigType().c_str()))
{ {
return fullPath; return fullPath;
@ -1088,7 +1115,8 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe)
dir += m_CTest->GetConfigType(); dir += m_CTest->GetConfigType();
dir += "/"; dir += "/";
dir += file; dir += file;
cmSystemTools::Error("config type specified on the command line, but test executable not found.", cmSystemTools::Error("config type specified on the command line, but "
"test executable not found.",
dir.c_str()); dir.c_str());
return ""; return "";
} }
@ -1107,27 +1135,30 @@ void cmCTestTestHandler::GetListOfTests()
{ {
m_ExcludeTestsRegularExpression.compile(m_ExcludeRegExp.c_str()); m_ExcludeTestsRegularExpression.compile(m_ExcludeRegExp.c_str());
} }
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Constructing a list of tests" << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Constructing a list of tests"
<< std::endl);
cmake cm; cmake cm;
cmGlobalGenerator gg; cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm); gg.SetCMakeInstance(&cm);
std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
lg->SetGlobalGenerator(&gg); lg->SetGlobalGenerator(&gg);
cmMakefile *mf = lg->GetMakefile(); cmMakefile *mf = lg->GetMakefile();
mf->AddDefinition("CTEST_CONFIGURATION_TYPE", m_CTest->GetConfigType().c_str()); mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
m_CTest->GetConfigType().c_str());
// Add handler for ADD_TEST // Add handler for ADD_TEST
cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand; cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
newCom1->m_TestHandler = this; newCom1->m_TestHandler = this;
cm.AddCommand(newCom1); cm.AddCommand(newCom1);
// Add handler for SUBDIR // Add handler for SUBDIR
cmCTestSubdirCommand* newCom2 = new cmCTestSubdirCommand; cmCTestSubdirCommand* newCom2 = new cmCTestSubdirCommand;
newCom2->m_TestHandler = this; newCom2->m_TestHandler = this;
cm.AddCommand(newCom2); cm.AddCommand(newCom2);
// Add handler for SET_SOURCE_FILES_PROPERTIES // Add handler for SET_SOURCE_FILES_PROPERTIES
cmCTestSetTestsPropertiesCommand* newCom3 = new cmCTestSetTestsPropertiesCommand; cmCTestSetTestsPropertiesCommand* newCom3
= new cmCTestSetTestsPropertiesCommand;
newCom3->m_TestHandler = this; newCom3->m_TestHandler = this;
cm.AddCommand(newCom3); cm.AddCommand(newCom3);
@ -1155,13 +1186,14 @@ void cmCTestTestHandler::GetListOfTests()
{ {
return; return;
} }
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Done constructing a list of tests" << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
"Done constructing a list of tests" << std::endl);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestTestHandler::UseIncludeRegExp() void cmCTestTestHandler::UseIncludeRegExp()
{ {
this->m_UseIncludeRegExp = true; this->m_UseIncludeRegExp = true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1170,7 +1202,7 @@ void cmCTestTestHandler::UseExcludeRegExp()
this->m_UseExcludeRegExp = true; this->m_UseExcludeRegExp = true;
this->m_UseExcludeRegExpFirst = this->m_UseIncludeRegExp ? false : true; this->m_UseExcludeRegExpFirst = this->m_UseIncludeRegExp ? false : true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* cmCTestTestHandler::GetTestStatus(int status) const char* cmCTestTestHandler::GetTestStatus(int status)
{ {
@ -1187,7 +1219,7 @@ const char* cmCTestTestHandler::GetTestStatus(int status)
"Completed" "Completed"
}; };
if ( status < cmCTestTestHandler::NOT_RUN || if ( status < cmCTestTestHandler::NOT_RUN ||
status > cmCTestTestHandler::COMPLETED ) status > cmCTestTestHandler::COMPLETED )
{ {
return "No Status"; return "No Status";
@ -1202,7 +1234,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests)
{ {
return; return;
} }
int start; int start;
int end = -1; int end = -1;
double stride = -1; double stride = -1;
@ -1239,7 +1271,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests)
{ {
end = numTests; end = numTests;
} }
// if the stride wasn't specified then it defaults to 1 // if the stride wasn't specified then it defaults to 1
if(stride == -1) if(stride == -1)
{ {
@ -1260,7 +1292,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests)
// sort the array // sort the array
std::sort(m_TestsToRun.begin(), m_TestsToRun.end(), std::less<int>()); std::sort(m_TestsToRun.begin(), m_TestsToRun.end(), std::less<int>());
// remove duplicates // remove duplicates
std::vector<int>::iterator new_end = std::vector<int>::iterator new_end =
std::unique(m_TestsToRun.begin(), m_TestsToRun.end()); std::unique(m_TestsToRun.begin(), m_TestsToRun.end());
m_TestsToRun.erase(new_end, m_TestsToRun.end()); m_TestsToRun.erase(new_end, m_TestsToRun.end());
} }
@ -1273,27 +1305,27 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
const std::string& xml) const std::string& xml)
{ {
cmsys::RegularExpression twoattributes( cmsys::RegularExpression twoattributes(
"<DartMeasurement" "<DartMeasurement"
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*>([^<]*)</DartMeasurement>"); SPACE_REGEX "*>([^<]*)</DartMeasurement>");
cmsys::RegularExpression threeattributes( cmsys::RegularExpression threeattributes(
"<DartMeasurement" "<DartMeasurement"
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*>([^<]*)</DartMeasurement>"); SPACE_REGEX "*>([^<]*)</DartMeasurement>");
cmsys::RegularExpression fourattributes( cmsys::RegularExpression fourattributes(
"<DartMeasurement" "<DartMeasurement"
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*>([^<]*)</DartMeasurement>"); SPACE_REGEX "*>([^<]*)</DartMeasurement>");
cmsys::RegularExpression measurementfile( cmsys::RegularExpression measurementfile(
"<DartMeasurementFile" "<DartMeasurementFile"
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*>([^<]*)</DartMeasurementFile>"); SPACE_REGEX "*>([^<]*)</DartMeasurementFile>");
cmOStringStream ostr; cmOStringStream ostr;
@ -1304,42 +1336,54 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
if ( twoattributes.find(cxml) ) if ( twoattributes.find(cxml) )
{ {
ostr ostr
<< "\t\t\t<NamedMeasurement" << "\t\t\t<NamedMeasurement"
<< " " << twoattributes.match(1) << "=\"" << twoattributes.match(2) << "\"" << " " << twoattributes.match(1) << "=\""
<< " " << twoattributes.match(3) << "=\"" << twoattributes.match(4) << "\"" << twoattributes.match(2) << "\""
<< "><Value>" << twoattributes.match(5) << " " << twoattributes.match(3) << "=\""
<< "</Value></NamedMeasurement>" << twoattributes.match(4) << "\""
<< "><Value>" << twoattributes.match(5)
<< "</Value></NamedMeasurement>"
<< std::endl; << std::endl;
cxml.erase(twoattributes.start(), twoattributes.end() - twoattributes.start()); cxml.erase(twoattributes.start(),
twoattributes.end() - twoattributes.start());
} }
else if ( threeattributes.find(cxml) ) else if ( threeattributes.find(cxml) )
{ {
ostr ostr
<< "\t\t\t<NamedMeasurement" << "\t\t\t<NamedMeasurement"
<< " " << threeattributes.match(1) << "=\"" << threeattributes.match(2) << "\"" << " " << threeattributes.match(1) << "=\""
<< " " << threeattributes.match(3) << "=\"" << threeattributes.match(4) << "\"" << threeattributes.match(2) << "\""
<< " " << threeattributes.match(5) << "=\"" << threeattributes.match(6) << "\"" << " " << threeattributes.match(3) << "=\""
<< "><Value>" << threeattributes.match(7) << threeattributes.match(4) << "\""
<< "</Value></NamedMeasurement>" << " " << threeattributes.match(5) << "=\""
<< threeattributes.match(6) << "\""
<< "><Value>" << threeattributes.match(7)
<< "</Value></NamedMeasurement>"
<< std::endl; << std::endl;
cxml.erase(threeattributes.start(), threeattributes.end() - threeattributes.start()); cxml.erase(threeattributes.start(),
threeattributes.end() - threeattributes.start());
} }
else if ( fourattributes.find(cxml) ) else if ( fourattributes.find(cxml) )
{ {
ostr ostr
<< "\t\t\t<NamedMeasurement" << "\t\t\t<NamedMeasurement"
<< " " << fourattributes.match(1) << "=\"" << fourattributes.match(2) << "\"" << " " << fourattributes.match(1) << "=\""
<< " " << fourattributes.match(3) << "=\"" << fourattributes.match(4) << "\"" << fourattributes.match(2) << "\""
<< " " << fourattributes.match(5) << "=\"" << fourattributes.match(6) << "\"" << " " << fourattributes.match(3) << "=\""
<< " " << fourattributes.match(7) << "=\"" << fourattributes.match(8) << "\"" << fourattributes.match(4) << "\""
<< "><Value>" << fourattributes.match(9) << " " << fourattributes.match(5) << "=\""
<< "</Value></NamedMeasurement>" << fourattributes.match(6) << "\""
<< " " << fourattributes.match(7) << "=\""
<< fourattributes.match(8) << "\""
<< "><Value>" << fourattributes.match(9)
<< "</Value></NamedMeasurement>"
<< std::endl; << std::endl;
cxml.erase(fourattributes.start(), fourattributes.end() - fourattributes.start()); cxml.erase(fourattributes.start(),
fourattributes.end() - fourattributes.start());
} }
else if ( measurementfile.find(cxml) ) else if ( measurementfile.find(cxml) )
{ {
const std::string& filename = const std::string& filename =
cmCTest::CleanString(measurementfile.match(5)); cmCTest::CleanString(measurementfile.match(5));
if ( cmSystemTools::FileExists(filename.c_str()) ) if ( cmSystemTools::FileExists(filename.c_str()) )
{ {
@ -1357,34 +1401,38 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
if ( cmSystemTools::LowerCase(k2) == "type" ) if ( cmSystemTools::LowerCase(k2) == "type" )
{ {
v2 = "text/string"; v2 = "text/string";
} }
ostr ostr
<< "\t\t\t<NamedMeasurement" << "\t\t\t<NamedMeasurement"
<< " " << k1 << "=\"" << v1 << "\"" << " " << k1 << "=\"" << v1 << "\""
<< " " << k2 << "=\"" << v2 << "\"" << " " << k2 << "=\"" << v2 << "\""
<< " encoding=\"none\"" << " encoding=\"none\""
<< "><Value>Image " << filename.c_str() << "><Value>Image " << filename.c_str()
<< " is empty</Value></NamedMeasurement>"; << " is empty</Value></NamedMeasurement>";
} }
else else
{ {
std::ifstream ifs(filename.c_str(), std::ios::in std::ifstream ifs(filename.c_str(), std::ios::in
#ifdef _WIN32 #ifdef _WIN32
| std::ios::binary | std::ios::binary
#endif #endif
); );
unsigned char *file_buffer = new unsigned char [ len + 1 ]; unsigned char *file_buffer = new unsigned char [ len + 1 ];
ifs.read(reinterpret_cast<char*>(file_buffer), len); ifs.read(reinterpret_cast<char*>(file_buffer), len);
unsigned char *encoded_buffer = new unsigned char [ static_cast<int>(len * 1.5 + 5) ]; unsigned char *encoded_buffer
= new unsigned char [ static_cast<int>(len * 1.5 + 5) ];
unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
unsigned long rlen
= cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
unsigned long cc; unsigned long cc;
ostr ostr
<< "\t\t\t<NamedMeasurement" << "\t\t\t<NamedMeasurement"
<< " " << measurementfile.match(1) << "=\"" << measurementfile.match(2) << "\"" << " " << measurementfile.match(1) << "=\""
<< " " << measurementfile.match(3) << "=\"" << measurementfile.match(4) << "\"" << measurementfile.match(2) << "\""
<< " " << measurementfile.match(3) << "=\""
<< measurementfile.match(4) << "\""
<< " encoding=\"base64\"" << " encoding=\"base64\""
<< ">" << std::endl << "\t\t\t\t<Value>"; << ">" << std::endl << "\t\t\t\t<Value>";
for ( cc = 0; cc < rlen; cc ++ ) for ( cc = 0; cc < rlen; cc ++ )
@ -1396,7 +1444,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
} }
} }
ostr ostr
<< "</Value>" << std::endl << "\t\t\t</NamedMeasurement>" << "</Value>" << std::endl << "\t\t\t</NamedMeasurement>"
<< std::endl; << std::endl;
delete [] file_buffer; delete [] file_buffer;
delete [] encoded_buffer; delete [] encoded_buffer;
@ -1410,14 +1458,17 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
idx = 2; idx = 2;
} }
ostr ostr
<< "\t\t\t<NamedMeasurement" << "\t\t\t<NamedMeasurement"
<< " name=\"" << measurementfile.match(idx) << "\"" << " name=\"" << measurementfile.match(idx) << "\""
<< " text=\"text/string\"" << " text=\"text/string\""
<< "><Value>File " << filename.c_str() << " not found</Value></NamedMeasurement>" << "><Value>File " << filename.c_str()
<< " not found</Value></NamedMeasurement>"
<< std::endl; << std::endl;
cmCTestLog(m_CTest, HANDLER_OUTPUT, "File \"" << filename.c_str() << "\" not found." << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, "File \"" << filename.c_str()
<< "\" not found." << std::endl);
} }
cxml.erase(measurementfile.start(), measurementfile.end() - measurementfile.start()); cxml.erase(measurementfile.start(),
measurementfile.end() - measurementfile.start());
} }
else else
{ {
@ -1447,7 +1498,8 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in)
return; return;
} }
this->TestsToRunString = in; this->TestsToRunString = in;
// if the argument is a file, then read it and use the contents as the string // if the argument is a file, then read it and use the contents as the
// string
if(cmSystemTools::FileExists(in)) if(cmSystemTools::FileExists(in))
{ {
std::ifstream fin(in); std::ifstream fin(in);
@ -1460,7 +1512,8 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t remove_threshold) bool cmCTestTestHandler::CleanTestOutput(std::string& output,
size_t remove_threshold)
{ {
if ( remove_threshold == 0 ) if ( remove_threshold == 0 )
{ {
@ -1512,7 +1565,8 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t remove_thre
} }
if ( skipped ) if ( skipped )
{ {
ostr << "..." << std::endl << "The rest of the test output was removed since it exceeds the threshold of " ostr << "..." << std::endl << "The rest of the test output was removed "
"since it exceeds the threshold of "
<< remove_threshold << " characters." << std::endl; << remove_threshold << " characters." << std::endl;
} }
output = ostr.str(); output = ostr.str();
@ -1520,7 +1574,8 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t remove_thre
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestTestHandler::SetTestsProperties(const std::vector<std::string>& args) bool cmCTestTestHandler::SetTestsProperties(
const std::vector<std::string>& args)
{ {
std::vector<std::string>::const_iterator it; std::vector<std::string>::const_iterator it;
std::vector<cmStdString> tests; std::vector<cmStdString> tests;
@ -1567,7 +1622,8 @@ bool cmCTestTestHandler::SetTestsProperties(const std::vector<std::string>& args
std::vector<std::string>::iterator crit; std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit ) for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{ {
rtit->m_ErrorRegularExpressions.push_back(cmsys::RegularExpression(crit->c_str())); rtit->m_ErrorRegularExpressions.push_back(
cmsys::RegularExpression(crit->c_str()));
} }
} }
if ( key == "PASS_REGULAR_EXPRESSION" ) if ( key == "PASS_REGULAR_EXPRESSION" )
@ -1577,7 +1633,8 @@ bool cmCTestTestHandler::SetTestsProperties(const std::vector<std::string>& args
std::vector<std::string>::iterator crit; std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit ) for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{ {
rtit->m_RequiredRegularExpressions.push_back(cmsys::RegularExpression(crit->c_str())); rtit->m_RequiredRegularExpressions.push_back(
cmsys::RegularExpression(crit->c_str()));
} }
} }
} }
@ -1601,7 +1658,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
{ {
std::vector<cmStdString>::iterator it; std::vector<cmStdString>::iterator it;
bool found = false; bool found = false;
for ( it = m_CustomTestsIgnore.begin(); for ( it = m_CustomTestsIgnore.begin();
it != m_CustomTestsIgnore.end(); ++ it ) it != m_CustomTestsIgnore.end(); ++ it )
{ {
if ( *it == testname ) if ( *it == testname )
@ -1612,7 +1669,8 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
} }
if ( found ) if ( found )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Ignore memcheck: " << *it << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Ignore memcheck: "
<< *it << std::endl);
return true; return true;
} }
} }
@ -1620,7 +1678,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
{ {
std::vector<cmStdString>::iterator it; std::vector<cmStdString>::iterator it;
bool found = false; bool found = false;
for ( it = m_CustomTestsIgnore.begin(); for ( it = m_CustomTestsIgnore.begin();
it != m_CustomTestsIgnore.end(); ++ it ) it != m_CustomTestsIgnore.end(); ++ it )
{ {
if ( *it == testname ) if ( *it == testname )
@ -1631,7 +1689,8 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
} }
if ( found ) if ( found )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Ignore test: " << *it << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Ignore test: "
<< *it << std::endl);
return true; return true;
} }
} }
@ -1642,7 +1701,8 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
test.m_Directory = cmSystemTools::GetCurrentWorkingDirectory(); test.m_Directory = cmSystemTools::GetCurrentWorkingDirectory();
test.m_IsInBasedOnREOptions = true; test.m_IsInBasedOnREOptions = true;
test.m_WillFail = false; test.m_WillFail = false;
if (this->m_UseIncludeRegExp && !m_IncludeTestsRegularExpression.find(testname.c_str())) if (this->m_UseIncludeRegExp &&
!m_IncludeTestsRegularExpression.find(testname.c_str()))
{ {
test.m_IsInBasedOnREOptions = false; test.m_IsInBasedOnREOptions = false;
} }

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc. All rights reserved. Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -37,7 +37,7 @@ public:
* The main entry point for this class * The main entry point for this class
*/ */
int ProcessHandler(); int ProcessHandler();
/** /**
* When both -R and -I are used should te resulting test list be the * When both -R and -I are used should te resulting test list be the
* intersection or the union of the lists. By default it is the * intersection or the union of the lists. By default it is the
@ -49,14 +49,14 @@ public:
* This method is called when reading CTest custom file * This method is called when reading CTest custom file
*/ */
void PopulateCustomVectors(cmMakefile *mf); void PopulateCustomVectors(cmMakefile *mf);
///! Control the use of the regular expresisons, call these methods to turn ///! Control the use of the regular expresisons, call these methods to turn
///them on ///them on
void UseIncludeRegExp(); void UseIncludeRegExp();
void UseExcludeRegExp(); void UseExcludeRegExp();
void SetIncludeRegExp(const char *); void SetIncludeRegExp(const char *);
void SetExcludeRegExp(const char *); void SetExcludeRegExp(const char *);
///! pass the -I argument down ///! pass the -I argument down
void SetTestsToRunInformation(const char*); void SetTestsToRunInformation(const char*);
@ -140,9 +140,9 @@ private:
/** /**
* Run the test for a directory and any subdirectories * Run the test for a directory and any subdirectories
*/ */
void ProcessDirectory(std::vector<cmStdString> &passed, void ProcessDirectory(std::vector<cmStdString> &passed,
std::vector<cmStdString> &failed); std::vector<cmStdString> &failed);
typedef std::vector<cmCTestTestProperties> tm_ListOfTests; typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
/** /**

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -43,16 +43,18 @@ bool cmCTestUpdateCommand::InitialPass(
{ {
if ( res_var ) if ( res_var )
{ {
this->SetError("called with incorrect number of arguments. RETURN_VALUE specified twice."); this->SetError("called with incorrect number of arguments. "
"RETURN_VALUE specified twice.");
return false; return false;
} }
havereturn_variable = true; havereturn_variable = true;
} }
else if(args[i] == "SOURCE") else if(args[i] == "SOURCE")
{ {
if ( source_dir ) if ( source_dir )
{ {
this->SetError("called with incorrect number of arguments. SOURCE specified twice."); this->SetError("called with incorrect number of arguments. SOURCE "
"specified twice.");
return false; return false;
} }
havesource = true; havesource = true;
@ -60,20 +62,28 @@ bool cmCTestUpdateCommand::InitialPass(
else else
{ {
cmOStringStream str; cmOStringStream str;
str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << "."; str << "called with incorrect number of arguments. Extra argument is: "
<< args[i].c_str() << ".";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }
} }
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND"); m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS"); "UpdateCommand", "CTEST_UPDATE_COMMAND");
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "CVSCommand", "CTEST_CVS_COMMAND"); m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS"); "UpdateOptions", "CTEST_UPDATE_OPTIONS");
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "SVNCommand", "CTEST_SVN_COMMAND"); m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS"); "CVSCommand", "CTEST_CVS_COMMAND");
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
"CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS");
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
"SVNCommand", "CTEST_SVN_COMMAND");
m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile,
"SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS");
const char* initialCheckoutCommand = m_Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND"); const char* initialCheckoutCommand
= m_Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
if ( !initialCheckoutCommand ) if ( !initialCheckoutCommand )
{ {
initialCheckoutCommand = m_Makefile->GetDefinition("CTEST_CVS_CHECKOUT"); initialCheckoutCommand = m_Makefile->GetDefinition("CTEST_CVS_CHECKOUT");
@ -95,14 +105,16 @@ bool cmCTestUpdateCommand::InitialPass(
{ {
handler->SetOption("InitialCheckout", initialCheckoutCommand); handler->SetOption("InitialCheckout", initialCheckoutCommand);
} }
if ( (!cmSystemTools::FileExists(source_dir) || !cmSystemTools::FileIsDirectory(source_dir)) if ( (!cmSystemTools::FileExists(source_dir) ||
!cmSystemTools::FileIsDirectory(source_dir))
&& !initialCheckoutCommand ) && !initialCheckoutCommand )
{ {
cmOStringStream str; cmOStringStream str;
str << "cannot find source directory: " << source_dir << "."; str << "cannot find source directory: " << source_dir << ".";
if ( !cmSystemTools::FileExists(source_dir) ) if ( !cmSystemTools::FileExists(source_dir) )
{ {
str << " Looks like it is not checked out yet. Please specify CTEST_CHECKOUT_COMMAND."; str << " Looks like it is not checked out yet. Please specify "
"CTEST_CHECKOUT_COMMAND.";
} }
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;

View File

@ -9,8 +9,8 @@
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information. PURPOSE. See the above copyright notices for more information.
=========================================================================*/ =========================================================================*/
@ -29,11 +29,11 @@ class cmCTestUpdateCommand : public cmCTestCommand
public: public:
cmCTestUpdateCommand() {} cmCTestUpdateCommand() {}
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestUpdateCommand* ni = new cmCTestUpdateCommand; cmCTestUpdateCommand* ni = new cmCTestUpdateCommand;
ni->m_CTest = this->m_CTest; ni->m_CTest = this->m_CTest;
@ -55,11 +55,11 @@ public:
/** /**
* Succinct documentation. * Succinct documentation.
*/ */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Updates the repository."; return "Updates the repository.";
} }
/** /**
* More documentation. * More documentation.
*/ */
@ -67,8 +67,8 @@ public:
{ {
return return
" CTEST_UPDATE([SOURCE source] [RETURN_VALUE res])\n" " CTEST_UPDATE([SOURCE source] [RETURN_VALUE res])\n"
"Updates the given source directory and stores results in Update.xml. The " "Updates the given source directory and stores results in Update.xml. "
"second argument is a variable that will hold the number of files " "The second argument is a variable that will hold the number of files "
"modified. If there is a problem, the variable will be -1."; "modified. If there is a problem, the variable will be -1.";
} }

View File

@ -48,7 +48,8 @@ static const char* cmCTestUpdateHandlerUpdateStrings[] =
static const char* cmCTestUpdateHandlerUpdateToString(int type) static const char* cmCTestUpdateHandlerUpdateToString(int type)
{ {
if ( type < cmCTestUpdateHandler::e_UNKNOWN || type >= cmCTestUpdateHandler::e_LAST ) if ( type < cmCTestUpdateHandler::e_UNKNOWN ||
type >= cmCTestUpdateHandler::e_LAST )
{ {
return cmCTestUpdateHandlerUpdateStrings[cmCTestUpdateHandler::e_UNKNOWN]; return cmCTestUpdateHandlerUpdateStrings[cmCTestUpdateHandler::e_UNKNOWN];
} }
@ -116,7 +117,8 @@ protected:
{ {
if ( strcmp(name, "logentry") == 0 ) if ( strcmp(name, "logentry") == 0 )
{ {
cmCTestLog(m_UpdateHandler->GetCTestInstance(), HANDLER_VERBOSE_OUTPUT, "\tRevision: " << m_CommitLog.m_Revision<< std::endl cmCTestLog(m_UpdateHandler->GetCTestInstance(), HANDLER_VERBOSE_OUTPUT,
"\tRevision: " << m_CommitLog.m_Revision<< std::endl
<< "\tAuthor: " << m_CommitLog.m_Author.c_str() << std::endl << "\tAuthor: " << m_CommitLog.m_Author.c_str() << std::endl
<< "\tDate: " << m_CommitLog.m_Date.c_str() << std::endl << "\tDate: " << m_CommitLog.m_Date.c_str() << std::endl
<< "\tMessage: " << m_CommitLog.m_Message.c_str() << std::endl); << "\tMessage: " << m_CommitLog.m_Message.c_str() << std::endl);
@ -124,15 +126,18 @@ protected:
} }
else if ( strcmp(name, "author") == 0 ) else if ( strcmp(name, "author") == 0 )
{ {
m_CommitLog.m_Author.assign(&(*(m_CharacterData.begin())), m_CharacterData.size()); m_CommitLog.m_Author.assign(&(*(m_CharacterData.begin())),
m_CharacterData.size());
} }
else if ( strcmp(name, "date") == 0 ) else if ( strcmp(name, "date") == 0 )
{ {
m_CommitLog.m_Date.assign(&(*(m_CharacterData.begin())), m_CharacterData.size()); m_CommitLog.m_Date.assign(&(*(m_CharacterData.begin())),
m_CharacterData.size());
} }
else if ( strcmp(name, "msg") == 0 ) else if ( strcmp(name, "msg") == 0 )
{ {
m_CommitLog.m_Message.assign(&(*(m_CharacterData.begin())), m_CharacterData.size()); m_CommitLog.m_Message.assign(&(*(m_CharacterData.begin())),
m_CharacterData.size());
} }
m_CharacterData.erase(m_CharacterData.begin(), m_CharacterData.end()); m_CharacterData.erase(m_CharacterData.begin(), m_CharacterData.end());
} }
@ -184,7 +189,8 @@ void cmCTestUpdateHandler::Initialize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type)
{ {
cmCTestLog(m_CTest, DEBUG, "Determine update type from command: " << cmd << " and type: " << type << std::endl); cmCTestLog(m_CTest, DEBUG, "Determine update type from command: " << cmd
<< " and type: " << type << std::endl);
if ( type && *type ) if ( type && *type )
{ {
cmCTestLog(m_CTest, DEBUG, "Type specified: " << type << std::endl); cmCTestLog(m_CTest, DEBUG, "Type specified: " << type << std::endl);
@ -200,7 +206,8 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type)
} }
else else
{ {
cmCTestLog(m_CTest, DEBUG, "Type not specified, check command: " << cmd << std::endl); cmCTestLog(m_CTest, DEBUG, "Type not specified, check command: " << cmd
<< std::endl);
std::string stype = cmSystemTools::LowerCase(cmd); std::string stype = cmSystemTools::LowerCase(cmd);
if ( stype.find("cvs") != std::string::npos ) if ( stype.find("cvs") != std::string::npos )
{ {
@ -212,7 +219,8 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type)
} }
} }
std::string sourceDirectory = this->GetOption("SourceDirectory"); std::string sourceDirectory = this->GetOption("SourceDirectory");
cmCTestLog(m_CTest, DEBUG, "Check directory: " << sourceDirectory.c_str() << std::endl); cmCTestLog(m_CTest, DEBUG, "Check directory: " << sourceDirectory.c_str()
<< std::endl);
sourceDirectory += "/.svn"; sourceDirectory += "/.svn";
if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
{ {
@ -246,7 +254,9 @@ int cmCTestUpdateHandler::ProcessHandler()
const char* sourceDirectory = this->GetOption("SourceDirectory"); const char* sourceDirectory = this->GetOption("SourceDirectory");
if ( !sourceDirectory ) if ( !sourceDirectory )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find SourceDirectory key in the DartConfiguration.tcl" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot find SourceDirectory key in the DartConfiguration.tcl"
<< std::endl);
return -1; return -1;
} }
@ -261,39 +271,49 @@ int cmCTestUpdateHandler::ProcessHandler()
const char* initialCheckoutCommand = this->GetOption("InitialCheckout"); const char* initialCheckoutCommand = this->GetOption("InitialCheckout");
if ( initialCheckoutCommand ) if ( initialCheckoutCommand )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " First perform the initil checkout: " << initialCheckoutCommand << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT,
" First perform the initil checkout: " << initialCheckoutCommand
<< std::endl);
cmStdString parent = cmSystemTools::GetParentDirectory(sourceDirectory); cmStdString parent = cmSystemTools::GetParentDirectory(sourceDirectory);
if ( parent.empty() ) if ( parent.empty() )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, cmCTestLog(m_CTest, ERROR_MESSAGE, "Something went wrong when trying "
"Something went wrong when trying to determine the parent directory of " << sourceDirectory << std::endl); "to determine the parent directory of " << sourceDirectory
<< std::endl);
return -1; return -1;
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Perform checkout in directory: " << parent.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Perform checkout in directory: "
<< parent.c_str() << std::endl);
if ( !cmSystemTools::MakeDirectory(parent.c_str()) ) if ( !cmSystemTools::MakeDirectory(parent.c_str()) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot create parent directory: " << parent.c_str() << " of the source directory: " << sourceDirectory << std::endl); "Cannot create parent directory: " << parent.c_str()
<< " of the source directory: " << sourceDirectory << std::endl);
return -1; return -1;
} }
ofs << "* Run initial checkout" << std::endl; ofs << "* Run initial checkout" << std::endl;
ofs << " Command: " << initialCheckoutCommand << std::endl; ofs << " Command: " << initialCheckoutCommand << std::endl;
cmCTestLog(m_CTest, DEBUG, " Before: " << initialCheckoutCommand << std::endl); cmCTestLog(m_CTest, DEBUG, " Before: "
bool retic = m_CTest->RunCommand(initialCheckoutCommand, &goutput, &errors, &retVal, parent.c_str(), 0 /* Timeout */); << initialCheckoutCommand << std::endl);
cmCTestLog(m_CTest, DEBUG, " After: " << 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 << " Output: " << goutput.c_str() << std::endl;
ofs << " Errors: " << errors.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl;
if ( !retic || retVal ) if ( !retic || retVal )
{ {
cmOStringStream ostr; cmOStringStream ostr;
ostr << "Problem running initial checkout Output [" << goutput << "] Errors [" << errors << "]"; ostr << "Problem running initial checkout Output [" << goutput
<< "] Errors [" << errors << "]";
cmCTestLog(m_CTest, ERROR_MESSAGE, ostr.str().c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, ostr.str().c_str() << std::endl);
checkoutErrorMessages += ostr.str(); checkoutErrorMessages += ostr.str();
updateProducedError = true; updateProducedError = true;
} }
m_CTest->InitializeFromCommand(m_Command); m_CTest->InitializeFromCommand(m_Command);
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Updating the repository: " << sourceDirectory << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Updating the repository: "
<< sourceDirectory << std::endl);
// Get update command // Get update command
std::string updateCommand = m_CTest->GetCTestConfiguration("UpdateCommand"); std::string updateCommand = m_CTest->GetCTestConfiguration("UpdateCommand");
@ -305,7 +325,9 @@ int cmCTestUpdateHandler::ProcessHandler()
updateCommand = m_CTest->GetCTestConfiguration("SVNCommand"); updateCommand = m_CTest->GetCTestConfiguration("SVNCommand");
if ( updateCommand.empty() ) if ( updateCommand.empty() )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find CVSCommand, SVNCommand, or UpdateCommand key in the DartConfiguration.tcl" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Cannot find CVSCommand, SVNCommand, or UpdateCommand key in the "
"DartConfiguration.tcl" << std::endl);
return -1; return -1;
} }
else else
@ -320,10 +342,13 @@ int cmCTestUpdateHandler::ProcessHandler()
} }
else else
{ {
updateType = this->DetermineType(updateCommand.c_str(), m_CTest->GetCTestConfiguration("UpdateType").c_str()); updateType = this->DetermineType(updateCommand.c_str(),
m_CTest->GetCTestConfiguration("UpdateType").c_str());
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use " << cmCTestUpdateHandlerUpdateToString(updateType) << " repository type" << std::endl;); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use "
<< cmCTestUpdateHandlerUpdateToString(updateType) << " repository type"
<< std::endl;);
// And update options // And update options
std::string updateOptions = m_CTest->GetCTestConfiguration("UpdateOptions"); std::string updateOptions = m_CTest->GetCTestConfiguration("UpdateOptions");
@ -348,7 +373,8 @@ int cmCTestUpdateHandler::ProcessHandler()
std::string extra_update_opts; std::string extra_update_opts;
if ( m_CTest->GetTestModel() == cmCTest::NIGHTLY ) if ( m_CTest->GetTestModel() == cmCTest::NIGHTLY )
{ {
struct tm* t = m_CTest->GetNightlyTime(m_CTest->GetCTestConfiguration("NightlyStartTime"), struct tm* t = m_CTest->GetNightlyTime(
m_CTest->GetCTestConfiguration("NightlyStartTime"),
m_CTest->GetTomorrowTag()); m_CTest->GetTomorrowTag());
char current_time[1024]; char current_time[1024];
sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d", sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d",
@ -396,11 +422,13 @@ int cmCTestUpdateHandler::ProcessHandler()
// //
// Get initial repository information if that is possible. With subversion, this will check the current revision. // Get initial repository information if that is possible. With subversion,
// this will check the current revision.
// //
if ( !command.empty() ) if ( !command.empty() )
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "* Get repository information: " << command.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
"* Get repository information: " << command.c_str() << std::endl);
if ( !m_CTest->GetShowOnly() ) if ( !m_CTest->GetShowOnly() )
{ {
ofs << "* Get repository information" << std::endl; ofs << "* Get repository information" << std::endl;
@ -422,12 +450,16 @@ int cmCTestUpdateHandler::ProcessHandler()
break; break;
case cmCTestUpdateHandler::e_SVN: case cmCTestUpdateHandler::e_SVN:
{ {
cmsys::RegularExpression current_revision_regex("Revision: ([0-9]+)"); cmsys::RegularExpression current_revision_regex(
"Revision: ([0-9]+)");
if ( current_revision_regex.find(goutput.c_str()) ) if ( current_revision_regex.find(goutput.c_str()) )
{ {
std::string currentRevisionString = current_revision_regex.match(1); std::string currentRevisionString
= current_revision_regex.match(1);
svn_current_revision = atoi(currentRevisionString.c_str()); svn_current_revision = atoi(currentRevisionString.c_str());
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Old revision of repository is: " << svn_current_revision << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT,
" Old revision of repository is: " << svn_current_revision
<< std::endl);
} }
} }
break; break;
@ -435,7 +467,8 @@ int cmCTestUpdateHandler::ProcessHandler()
} }
else else
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Update with command: " << command << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
"Update with command: " << command << std::endl);
} }
} }
@ -451,7 +484,8 @@ int cmCTestUpdateHandler::ProcessHandler()
std::string start_time = m_CTest->CurrentTime(); std::string start_time = m_CTest->CurrentTime();
double elapsed_time_start = cmSystemTools::GetTime(); double elapsed_time_start = cmSystemTools::GetTime();
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "* Update repository: " << command.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "* Update repository: "
<< command.c_str() << std::endl);
if ( !m_CTest->GetShowOnly() ) if ( !m_CTest->GetShowOnly() )
{ {
command = ""; command = "";
@ -474,7 +508,8 @@ int cmCTestUpdateHandler::ProcessHandler()
" " + extra_update_opts; " " + extra_update_opts;
ofs << "* Update repository: " << std::endl; ofs << "* Update repository: " << std::endl;
ofs << " Command: " << command.c_str() << std::endl; ofs << " Command: " << command.c_str() << std::endl;
bool res1 = m_CTest->RunCommand(command.c_str(), &partialOutput, &errors, bool res1 = m_CTest->RunCommand(command.c_str(), &partialOutput,
&errors,
&retVal, sourceDirectory, 0 /*m_TimeOut*/); &retVal, sourceDirectory, 0 /*m_TimeOut*/);
ofs << " Output: " << partialOutput.c_str() << std::endl; ofs << " Output: " << partialOutput.c_str() << std::endl;
ofs << " Errors: " << errors.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl;
@ -494,7 +529,7 @@ int cmCTestUpdateHandler::ProcessHandler()
if ( ofs ) if ( ofs )
{ {
ofs << "--- Update repository ---" << std::endl; ofs << "--- Update repository ---" << std::endl;
ofs << goutput << std::endl;; ofs << goutput << std::endl;
} }
} }
if ( !res || retVal ) if ( !res || retVal )
@ -514,10 +549,12 @@ int cmCTestUpdateHandler::ProcessHandler()
os << "\t<StartDateTime>" << start_time << "</StartDateTime>\n" os << "\t<StartDateTime>" << start_time << "</StartDateTime>\n"
<< "\t<UpdateCommand>" << m_CTest->MakeXMLSafe(command) << "\t<UpdateCommand>" << m_CTest->MakeXMLSafe(command)
<< "</UpdateCommand>\n" << "</UpdateCommand>\n"
<< "\t<UpdateType>" << m_CTest->MakeXMLSafe(cmCTestUpdateHandlerUpdateToString(updateType)) << "\t<UpdateType>" << m_CTest->MakeXMLSafe(
cmCTestUpdateHandlerUpdateToString(updateType))
<< "</UpdateType>\n"; << "</UpdateType>\n";
// Even though it failed, we may have some useful information. Try to continue... // Even though it failed, we may have some useful information. Try to
// continue...
std::vector<cmStdString> lines; std::vector<cmStdString> lines;
cmSystemTools::Split(goutput.c_str(), lines); cmSystemTools::Split(goutput.c_str(), lines);
std::vector<cmStdString> errLines; std::vector<cmStdString> errLines;
@ -525,16 +562,23 @@ int cmCTestUpdateHandler::ProcessHandler()
lines.insert(lines.end(), errLines.begin(), errLines.end()); lines.insert(lines.end(), errLines.begin(), errLines.end());
// CVS style regular expressions // CVS style regular expressions
cmsys::RegularExpression cvs_date_author_regex("^date: +([^;]+); +author: +([^;]+); +state: +[^;]+;"); cmsys::RegularExpression cvs_date_author_regex(
"^date: +([^;]+); +author: +([^;]+); +state: +[^;]+;");
cmsys::RegularExpression cvs_revision_regex("^revision +([^ ]*) *$"); cmsys::RegularExpression cvs_revision_regex("^revision +([^ ]*) *$");
cmsys::RegularExpression cvs_end_of_file_regex("^=============================================================================$"); cmsys::RegularExpression cvs_end_of_file_regex(
cmsys::RegularExpression cvs_end_of_comment_regex("^----------------------------$"); "^=========================================="
"===================================$");
cmsys::RegularExpression cvs_end_of_comment_regex(
"^----------------------------$");
// Subversion style regular expressions // Subversion style regular expressions
cmsys::RegularExpression svn_status_line_regex("^ *([0-9]+) *([0-9]+) *([^ ]+) *([^ ][^\t\r\n]*)[ \t\r\n]*$"); cmsys::RegularExpression svn_status_line_regex(
cmsys::RegularExpression svn_latest_revision_regex("(Updated to|At) revision ([0-9]+)\\."); "^ *([0-9]+) *([0-9]+) *([^ ]+) *([^ ][^\t\r\n]*)[ \t\r\n]*$");
cmsys::RegularExpression svn_latest_revision_regex(
"(Updated to|At) revision ([0-9]+)\\.");
cmsys::RegularExpression file_removed_line("cvs update: `(.*)' is no longer in the repository"); cmsys::RegularExpression file_removed_line(
"cvs update: `(.*)' is no longer in the repository");
cmsys::RegularExpression file_update_line("([A-Z]) *(.*)"); cmsys::RegularExpression file_update_line("([A-Z]) *(.*)");
std::string current_path = "<no-path>"; std::string current_path = "<no-path>";
bool first_file = true; bool first_file = true;
@ -546,28 +590,35 @@ int cmCTestUpdateHandler::ProcessHandler()
// In subversion, get the latest revision // In subversion, get the latest revision
if ( updateType == cmCTestUpdateHandler::e_SVN ) if ( updateType == cmCTestUpdateHandler::e_SVN )
{ {
for ( cc= 0 ; cc < lines.size(); cc ++ ) for ( cc= 0; cc < lines.size(); cc ++ )
{ {
const char* line = lines[cc].c_str(); const char* line = lines[cc].c_str();
if ( svn_latest_revision_regex.find(line) ) if ( svn_latest_revision_regex.find(line) )
{ {
svn_latest_revision = atoi(svn_latest_revision_regex.match(2).c_str()); svn_latest_revision = atoi(
svn_latest_revision_regex.match(2).c_str());
} }
} }
if ( svn_latest_revision <= 0 ) if ( svn_latest_revision <= 0 )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem determining the current revision of the repository from output:" << std::endl << goutput.c_str() << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem determining the current "
"revision of the repository from output:" << std::endl
<< goutput.c_str() << std::endl);
} }
else else
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Current revision of repository is: " << svn_latest_revision << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT,
" Current revision of repository is: " << svn_latest_revision
<< std::endl);
} }
} }
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Gathering version information (each . represents one updated file):" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT,
" Gathering version information (each . represents one updated file):"
<< std::endl);
int file_count = 0; int file_count = 0;
std::string removed_line; std::string removed_line;
for ( cc= 0 ; cc < lines.size(); cc ++ ) for ( cc= 0; cc < lines.size(); cc ++ )
{ {
const char* line = lines[cc].c_str(); const char* line = lines[cc].c_str();
if ( file_removed_line.find(line) ) if ( file_removed_line.find(line) )
@ -596,7 +647,8 @@ int cmCTestUpdateHandler::ProcessHandler()
modifiedOrConflict = true; modifiedOrConflict = true;
} }
const char* file = upFile.c_str(); const char* file = upFile.c_str();
cmCTestLog(m_CTest, DEBUG, "Line" << cc << ": " << mod << " - " << file << std::endl); cmCTestLog(m_CTest, DEBUG, "Line" << cc << ": " << mod << " - "
<< file << std::endl);
std::string output; std::string output;
if ( modifiedOrConflict ) if ( modifiedOrConflict )
@ -608,22 +660,27 @@ int cmCTestUpdateHandler::ProcessHandler()
logcommand = updateCommand + " -z3 log -N \"" + file + "\""; logcommand = updateCommand + " -z3 log -N \"" + file + "\"";
break; break;
case cmCTestUpdateHandler::e_SVN: case cmCTestUpdateHandler::e_SVN:
if ( svn_latest_revision > 0 && svn_latest_revision > svn_current_revision ) if ( svn_latest_revision > 0 &&
svn_latest_revision > svn_current_revision )
{ {
cmOStringStream logCommandStream; cmOStringStream logCommandStream;
logCommandStream << updateCommand << " log -r " << svn_current_revision << ":" << svn_latest_revision logCommandStream << updateCommand << " log -r "
<< svn_current_revision << ":" << svn_latest_revision
<< " --xml \"" << file << "\""; << " --xml \"" << file << "\"";
logcommand = logCommandStream.str(); logcommand = logCommandStream.str();
} }
else else
{ {
logcommand = updateCommand + " status --verbose \"" + file + "\""; logcommand = updateCommand +
" status --verbose \"" + file + "\"";
svn_use_status = 1; svn_use_status = 1;
} }
break; break;
} }
cmCTestLog(m_CTest, DEBUG, "Do log: " << logcommand << std::endl); cmCTestLog(m_CTest, DEBUG, "Do log: " << logcommand << std::endl);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "* Get file update information: " << logcommand.c_str() << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT,
"* Get file update information: " << logcommand.c_str()
<< std::endl);
ofs << "* Get log information for file: " << file << std::endl; ofs << "* Get log information for file: " << file << std::endl;
ofs << " Command: " << logcommand.c_str() << std::endl; ofs << " Command: " << logcommand.c_str() << std::endl;
res = m_CTest->RunCommand(logcommand.c_str(), &output, &errors, res = m_CTest->RunCommand(logcommand.c_str(), &output, &errors,
@ -669,7 +726,8 @@ int cmCTestUpdateHandler::ProcessHandler()
srevision2 = cvs_revision_regex.match(1); srevision2 = cvs_revision_regex.match(1);
} }
} }
else if ( !have_second && !sline && cvs_date_author_regex.find(clp) ) else if ( !have_second && !sline &&
cvs_date_author_regex.find(clp) )
{ {
sline = kk + 1; sline = kk + 1;
if ( !have_first ) if ( !have_first )
@ -683,7 +741,8 @@ int cmCTestUpdateHandler::ProcessHandler()
sauthor2 = cvs_date_author_regex.match(2); sauthor2 = cvs_date_author_regex.match(2);
} }
} }
else if ( sline && cvs_end_of_comment_regex.find(clp) || cvs_end_of_file_regex.find(clp)) else if ( sline && cvs_end_of_comment_regex.find(clp) ||
cvs_end_of_file_regex.find(clp))
{ {
if ( !have_first ) if ( !have_first )
{ {
@ -719,16 +778,24 @@ int cmCTestUpdateHandler::ProcessHandler()
srevision1 = str.str(); srevision1 = str.str();
if (!svn_status_line_regex.find(output)) if (!svn_status_line_regex.find(output))
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Bad output from SVN status command: " << output << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Bad output from SVN status command: " << output
<< std::endl);
} }
else if ( svn_status_line_regex.match(4) != file ) else if ( svn_status_line_regex.match(4) != file )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Bad output from SVN status command. The file name returned: \"" << svn_status_line_regex.match(4) << "\" was different than the file specified: \"" << file << "\"" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE,
"Bad output from SVN status command. "
"The file name returned: \""
<< svn_status_line_regex.match(4)
<< "\" was different than the file specified: \"" << file
<< "\"" << std::endl);
} }
else else
{ {
srevision1 = svn_status_line_regex.match(2); srevision1 = svn_status_line_regex.match(2);
int latest_revision = atoi(svn_status_line_regex.match(2).c_str()); int latest_revision = atoi(
svn_status_line_regex.match(2).c_str());
if ( svn_current_revision < latest_revision ) if ( svn_current_revision < latest_revision )
{ {
srevision2 = str.str(); srevision2 = str.str();
@ -743,7 +810,8 @@ int cmCTestUpdateHandler::ProcessHandler()
{ {
int minrev = parser.GetMinRevision(); int minrev = parser.GetMinRevision();
int maxrev = parser.GetMaxRevision(); int maxrev = parser.GetMaxRevision();
cmCTestUpdateHandlerSVNXMLParser::t_VectorOfCommits::iterator it; cmCTestUpdateHandlerSVNXMLParser::
t_VectorOfCommits::iterator it;
for ( it = parser.GetCommits()->begin(); for ( it = parser.GetCommits()->begin();
it != parser.GetCommits()->end(); it != parser.GetCommits()->end();
++ it ) ++ it )
@ -823,14 +891,18 @@ int cmCTestUpdateHandler::ProcessHandler()
{ {
srevision2 = srevision1; srevision2 = srevision1;
} }
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "File: " << path.c_str() << " / " << fname.c_str() << " was updated by " cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "File: " << path.c_str()
<< " / " << fname.c_str() << " was updated by "
<< sauthor1.c_str() << " to revision: " << srevision1.c_str() << sauthor1.c_str() << " to revision: " << srevision1.c_str()
<< " from revision: " << srevision2.c_str() << std::endl); << " from revision: " << srevision2.c_str() << std::endl);
os << "\t\t<File Directory=\"" << cmCTest::MakeXMLSafe(path) << "\">" << cmCTest::MakeXMLSafe(fname) os << "\t\t<File Directory=\"" << cmCTest::MakeXMLSafe(path) << "\">"
<< cmCTest::MakeXMLSafe(fname)
<< "</File>\n" << "</File>\n"
<< "\t\t<Directory>" << cmCTest::MakeXMLSafe(path) << "</Directory>\n" << "\t\t<Directory>" << cmCTest::MakeXMLSafe(path)
<< "</Directory>\n"
<< "\t\t<FullName>" << cmCTest::MakeXMLSafe(file) << "</FullName>\n" << "\t\t<FullName>" << cmCTest::MakeXMLSafe(file) << "</FullName>\n"
<< "\t\t<CheckinDate>" << cmCTest::MakeXMLSafe(sdate1) << "</CheckinDate>\n" << "\t\t<CheckinDate>" << cmCTest::MakeXMLSafe(sdate1)
<< "</CheckinDate>\n"
<< "\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor1) << "</Author>\n" << "\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor1) << "</Author>\n"
<< "\t\t<Email>" << cmCTest::MakeXMLSafe(semail1) << "</Email>\n" << "\t\t<Email>" << cmCTest::MakeXMLSafe(semail1) << "</Email>\n"
<< "\t\t<Log>" << cmCTest::MakeXMLSafe(comment1) << "</Log>\n" << "\t\t<Log>" << cmCTest::MakeXMLSafe(comment1) << "</Log>\n"
@ -842,19 +914,29 @@ int cmCTestUpdateHandler::ProcessHandler()
os os
<< "\t\t<Revisions>\n" << "\t\t<Revisions>\n"
<< "\t\t\t<Revision>" << srevision1 << "</Revision>\n" << "\t\t\t<Revision>" << srevision1 << "</Revision>\n"
<< "\t\t\t<PreviousRevision>" << srevision2 << "</PreviousRevision>\n" << "\t\t\t<PreviousRevision>" << srevision2
<< "\t\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor1) << "</Author>\n" << "</PreviousRevision>\n"
<< "\t\t\t<Date>" << cmCTest::MakeXMLSafe(sdate1) << "</Date>\n" << "\t\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor1)
<< "\t\t\t<Comment>" << cmCTest::MakeXMLSafe(comment1) << "</Comment>\n" << "</Author>\n"
<< "\t\t\t<Email>" << cmCTest::MakeXMLSafe(semail1) << "</Email>\n" << "\t\t\t<Date>" << cmCTest::MakeXMLSafe(sdate1)
<< "</Date>\n"
<< "\t\t\t<Comment>" << cmCTest::MakeXMLSafe(comment1)
<< "</Comment>\n"
<< "\t\t\t<Email>" << cmCTest::MakeXMLSafe(semail1)
<< "</Email>\n"
<< "\t\t</Revisions>\n" << "\t\t</Revisions>\n"
<< "\t\t<Revisions>\n" << "\t\t<Revisions>\n"
<< "\t\t\t<Revision>" << srevision2 << "</Revision>\n" << "\t\t\t<Revision>" << srevision2 << "</Revision>\n"
<< "\t\t\t<PreviousRevision>" << srevision2 << "</PreviousRevision>\n" << "\t\t\t<PreviousRevision>" << srevision2
<< "\t\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor2) << "</Author>\n" << "</PreviousRevision>\n"
<< "\t\t\t<Date>" << cmCTest::MakeXMLSafe(sdate2) << "</Date>\n" << "\t\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor2)
<< "\t\t\t<Comment>" << cmCTest::MakeXMLSafe(comment2) << "</Comment>\n" << "</Author>\n"
<< "\t\t\t<Email>" << cmCTest::MakeXMLSafe(semail2) << "</Email>\n" << "\t\t\t<Date>" << cmCTest::MakeXMLSafe(sdate2)
<< "</Date>\n"
<< "\t\t\t<Comment>" << cmCTest::MakeXMLSafe(comment2)
<< "</Comment>\n"
<< "\t\t\t<Email>" << cmCTest::MakeXMLSafe(semail2)
<< "</Email>\n"
<< "\t\t</Revisions>" << std::endl; << "\t\t</Revisions>" << std::endl;
} }
if ( mod == 'C' ) if ( mod == 'C' )
@ -890,21 +972,25 @@ int cmCTestUpdateHandler::ProcessHandler()
} }
if ( num_updated ) if ( num_updated )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_updated << " updated files" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_updated
<< " updated files" << std::endl);
} }
if ( num_modified ) if ( num_modified )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_modified << " locally modified files" cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_modified
<< " locally modified files"
<< std::endl); << std::endl);
} }
if ( num_conflicting ) if ( num_conflicting )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_conflicting << " conflicting files" cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_conflicting
<< " conflicting files"
<< std::endl); << std::endl);
} }
if ( num_modified == 0 && num_conflicting == 0 && num_updated == 0 ) if ( num_modified == 0 && num_conflicting == 0 && num_updated == 0 )
{ {
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Project is up-to-date" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Project is up-to-date"
<< std::endl);
} }
if ( !first_file ) if ( !first_file )
{ {
@ -936,21 +1022,26 @@ int cmCTestUpdateHandler::ProcessHandler()
<< "\t<UpdateReturnStatus>"; << "\t<UpdateReturnStatus>";
if ( num_modified > 0 || num_conflicting > 0 ) if ( num_modified > 0 || num_conflicting > 0 )
{ {
os << "Update error: There are modified or conflicting files in the repository"; os << "Update error: There are modified or conflicting files in the "
cmCTestLog(m_CTest, ERROR_MESSAGE, " There are modified or conflicting files in the repository" << std::endl); "repository";
cmCTestLog(m_CTest, ERROR_MESSAGE,
" There are modified or conflicting files in the repository"
<< std::endl);
} }
if ( updateProducedError ) if ( updateProducedError )
{ {
os << "Update error: "; os << "Update error: ";
os << m_CTest->MakeXMLSafe(checkoutErrorMessages); os << m_CTest->MakeXMLSafe(checkoutErrorMessages);
cmCTestLog(m_CTest, ERROR_MESSAGE, " Update with command: " << command << " failed" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, " Update with command: " << command
<< " failed" << std::endl);
} }
os << "</UpdateReturnStatus>" << std::endl; os << "</UpdateReturnStatus>" << std::endl;
os << "</Update>" << std::endl; os << "</Update>" << std::endl;
if (! res || retVal ) if (! res || retVal )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when updating the project" << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when updating the project"
<< std::endl);
cmCTestLog(m_CTest, ERROR_MESSAGE, "Output: " << goutput << std::endl); cmCTestLog(m_CTest, ERROR_MESSAGE, "Output: " << goutput << std::endl);
return -1; return -1;
} }