diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 2eeb3b1e1..ab89961c5 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -55,9 +55,9 @@ int cmCTestBuildAndTestHandler::ProcessHandler() } //---------------------------------------------------------------------- -int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, cmOStringStream &out, - std::string &cmakeOutString, std::string &cwd, - cmake *cm) +int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, + cmOStringStream &out, std::string &cmakeOutString, std::string &cwd, + cmake *cm) { unsigned int k; std::vector args; @@ -71,7 +71,8 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, cmOStringStream } 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); } @@ -114,7 +115,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, cmOStringStream } return 1; } - } + } return 0; } @@ -135,7 +136,7 @@ void CMakeStdoutCallback(const char* m, int len, void* s) //---------------------------------------------------------------------- int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) -{ +{ unsigned int k; std::string cmakeOutString; cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString); @@ -143,23 +144,23 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) cmOStringStream out; // What is this? double timeout = m_CTest->GetTimeOut(); int retVal = 0; - + // if the generator and make program are not specified then it is an error if (!m_BuildGenerator.size() || !m_BuildMakeProgram.size()) { if(outstring) { - *outstring = + *outstring = "--build-and-test requires that both the generator and makeprogram " "be provided using the --build-generator and --build-makeprogram " "command line options. "; } return 1; } - + // make sure the binary dir is there 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())) { cmSystemTools::MakeDirectory(m_BinaryDir.c_str()); @@ -169,7 +170,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) // should we cmake? cmake cm; cm.SetGlobalGenerator(cm.CreateGlobalGenerator(m_BuildGenerator.c_str())); - + if(!m_BuildNoCMake) { // do the cmake step @@ -210,20 +211,20 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) { *outstring = out.str(); } - + // if not test was specified then we are done if (!m_TestCommand.size()) { return 0; } - + // now run the compiled test if we can find it std::vector attempted; std::vector failed; std::string tempPath; - std::string filepath = + std::string filepath = cmSystemTools::GetFilenamePath(m_TestCommand); - std::string filename = + std::string filename = cmSystemTools::GetFilenameName(m_TestCommand); // if full path specified then search that first if (filepath.size()) @@ -282,9 +283,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) // store the final location in fullPath std::string fullPath; - + // 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) { // first check without exe extension @@ -396,7 +397,8 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( } 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; } } @@ -433,7 +435,8 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( 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++; m_BuildMakeProgram = allArgs[idx]; @@ -449,8 +452,9 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( while(idx < allArgs.size() && !done) { m_BuildOptions.push_back(allArgs[idx]); - if(idx+1 < allArgs.size() - && (allArgs[idx+1] == "--build-target" || allArgs[idx+1] == "--test-command")) + if(idx+1 < allArgs.size() + && (allArgs[idx+1] == "--build-target" || + allArgs[idx+1] == "--test-command")) { done = true; } diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index e5d20ed71..361bf66af 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -63,16 +63,18 @@ bool cmCTestBuildCommand::InitialPass( { 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; } havereturn_variable = true; - } + } else if(args[i] == "BUILD") { 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; } havesource = true; @@ -80,7 +82,8 @@ bool cmCTestBuildCommand::InitialPass( else { 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()); return false; } @@ -97,18 +100,23 @@ bool cmCTestBuildCommand::InitialPass( this->SetError("internal CTest error. Cannot instantiate build handler"); return false; } - - const char* ctestBuildCommand = m_Makefile->GetDefinition("CTEST_BUILD_COMMAND"); + + const char* ctestBuildCommand + = m_Makefile->GetDefinition("CTEST_BUILD_COMMAND"); if ( ctestBuildCommand && *ctestBuildCommand ) { m_CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand); } else { - const char* cmakeGeneratorName = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); - const char* cmakeProjectName = m_Makefile->GetDefinition("CTEST_PROJECT_NAME"); - const char* cmakeBuildConfiguration = m_Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); - const char* cmakeBuildAdditionalFlags = m_Makefile->GetDefinition("CTEST_BUILD_FLAGS"); + const char* cmakeGeneratorName + = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); + const char* cmakeProjectName + = 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 && cmakeProjectName && *cmakeProjectName ) { @@ -126,25 +134,31 @@ bool cmCTestBuildCommand::InitialPass( } if ( !m_GlobalGenerator ) { - m_GlobalGenerator = - m_Makefile->GetCMakeInstance()->CreateGlobalGenerator(cmakeGeneratorName); + m_GlobalGenerator = + m_Makefile->GetCMakeInstance()->CreateGlobalGenerator( + cmakeGeneratorName); } 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 - = m_GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram, cmakeProjectName, + = m_GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram, + cmakeProjectName, cmakeBuildAdditionalFlags, 0, cmakeBuildConfiguration, true); m_CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str()); } else { 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()); return false; } } - + int res = handler->ProcessHandler(); if ( res_var ) { diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 60b33a123..a5f9143ee 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -32,7 +32,7 @@ #include "windows.h" #endif -#include +#include #include #include #include @@ -125,9 +125,9 @@ static const char* cmCTestWarningMatches[] = { }; static const char* cmCTestWarningExceptions[] = { - "/usr/openwin/include/X11/Xlib\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", - "/usr/openwin/include/X11/Xutil\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", - "/usr/openwin/include/X11/XResource\\.h:[0-9]+: warning: ANSI C\\+\\+ forbids declaration", + "/usr/.*/X11/Xlib\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration", + "/usr/.*/X11/Xutil\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration", + "/usr/.*/X11/XResource\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration", "WARNING 84 :", "WARNING 47 :", "makefile:", @@ -220,19 +220,19 @@ void cmCTestBuildHandler::Initialize() //---------------------------------------------------------------------- void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf) { - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH", + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH", m_CustomErrorMatches); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION", + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION", m_CustomErrorExceptions); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH", + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH", m_CustomWarningMatches); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION", + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION", m_CustomWarningExceptions); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", m_MaxErrors); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", m_MaxWarnings); } @@ -244,7 +244,9 @@ int cmCTestBuildHandler::ProcessHandler() cmCTestLog(m_CTest, HANDLER_OUTPUT, "Build project" << std::endl); int entry; - for ( entry = 0; cmCTestWarningErrorFileLine[entry].m_RegularExpressionString; ++ entry ) + for ( entry = 0; + cmCTestWarningErrorFileLine[entry].m_RegularExpressionString; + ++ entry ) { cmCTestBuildHandler::cmCTestCompileErrorWarningRex r; if ( r.m_RegularExpression.compile( @@ -256,22 +258,30 @@ int cmCTestBuildHandler::ProcessHandler() } else { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem Compiling regular expression: " - << cmCTestWarningErrorFileLine[entry].m_RegularExpressionString << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, + "Problem Compiling regular expression: " + << cmCTestWarningErrorFileLine[entry].m_RegularExpressionString + << std::endl); } } // 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 ) { - 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; } - const std::string &buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); + const std::string &buildDirectory + = m_CTest->GetCTestConfiguration("BuildDirectory"); 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; } @@ -280,7 +290,8 @@ int cmCTestBuildHandler::ProcessHandler() double elapsed_time_start = cmSystemTools::GetTime(); 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, @@ -312,10 +323,14 @@ int cmCTestBuildHandler::ProcessHandler() { \ regexes.push_back(it->c_str()); \ } - cmCTestBuildHandlerPopulateRegexVector(m_CustomErrorMatches, m_ErrorMatchRegex); - cmCTestBuildHandlerPopulateRegexVector(m_CustomErrorExceptions, m_ErrorExceptionRegex); - cmCTestBuildHandlerPopulateRegexVector(m_CustomWarningMatches, m_WarningMatchRegex); - cmCTestBuildHandlerPopulateRegexVector(m_CustomWarningExceptions, m_WarningExceptionRegex); + cmCTestBuildHandlerPopulateRegexVector( + m_CustomErrorMatches, m_ErrorMatchRegex); + cmCTestBuildHandlerPopulateRegexVector( + m_CustomErrorExceptions, m_ErrorExceptionRegex); + cmCTestBuildHandlerPopulateRegexVector( + m_CustomWarningMatches, m_WarningMatchRegex); + cmCTestBuildHandlerPopulateRegexVector( + m_CustomWarningExceptions, m_WarningExceptionRegex); // Determine source and binary tree substitutions to simplify the output. @@ -323,7 +338,8 @@ int cmCTestBuildHandler::ProcessHandler() m_SimplifyBuildDir = ""; if ( m_CTest->GetCTestConfiguration("SourceDirectory").size() > 20 ) { - std::string srcdir = m_CTest->GetCTestConfiguration("SourceDirectory") + "/"; + std::string srcdir + = m_CTest->GetCTestConfiguration("SourceDirectory") + "/"; std::string srcdirrep; for ( cc = srcdir.size()-2; cc > 0; cc -- ) { @@ -339,7 +355,8 @@ int cmCTestBuildHandler::ProcessHandler() } if ( m_CTest->GetCTestConfiguration("BuildDirectory").size() > 20 ) { - std::string bindir = m_CTest->GetCTestConfiguration("BuildDirectory") + "/"; + std::string bindir + = m_CTest->GetCTestConfiguration("BuildDirectory") + "/"; std::string bindirrep; for ( cc = bindir.size()-2; cc > 0; cc -- ) { @@ -356,18 +373,20 @@ int cmCTestBuildHandler::ProcessHandler() // Ok, let's do the build - + // Remember start build time m_StartBuild = m_CTest->CurrentTime(); int retVal = 0; int res = cmsysProcess_State_Exited; 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 { - 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 @@ -375,28 +394,39 @@ int cmCTestBuildHandler::ProcessHandler() double elapsed_build_time = cmSystemTools::GetTime() - elapsed_time_start; 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. t_ErrorsAndWarningsVector::iterator evit; 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(evit->m_PreContext, m_SimplifySourceDir.c_str(), "/.../"); - cmSystemTools::ReplaceString(evit->m_PostContext, m_SimplifySourceDir.c_str(), "/.../"); + cmSystemTools::ReplaceString( + evit->m_Text, 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() ) { - 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(evit->m_PreContext, m_SimplifyBuildDir.c_str(), "/.../"); - cmSystemTools::ReplaceString(evit->m_PostContext, m_SimplifyBuildDir.c_str(), "/.../"); + cmSystemTools::ReplaceString( + evit->m_Text, 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; 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; } - this->GenerateDartBuildOutput(xofs, m_ErrorsAndWarnings, elapsed_build_time); + this->GenerateDartBuildOutput( + xofs, m_ErrorsAndWarnings, elapsed_build_time); return 0; } //---------------------------------------------------------------------- void cmCTestBuildHandler::GenerateDartBuildOutput( - std::ostream& os, + std::ostream& os, std::vector ew, double elapsed_build_time) { m_CTest->StartXML(os); os << "\n" << "\t" << m_StartBuild << "\n" - << "" + << "" << m_CTest->MakeXMLSafe(m_CTest->GetCTestConfiguration("MakeCommand")) << "" << std::endl; - + std::vector::iterator it; - + // only report the first 50 warnings and first 50 errors unsigned short numErrorsAllowed = m_MaxErrors; unsigned short numWarningsAllowed = m_MaxWarnings; @@ -442,7 +474,7 @@ void cmCTestBuildHandler::GenerateDartBuildOutput( // via a call to collapse full path. srcdir = cmSystemTools::CollapseFullPath(srcdir.c_str()); srcdir += "/"; - for ( it = ew.begin(); + for ( it = ew.begin(); it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ ) { cmCTestBuildErrorWarning *cm = &(*it); @@ -459,7 +491,7 @@ void cmCTestBuildHandler::GenerateDartBuildOutput( } os << "\t<" << (cm->m_Error ? "Error" : "Warning") << ">\n" << "\t\t" << cm->m_LogLine << "\n" - << "\t\t" << m_CTest->MakeXMLSafe(cm->m_Text) + << "\t\t" << m_CTest->MakeXMLSafe(cm->m_Text) << "\n" << std::endl; std::vector::iterator rit; for ( rit = m_ErrorWarningFileLineRegex.begin(); @@ -469,7 +501,7 @@ void cmCTestBuildHandler::GenerateDartBuildOutput( if ( re->find(cm->m_Text.c_str() ) ) { 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 cmSystemTools::ConvertToUnixSlashes(cm->m_SourceFile); 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("/"); 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 { // make sure it is a full path with the correct case - cm->m_SourceFile = cmSystemTools::CollapseFullPath(cm->m_SourceFile.c_str()); - cmSystemTools::ReplaceString(cm->m_SourceFile, srcdir.c_str(), ""); + cm->m_SourceFile = cmSystemTools::CollapseFullPath( + cm->m_SourceFile.c_str()); + cmSystemTools::ReplaceString( + cm->m_SourceFile, srcdir.c_str(), ""); } cm->m_LineNumber = atoi(re->match(rit->m_LineIndex).c_str()); break; @@ -493,31 +528,32 @@ void cmCTestBuildHandler::GenerateDartBuildOutput( } if ( cm->m_SourceFile.size() > 0 ) { - os << "\t\t" << cm->m_SourceFile << "" + os << "\t\t" << cm->m_SourceFile << "" << std::endl; } if ( cm->m_SourceFileTail.size() > 0 ) { - os << "\t\t" << cm->m_SourceFileTail + os << "\t\t" << cm->m_SourceFileTail << "" << std::endl; } if ( cm->m_LineNumber >= 0 ) { - os << "\t\t" << cm->m_LineNumber + os << "\t\t" << cm->m_LineNumber << "" << std::endl; } - os << "\t\t" << m_CTest->MakeXMLSafe(cm->m_PreContext) + os << "\t\t" << m_CTest->MakeXMLSafe(cm->m_PreContext) << "\n" << "\t\t" << m_CTest->MakeXMLSafe(cm->m_PostContext); // is this the last warning or error, if so notify if (cm->m_Error && !numErrorsAllowed || !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 << "\n" << "\t\t0\n" - << "m_Error ? "Error" : "Warning") << ">\n\n" + << "m_Error ? "Error" : "Warning") << ">\n\n" << 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, std::endl); - + // Now create process object cmsysProcess* cp = cmsysProcess_New(); cmsysProcess_SetCommand(cp, &*argv.begin()); @@ -577,7 +613,8 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, char* data; int length; 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 << " " << std::flush); @@ -609,16 +646,19 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, // Process the chunk of data 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 { - 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_BuildProcessingErrorQueue); + this->ProcessBuffer(0, 0, tick, tick_len, ofs, + &m_BuildProcessingErrorQueue); cmCTestLog(m_CTest, OUTPUT, " Size of output: " << int(m_BuildOutputLogSize / 1024.0) << "K" << std::endl); @@ -629,30 +669,33 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, if(result == cmsysProcess_State_Exited) { *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) { *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) { cmCTestLog(m_CTest, WARNING, "There was a timeout" << std::endl); - } + } else if(result == cmsysProcess_State_Error) { // If there was an error running command, report that on the dashboard. cmCTestBuildErrorWarning errorwarning; errorwarning.m_LogLine = 1; - errorwarning.m_Text = "*** ERROR executing: "; + errorwarning.m_Text = "*** ERROR executing: "; errorwarning.m_Text += cmsysProcess_GetErrorString(cp); errorwarning.m_PreContext = ""; errorwarning.m_PostContext = ""; errorwarning.m_Error = true; m_ErrorsAndWarnings.push_back(errorwarning); 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); @@ -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, - std::ofstream& ofs, t_BuildProcessingQueueType* queue) +void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, + size_t& tick, size_t tick_len, std::ofstream& ofs, + t_BuildProcessingQueueType* queue) { #undef cerr 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 ) { m_WarningQuotaReached = true; @@ -750,7 +795,9 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti // Copy pre-context to report std::deque::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"; } @@ -765,7 +812,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti { // This is not an error or warning. // 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_LastErrorOrWarning->m_PostContext += line; @@ -780,7 +828,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti m_PreContext.push_back(line); 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; // Check for regular expressions - + if ( !m_ErrorQuotaReached ) { - // Errors - for ( it = m_ErrorMatchRegex.begin(); it != m_ErrorMatchRegex.end(); ++ it ) + // Errors + for ( it = m_ErrorMatchRegex.begin(); + it != m_ErrorMatchRegex.end(); + ++ it ) { if ( it->find(data) ) { @@ -842,13 +893,16 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data) break; } } - // Error exceptions - for ( it = m_ErrorExceptionRegex.begin(); it != m_ErrorExceptionRegex.end(); ++ it ) + // Error exceptions + for ( it = m_ErrorExceptionRegex.begin(); + it != m_ErrorExceptionRegex.end(); + ++ it ) { if ( it->find(data) ) { 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; } } @@ -856,25 +910,30 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data) if ( !m_WarningQuotaReached ) { // 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) ) { warningLine = 1; cmCTestLog(m_CTest, DEBUG, " Warning Line: " << data << std::endl); break; - } + } } // 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) ) { 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; - } + } } } if ( errorLine ) diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index 80d062581..17504527f 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -39,21 +39,21 @@ public: * The main entry point for this class */ int ProcessHandler(); - + cmCTestBuildHandler(); - + void PopulateCustomVectors(cmMakefile *mf); /** * Initialize handler */ virtual void Initialize(); - + private: //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. int RunMakeCommand(const char* command, - int* retVal, const char* dir, int timeout, + int* retVal, const char* dir, int timeout, std::ofstream& ofs); enum { @@ -84,14 +84,14 @@ private: }; // generate the XML output - void GenerateDartBuildOutput(std::ostream& os, + void GenerateDartBuildOutput(std::ostream& os, std::vector, double elapsed_time); - + std::string m_StartBuild; std::string m_EndBuild; - + std::vector m_CustomErrorMatches; std::vector m_CustomErrorExceptions; std::vector m_CustomWarningMatches; @@ -105,8 +105,8 @@ private: typedef std::deque t_BuildProcessingQueueType; - void ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len, - std::ofstream& ofs, t_BuildProcessingQueueType* queue); + void ProcessBuffer(const char* data, int length, size_t& tick, + size_t tick_len, std::ofstream& ofs, t_BuildProcessingQueueType* queue); int ProcessSingleLine(const char* data); t_BuildProcessingQueueType m_BuildProcessingQueue; diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 8f3574c9f..bb5623b58 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -50,16 +50,18 @@ bool cmCTestConfigureCommand::InitialPass( { 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; } havereturn_variable = true; - } + } else if(args[i] == "SOURCE") { 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; } havesource = true; @@ -68,7 +70,8 @@ bool cmCTestConfigureCommand::InitialPass( { 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; } havebuild = true; @@ -76,7 +79,8 @@ bool cmCTestConfigureCommand::InitialPass( else { 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()); return false; } @@ -100,20 +104,24 @@ bool cmCTestConfigureCommand::InitialPass( build_dir = m_Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"); if ( !build_dir ) { - this->SetError("Build directory not specified. Either use BUILD argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY variable"); + this->SetError("Build directory not specified. Either use BUILD " + "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY " + "variable"); return false; } } - const char* ctestConfigureCommand = m_Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); + const char* ctestConfigureCommand + = m_Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); if ( ctestConfigureCommand && *ctestConfigureCommand ) { m_CTest->SetCTestConfiguration("ConfigureCommand", ctestConfigureCommand); } else { - const char* cmakeGeneratorName = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); + const char* cmakeGeneratorName + = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); if ( cmakeGeneratorName && *cmakeGeneratorName ) { std::string cmakeConfigureCommand = "\""; @@ -123,19 +131,24 @@ bool cmCTestConfigureCommand::InitialPass( cmakeConfigureCommand += "\" \""; cmakeConfigureCommand += source_dir; cmakeConfigureCommand += "\""; - m_CTest->SetCTestConfiguration("ConfigureCommand", cmakeConfigureCommand.c_str()); + m_CTest->SetCTestConfiguration("ConfigureCommand", + cmakeConfigureCommand.c_str()); } 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; } } - cmCTestGenericHandler* handler = m_CTest->GetInitializedHandler("configure"); + cmCTestGenericHandler* handler + = m_CTest->GetInitializedHandler("configure"); if ( !handler ) { - this->SetError("internal CTest error. Cannot instantiate configure handler"); + this->SetError( + "internal CTest error. Cannot instantiate configure handler"); return false; } int res = handler->ProcessHandler(); diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index 8508898cf..8ce199d73 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,11 +29,11 @@ class cmCTestConfigureCommand : public cmCTestCommand public: cmCTestConfigureCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestConfigureCommand* ni = new cmCTestConfigureCommand; ni->m_CTest = this->m_CTest; @@ -55,11 +55,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Configures the repository."; } - + /** * More documentation. */ @@ -67,8 +67,9 @@ public: { return " CTEST_CONFIGURE(BUILD build_dir RETURN_VALUE res)\n" - "Configures the given build directory and stores results in Configure.xml. The " - "second argument is a variable that will hold return value."; + "Configures the given build directory and stores results in " + "Configure.xml. The second argument is a variable that will hold " + "return value."; } cmTypeMacro(cmCTestConfigureCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 07d41906b..3152fffd0 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -43,15 +43,19 @@ int cmCTestConfigureHandler::ProcessHandler() std::string cCommand = m_CTest->GetCTestConfiguration("ConfigureCommand"); if ( cCommand.size() == 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find ConfigureCommand key in the DartConfiguration.tcl" - << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, + "Cannot find ConfigureCommand key in the DartConfiguration.tcl" + << std::endl); return -1; } - std::string buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); + std::string buildDirectory + = m_CTest->GetCTestConfiguration("BuildDirectory"); 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; } @@ -61,18 +65,20 @@ int cmCTestConfigureHandler::ProcessHandler() int res = 0; if ( !m_CTest->GetShowOnly() ) { - cmGeneratedFileStream os; + cmGeneratedFileStream 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; } std::string start_time = m_CTest->CurrentTime(); cmGeneratedFileStream ofs; this->StartLogFile("Configure", ofs); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " << cCommand.c_str() << std::endl); - res = m_CTest->RunMakeCommand(cCommand.c_str(), &output, + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " + << cCommand.c_str() << std::endl); + res = m_CTest->RunMakeCommand(cCommand.c_str(), &output, &retVal, buildDirectory.c_str(), 0, ofs); @@ -80,37 +86,41 @@ int cmCTestConfigureHandler::ProcessHandler() { ofs.close(); } - + if ( os ) { m_CTest->StartXML(os); os << "\n" - << "\t" << start_time << "" << std::endl; + << "\t" << start_time << "" + << std::endl; if ( res == cmsysProcess_State_Exited && retVal ) { os << retVal; } - os << "" << cCommand.c_str() << "" << std::endl; + os << "" << cCommand.c_str() << "" + << std::endl; cmCTestLog(m_CTest, DEBUG, "End" << std::endl); os << "" << cmCTest::MakeXMLSafe(output) << "" << std::endl; std::string end_time = m_CTest->CurrentTime(); os << "\t" << retVal << "\n" << "\t" << end_time << "\n" - << "" + << "" << static_cast( (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0 << "" << "" << std::endl; m_CTest->EndXML(os); - } + } } else { - cmCTestLog(m_CTest, DEBUG, "Configure with command: " << cCommand << std::endl); + cmCTestLog(m_CTest, DEBUG, "Configure with command: " << cCommand + << std::endl); } 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 0; diff --git a/Source/CTest/cmCTestConfigureHandler.h b/Source/CTest/cmCTestConfigureHandler.h index 07d7d7c60..5915af99f 100644 --- a/Source/CTest/cmCTestConfigureHandler.h +++ b/Source/CTest/cmCTestConfigureHandler.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -35,7 +35,7 @@ public: * The main entry point for this class */ int ProcessHandler(); - + cmCTestConfigureHandler(); void Initialize(); diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index 340693edd..bcb323956 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -43,16 +43,18 @@ bool cmCTestCoverageCommand::InitialPass( { 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; } havereturn_variable = true; - } + } else if(args[i] == "BUILD") { 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; } havesource = true; @@ -60,7 +62,8 @@ bool cmCTestCoverageCommand::InitialPass( else { 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()); return false; } @@ -81,7 +84,8 @@ bool cmCTestCoverageCommand::InitialPass( return false; } 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(); if ( res_var ) { diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index ce9948a67..703363a53 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,11 +29,11 @@ class cmCTestCoverageCommand : public cmCTestCommand public: cmCTestCoverageCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestCoverageCommand* ni = new cmCTestCoverageCommand; ni->m_CTest = this->m_CTest; @@ -55,11 +55,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Tests the repository."; } - + /** * More documentation. */ @@ -67,8 +67,9 @@ public: { return " CTEST_COVERAGE([BUILD build_dir] [RETURN_VALUE res])\n" - "Perform the coverage of the given build directory and stores results in " - "Coverage.xml. The second argument is a variable that will hold value."; + "Perform the coverage of the given build directory and stores results " + "in Coverage.xml. The second argument is a variable that will hold " + "value."; } cmTypeMacro(cmCTestCoverageCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 2b5f1caaf..0eacc42a1 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -44,25 +44,30 @@ void cmCTestCoverageHandler::Initialize() } //---------------------------------------------------------------------- -bool cmCTestCoverageHandler::StartCoverageLogFile(cmGeneratedFileStream& covLogFile, int logFileCount) +bool cmCTestCoverageHandler::StartCoverageLogFile( + cmGeneratedFileStream& covLogFile, int logFileCount) { char covLogFilename[1024]; 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) ) { - 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; } std::string local_start_time = m_CTest->CurrentTime(); m_CTest->StartXML(covLogFile); covLogFile << "" << std::endl - << "\t" << local_start_time << "" << std::endl; + << "\t" << local_start_time << "" + << std::endl; return true; } //---------------------------------------------------------------------- -void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount) +void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr, + int logFileCount) { std::string local_end_time = m_CTest->CurrentTime(); ostr << "\t" << local_end_time << "" << std::endl @@ -70,12 +75,14 @@ void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr, int m_CTest->EndXML(ostr); char covLogFilename[1024]; 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(); } //---------------------------------------------------------------------- -bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* srcDir, +bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, + const char* srcDir, const char* binDir) { std::vector::iterator sit; @@ -93,8 +100,10 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* src std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir); std::string fBinDir = cmSystemTools::CollapseFullPath(binDir); std::string fFile = cmSystemTools::CollapseFullPath(file); - bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fSrcDir.c_str()); - bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fBinDir.c_str()); + bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), + fSrcDir.c_str()); + bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), + fBinDir.c_str()); // Always check parent directory of the file. std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str()); std::string checkDir; @@ -124,7 +133,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* src fFile.c_str(), checkDir.c_str()); 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; } @@ -154,7 +164,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* src fFile.c_str(), checkDir.c_str()); 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; } // Ok, nothing in source tree, nothing in binary tree @@ -176,7 +187,8 @@ int cmCTestCoverageHandler::ProcessHandler() double elapsed_time_start = cmSystemTools::GetTime(); 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; @@ -186,39 +198,42 @@ int cmCTestCoverageHandler::ProcessHandler() std::string asfGlob = sourceDir + "/*"; std::string abfGlob = binaryDir + "/*"; - - + + // 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)\\."; cmsys::RegularExpression st1re1(st1gcovOutputRex1.c_str()); cmsys::RegularExpression st1re2(st1gcovOutputRex2.c_str()); - - + + // Style 2 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 st2gcovOutputRex4 = "^(.*):unexpected EOF *$"; 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 st2re2(st2gcovOutputRex2.c_str()); cmsys::RegularExpression st2re3(st2gcovOutputRex3.c_str()); cmsys::RegularExpression st2re4(st2gcovOutputRex4.c_str()); cmsys::RegularExpression st2re5(st2gcovOutputRex5.c_str()); cmsys::RegularExpression st2re6(st2gcovOutputRex6.c_str()); - + cmCTestLog(m_CTest, HANDLER_OUTPUT, "Performing coverage" << std::endl); - + std::string coverage_start_time = m_CTest->CurrentTime(); - + std::string testingDir = m_CTest->GetBinaryDir() + "/Testing"; std::string tempDir = testingDir + "/CoverageInfo"; std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::MakeDirectory(tempDir.c_str()); cmSystemTools::ChangeDirectory(tempDir.c_str()); - + cmGlob gl; gl.RecurseOn(); std::string daGlob = binaryDir + "/*.da"; @@ -229,10 +244,11 @@ int cmCTestCoverageHandler::ProcessHandler() std::vector& moreFiles = gl.GetFiles(); files.insert(files.end(), moreFiles.begin(), moreFiles.end()); std::vector::iterator it; - + 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 return 0; } @@ -243,27 +259,30 @@ int cmCTestCoverageHandler::ProcessHandler() rexIt != m_CustomCoverageExclude.end(); ++ rexIt ) { - m_CustomCoverageExcludeRegex.push_back(cmsys::RegularExpression(rexIt->c_str())); + m_CustomCoverageExcludeRegex.push_back( + cmsys::RegularExpression(rexIt->c_str())); } - + typedef std::vector singleFileCoverageVector; typedef std::map totalCoverageMap; - + totalCoverageMap totalCoverage; - + int gcovStyle = 0; std::set missingFiles; - + 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, " "); int file_count = 0; for ( it = files.begin(); it != files.end(); ++ it ) { cmCTestLog(m_CTest, HANDLER_OUTPUT, "." << std::flush); 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); std::string output = ""; std::string errors = ""; @@ -272,36 +291,43 @@ int cmCTestCoverageHandler::ProcessHandler() ofs << " Command: " << command.c_str() << std::endl; int res = m_CTest->RunCommand(command.c_str(), &output, &errors, &retVal, tempDir.c_str(), 0 /*m_TimeOut*/); - + ofs << " Output: " << output.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; if ( ! res ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem running coverage on file: " << it->c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << errors << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem running coverage on file: " + << it->c_str() << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << errors + << std::endl); error ++; continue; } if ( retVal != 0 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Coverage command returned: " << retVal << " while processing: " << it->c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, "Command produced error: " << error << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, "Coverage command returned: " + << 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, - "--------------------------------------------------------------" << std::endl + "--------------------------------------------------------------" + << std::endl << output << std::endl - << "--------------------------------------------------------------" << std::endl); + << "--------------------------------------------------------------" + << std::endl); std::vector lines; std::vector::iterator line; - - + + // Globals for storing current source file and current gcov file; cmSystemTools::Split(output.c_str(), lines); for ( line = lines.begin(); line != lines.end(); ++line) { std::string sourceFile; 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 ) { // Ignore empty line; probably style 2 @@ -312,13 +338,14 @@ int cmCTestCoverageHandler::ProcessHandler() { 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 ++; break; } gcovStyle = 1; } - + actualSourceFile = ""; sourceFile = st1re1.match(2); } @@ -328,13 +355,14 @@ int cmCTestCoverageHandler::ProcessHandler() { 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 ++; break; } gcovStyle = 1; } - + gcovFile = st1re2.match(1); } else if ( st2re1.find(line->c_str() ) ) @@ -343,13 +371,14 @@ int cmCTestCoverageHandler::ProcessHandler() { 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 ++; break; } gcovStyle = 2; } - + actualSourceFile = ""; sourceFile = st2re1.match(1); } @@ -359,7 +388,8 @@ int cmCTestCoverageHandler::ProcessHandler() { 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 ++; break; } @@ -372,13 +402,14 @@ int cmCTestCoverageHandler::ProcessHandler() { 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 ++; break; } gcovStyle = 2; } - + gcovFile = st2re3.match(2); } else if ( st2re4.find(line->c_str() ) ) @@ -387,14 +418,16 @@ int cmCTestCoverageHandler::ProcessHandler() { 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 ++; break; } 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() ) ) { @@ -402,14 +435,16 @@ int cmCTestCoverageHandler::ProcessHandler() { 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 ++; break; } 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() ) ) { @@ -417,30 +452,34 @@ int cmCTestCoverageHandler::ProcessHandler() { 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 ++; break; } gcovStyle = 2; } - + cmCTestLog(m_CTest, WARNING, "Warning: File: " << st2re6.match(1) << " is newer than " << st2re6.match(2) << std::endl); } 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 ++; //abort(); } if ( !gcovFile.empty() && actualSourceFile.size() ) { 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()); 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 { @@ -449,30 +488,33 @@ int cmCTestCoverageHandler::ProcessHandler() while ( cmSystemTools::GetLineFromStream(ifile, nl) ) { cnt ++; - + //TODO: Handle gcov 3.0 non-coverage lines - + // Skip empty lines if ( !nl.size() ) { continue; } - + // Skip unused lines if ( nl.size() < 12 ) { 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); 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); int lineIdx = atoi(lineNumber.c_str())-1; if ( lineIdx >= 0 ) { - while ( vec->size() <= static_cast(lineIdx) ) + while ( vec->size() <= + static_cast(lineIdx) ) { vec->push_back(-1); } @@ -499,28 +541,39 @@ int cmCTestCoverageHandler::ProcessHandler() sourceFile.substr(0, sourceDir.size()) == sourceDir && sourceFile[sourceDir.size()] == '/' ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " << sourceFile.c_str() << std::endl); - ofs << " produced in source dir: " << sourceFile.c_str() << std::endl; - actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " + << sourceFile.c_str() << std::endl); + ofs << " produced in source dir: " << sourceFile.c_str() + << std::endl; + actualSourceFile + = cmSystemTools::CollapseFullPath(sourceFile.c_str()); } // Binary dir? if ( sourceFile.size() > binaryDir.size() && sourceFile.substr(0, binaryDir.size()) == binaryDir && sourceFile[binaryDir.size()] == '/' ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " << sourceFile.c_str() << std::endl); - ofs << " produced in binary dir: " << sourceFile.c_str() << std::endl; - actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " + << sourceFile.c_str() << std::endl); + ofs << " produced in binary dir: " << sourceFile.c_str() + << std::endl; + actualSourceFile + = cmSystemTools::CollapseFullPath(sourceFile.c_str()); } if ( actualSourceFile.empty() ) { if ( missingFiles.find(actualSourceFile) == missingFiles.end() ) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Something went wrong" << std::endl); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "File: [" << sourceFile.c_str() << "]" << std::endl); - 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() + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Something went wrong" + << std::endl); + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "File: [" + << sourceFile.c_str() << "]" << std::endl); + 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() << " or binary dir: " << binaryDir.c_str() << std::endl; missingFiles.insert(actualSourceFile); @@ -531,17 +584,19 @@ int cmCTestCoverageHandler::ProcessHandler() file_count ++; 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, " "); } } - + cmGeneratedFileStream covSumFile; cmGeneratedFileStream covLogFile; 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; } @@ -550,7 +605,8 @@ int cmCTestCoverageHandler::ProcessHandler() // Produce output xml files covSumFile << "" << std::endl - << "\t" << coverage_start_time << "" << std::endl; + << "\t" << coverage_start_time << "" + << std::endl; int logFileCount = 0; if ( !this->StartCoverageLogFile(covLogFile, logFileCount) ) { @@ -563,7 +619,8 @@ int cmCTestCoverageHandler::ProcessHandler() //std::string fullSourceDir = sourceDir + "/"; //std::string fullBinaryDir = binaryDir + "/"; 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, " "); std::vector errorsWhileAccumulating; @@ -577,7 +634,8 @@ int cmCTestCoverageHandler::ProcessHandler() file_count ++; 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); cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); } @@ -591,15 +649,19 @@ int cmCTestCoverageHandler::ProcessHandler() } } const std::string fullFileName = fileIterator->first; - const std::string fileName = cmSystemTools::GetFilenameName(fullFileName.c_str()); - std::string fullFilePath = cmSystemTools::GetFilenamePath(fullFileName.c_str()); - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Process file: " << fullFileName << std::endl); + const std::string fileName + = cmSystemTools::GetFilenameName(fullFileName.c_str()); + std::string fullFilePath + = cmSystemTools::GetFilenamePath(fullFileName.c_str()); + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Process file: " + << fullFileName << std::endl); cmSystemTools::ConvertToUnixSlashes(fullFilePath); 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; } @@ -608,7 +670,8 @@ int cmCTestCoverageHandler::ProcessHandler() sourceDir.c_str(), binaryDir.c_str()); 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() << std::endl); continue; @@ -641,12 +704,14 @@ int cmCTestCoverageHandler::ProcessHandler() if ( !cmSystemTools::GetLineFromStream(ifs, line) ) { 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()); error ++; break; } - covLogFile << "\t\t" + covLogFile << "\t\t" << m_CTest->MakeXMLSafe(line.c_str()) << "" << std::endl; if ( fcov[cc] == 0 ) { @@ -698,7 +763,8 @@ int cmCTestCoverageHandler::ProcessHandler() if ( errorsWhileAccumulating.size() > 0 ) { 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::iterator erIt; for ( erIt = errorsWhileAccumulating.begin(); erIt != errorsWhileAccumulating.end(); @@ -726,16 +792,17 @@ int cmCTestCoverageHandler::ProcessHandler() covSumFile.precision(2); covSumFile << (percent_coverage)<< "\n" << "\t" << end_time << "\n"; - covSumFile << "" << + covSumFile << "" << static_cast((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0 << "" << "" << std::endl; 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 << "\tTotal LOC: " << total_lines << std::endl - << "\tPercentage Coverage: " + << "\tPercentage Coverage: " << std::setiosflags(std::ios::fixed) << std::setprecision(2) << (percent_coverage) << "%" << std::endl); @@ -743,7 +810,7 @@ int cmCTestCoverageHandler::ProcessHandler() ofs << "\tCovered LOC: " << total_tested << std::endl << "\tNot covered LOC: " << total_untested << std::endl << "\tTotal LOC: " << total_lines << std::endl - << "\tPercentage Coverage: " + << "\tPercentage Coverage: " << std::setiosflags(std::ios::fixed) << std::setprecision(2) << (percent_coverage) << "%" << std::endl; @@ -760,14 +827,16 @@ int cmCTestCoverageHandler::ProcessHandler() //---------------------------------------------------------------------- void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) { - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude regular expressions." << std::endl); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE", + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, + " Add coverage exclude regular expressions." << std::endl); + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE", m_CustomCoverageExclude); std::vector::iterator it; for ( it = m_CustomCoverageExclude.begin(); it != m_CustomCoverageExclude.end(); ++ 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); } } diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index aa6a4cd75..2102843f9 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -39,16 +39,16 @@ public: * The main entry point for this class */ int ProcessHandler(); - + cmCTestCoverageHandler(); - + virtual void Initialize(); /** * This method is called when reading CTest custom file */ void PopulateCustomVectors(cmMakefile *mf); - + private: bool ShouldIDoCoverage(const char* file, const char* srcDir, const char* binDir); diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index d8ac1c030..9b7e904b5 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -30,13 +30,14 @@ class cmCTestEmptyBinaryDirectoryCommand : public cmCTestCommand public: cmCTestEmptyBinaryDirectoryCommand() {} - + /** * 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_CTestScriptHandler = this->m_CTestScriptHandler; return ni; @@ -56,11 +57,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "empties the binary directory"; } - + /** * More documentation. */ diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index a406d3eef..b5f964d93 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -41,7 +41,7 @@ void cmCTestGenericHandler::SetOption(const char* op, const char* value) } if ( !value ) { - cmCTestGenericHandler::t_StringToString::iterator remit + cmCTestGenericHandler::t_StringToString::iterator remit = m_Options.find(op); if ( remit != m_Options.end() ) { @@ -62,7 +62,7 @@ void cmCTestGenericHandler::Initialize() //---------------------------------------------------------------------- const char* cmCTestGenericHandler::GetOption(const char* op) { - cmCTestGenericHandler::t_StringToString::iterator remit + cmCTestGenericHandler::t_StringToString::iterator remit = m_Options.find(op); 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 ) { - 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; } cmOStringStream ostr; @@ -86,9 +89,11 @@ bool cmCTestGenericHandler::StartResultingXML(const char* name, cmGeneratedFileS ostr << "_" << m_SubmitIndex; } 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; } 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 ) { - 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; } cmOStringStream ostr; @@ -116,7 +123,8 @@ bool cmCTestGenericHandler::StartLogFile(const char* name, cmGeneratedFileStream ostr << ".log"; 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 true; diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index 29f199b2f..4b8e699c2 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -89,7 +89,7 @@ public: protected: bool StartResultingXML(const char* name, cmGeneratedFileStream& xofs); bool StartLogFile(const char* name, cmGeneratedFileStream& xofs); - + bool m_HandlerVerbose; cmCTest *m_CTest; t_StringToString m_Options; diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index fbb95c17a..e030a5f4e 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -38,7 +38,8 @@ cmCTestHandlerCommand::cmCTestHandlerCommand() bool cmCTestHandlerCommand::InitialPass( std::vector 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; } @@ -58,8 +59,11 @@ bool cmCTestHandlerCommand::InitialPass( { if ( m_CTest->GetDartVersion() <= 1 ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "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); + cmCTestLog(m_CTest, ERROR_MESSAGE, + "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 { @@ -69,7 +73,8 @@ bool cmCTestHandlerCommand::InitialPass( 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(); if ( m_Values[ct_RETURN_VALUE] && *m_Values[ct_RETURN_VALUE]) { @@ -81,8 +86,9 @@ bool cmCTestHandlerCommand::InitialPass( return true; } -bool cmCTestHandlerCommand::ProcessArguments(std::vector const& args, - int last, const char** strings, std::vector& values) +bool cmCTestHandlerCommand::ProcessArguments( + std::vector const& args, int last, const char** strings, + std::vector& values) { int state = 0; int cc; @@ -98,7 +104,8 @@ bool cmCTestHandlerCommand::ProcessArguments(std::vector const& arg { values[state] = args[i].c_str(); #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; } else @@ -112,7 +119,8 @@ bool cmCTestHandlerCommand::ProcessArguments(std::vector const& arg if ( values[state] ) { 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()); return false; } @@ -123,7 +131,9 @@ bool cmCTestHandlerCommand::ProcessArguments(std::vector const& arg if ( !found ) { 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()); return false; } diff --git a/Source/CTest/cmCTestHandlerCommand.h b/Source/CTest/cmCTestHandlerCommand.h index 2f6b5165b..1bdd1883f 100644 --- a/Source/CTest/cmCTestHandlerCommand.h +++ b/Source/CTest/cmCTestHandlerCommand.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index 9e66216c3..443672d44 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -31,11 +31,11 @@ class cmCTestMemCheckCommand : public cmCTestTestCommand public: cmCTestMemCheckCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestMemCheckCommand* ni = new cmCTestMemCheckCommand; ni->m_CTest = this->m_CTest; @@ -51,11 +51,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Tests the repository."; } - + /** * More documentation. */ @@ -64,8 +64,8 @@ public: return " CTEST_MEMCHECK([BUILD build_dir] [RETURN_VALUE res])\n" "Performs a memory checking of tests in the given build directory and " - "stores results in MemCheck.xml. The second argument is a variable that " - "will hold value."; + "stores results in MemCheck.xml. The second argument is a variable " + "that will hold value."; } cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 7665cba01..bf529b17b 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -25,7 +25,7 @@ #include #include "cmMakefile.h" -#include +#include #include #include @@ -117,7 +117,8 @@ int cmCTestMemCheckHandler::PreProcessHandler() 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 1; @@ -128,14 +129,16 @@ int cmCTestMemCheckHandler::PostProcessHandler() { 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 1; } //---------------------------------------------------------------------- -void cmCTestMemCheckHandler::GenerateTestCommand(std::vector& args) +void cmCTestMemCheckHandler::GenerateTestCommand( + std::vector& args) { std::vector::size_type pp; args.push_back(m_MemoryTester.c_str()); @@ -145,22 +148,24 @@ void cmCTestMemCheckHandler::GenerateTestCommand(std::vector& args) { args.push_back(m_MemoryTesterOptionsParsed[pp].c_str()); 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) { this->cmCTestTestHandler::PopulateCustomVectors(mf); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK", + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK", m_CustomPreMemCheck); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK", + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK", m_CustomPostMemCheck); - cmCTest::PopulateCustomVector(mf, - "CTEST_CUSTOM_MEMCHECK_IGNORE", + cmCTest::PopulateCustomVector(mf, + "CTEST_CUSTOM_MEMCHECK_IGNORE", m_CustomTestsIgnore); } @@ -202,7 +207,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) << "" << std::endl; } os << "\t\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 step = total / 10; unsigned int current = 0; @@ -212,7 +218,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) std::string memcheckstr; int memcheckresults[cmCTestMemCheckHandler::NO_MEMORY_FAULT]; 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 ) { continue; @@ -237,21 +244,22 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) m_CTest->GetShortPathToFile(result->m_Path.c_str())) << "\n" << "\t\t" << cmCTest::MakeXMLSafe( m_CTest->GetShortPathToFile(testPath.c_str())) << "\n" - << "\t\t" - << cmCTest::MakeXMLSafe(result->m_FullCommandLine) + << "\t\t" + << cmCTest::MakeXMLSafe(result->m_FullCommandLine) << "\n" << "\t\t" << std::endl; for ( kk = 0; cmCTestMemCheckResultLongStrings[kk]; kk ++ ) { if ( memcheckresults[kk] ) { - os << "\t\t\t" - << memcheckresults[kk] + os << "\t\t\t" + << memcheckresults[kk] << "" << std::endl; } m_MemoryTesterGlobalResults[kk] += memcheckresults[kk]; } - os + os << "\t\t\n" << "\t\n" << memcheckstr << std::endl << "\t\n" @@ -263,7 +271,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) } } 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" << std::endl; for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) { @@ -274,18 +283,20 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) #endif std::cerr.width(35); #define cerr no_cerr - cmCTestLog(m_CTest, HANDLER_OUTPUT, cmCTestMemCheckResultLongStrings[cc] << " - " + cmCTestLog(m_CTest, HANDLER_OUTPUT, cmCTestMemCheckResultLongStrings[cc] + << " - " << m_MemoryTesterGlobalResults[cc] << std::endl); - os << "\t\t" << std::endl; + os << "\t\t" << std::endl; } } os << "\t" << std::endl; os << "\t" << m_EndTest << "" << std::endl; - os << "" - << static_cast(m_ElapsedTestingTime/6)/10.0 + os << "" + << static_cast(m_ElapsedTestingTime/6)/10.0 << "\n"; - + os << "" << std::endl; m_CTest->EndXML(os); @@ -296,29 +307,37 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) bool cmCTestMemCheckHandler::InitializeMemoryChecking() { // Setup the command - if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration("MemoryCheckCommand").c_str()) ) + if ( cmSystemTools::FileExists(m_CTest->GetCTestConfiguration( + "MemoryCheckCommand").c_str()) ) { - m_MemoryTester - = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("MemoryCheckCommand").c_str()); + m_MemoryTester + = 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 - = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("PurifyCommand").c_str()); + m_MemoryTester + = 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 - = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration("ValgrindCommand").c_str()); + m_MemoryTester + = cmSystemTools::ConvertToOutputPath(m_CTest->GetCTestConfiguration( + "ValgrindCommand").c_str()); } 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); 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); } @@ -326,32 +345,42 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() // Setup the options 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() ) { - m_MemoryTesterOptions = m_CTest->GetCTestConfiguration("ValgrindCommandOptions"); + m_MemoryTesterOptions = m_CTest->GetCTestConfiguration( + "ValgrindCommandOptions"); } - m_MemoryTesterOutputFile = m_CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; - m_MemoryTesterOutputFile = cmSystemTools::EscapeSpaces(m_MemoryTesterOutputFile.c_str()); + m_MemoryTesterOutputFile + = m_CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; + m_MemoryTesterOutputFile + = cmSystemTools::EscapeSpaces(m_MemoryTesterOutputFile.c_str()); if ( m_MemoryTester.find("valgrind") != std::string::npos ) { m_MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; 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 ( !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: " - << m_CTest->GetCTestConfiguration("MemoryCheckSuppressionFile").c_str() << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, + "Cannot find memory checker suppression file: " + << m_CTest->GetCTestConfiguration( + "MemoryCheckSuppressionFile").c_str() << std::endl); 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 ) @@ -366,16 +395,19 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() else if ( m_MemoryTester.find("boundschecker") != std::string::npos ) { 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; } 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; } - m_MemoryTesterOptionsParsed = cmSystemTools::ParseArguments(m_MemoryTesterOptions.c_str()); + m_MemoryTesterOptionsParsed + = cmSystemTools::ParseArguments(m_MemoryTesterOptions.c_str()); std::vector::size_type 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::size_type cc; @@ -420,7 +452,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str, //---------------------------------------------------------------------- bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( - const std::string&, std::string& log, + const std::string&, std::string& log, int* results) { if ( !cmSystemTools::FileExists(m_MemoryTesterOutputFile.c_str()) ) @@ -462,8 +494,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( } if ( cc == cmCTestMemCheckHandler::NO_MEMORY_FAULT ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown Purify memory fault: " << pfW.match(1) << std::endl); - ostr << "*** Unknown Purify memory fault: " << pfW.match(1) << std::endl; + cmCTestLog(m_CTest, ERROR_MESSAGE, "Unknown Purify memory fault: " + << pfW.match(1) << std::endl); + ostr << "*** Unknown Purify memory fault: " << pfW.match(1) + << std::endl; } } if ( failure != NO_MEMORY_FAULT ) @@ -485,12 +519,12 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( //---------------------------------------------------------------------- bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( - const std::string& str, std::string& log, + const std::string& str, std::string& log, int* results) { std::vector lines; cmSystemTools::Split(str.c_str(), lines); - + std::string::size_type cc; cmOStringStream ostr; @@ -517,13 +551,15 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( " in loss record [0-9][0-9]* of [0-9]"); cmsys::RegularExpression vgUMC( "== .*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 vgUMR3("== .*Jump to the invalid address "); - cmsys::RegularExpression vgUMR4( - "== .*Syscall param .* contains uninitialised or unaddressable byte\\(s\\)"); + cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains " + "uninitialised or unaddressable byte\\(s\\)"); 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(); cmCTestLog(m_CTest, DEBUG, "Start test: " << lines.size() << std::endl); @@ -532,19 +568,58 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( if ( valgrindLine.find(lines[cc]) ) { int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT; - if ( vgFIM.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::FIM; } - else if ( vgFMM.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::FMM; } - else if ( vgMLK.find(lines[cc]) ) { failure = cmCTestMemCheckHandler::MLK; } - 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 ( vgFIM.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::FIM; + } + else if ( vgFMM.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::FMM; + } + else if ( vgMLK.find(lines[cc]) ) + { + failure = cmCTestMemCheckHandler::MLK; + } + 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 ) { @@ -555,7 +630,8 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( 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(); if ( defects ) { diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx index 88badc7e7..80c13f8c8 100644 --- a/Source/CTest/cmCTestRunScriptCommand.cxx +++ b/Source/CTest/cmCTestRunScriptCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -18,7 +18,8 @@ #include "cmCTestScriptHandler.h" -bool cmCTestRunScriptCommand::InitialPass(std::vector const& args) +bool cmCTestRunScriptCommand::InitialPass( + std::vector const& args) { if(args.size() < 1 ) { diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 34ec49361..67d556d6e 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -33,7 +33,7 @@ #include "windows.h" #endif -#include +#include #include #include #include @@ -67,13 +67,13 @@ public: cmMakefile &mf); //virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf); //virtual void ScopeEnded(cmMakefile &mf); - + cmCTestScriptHandler* m_CTestScriptHandler; }; // simply update the time and don't block anything bool cmCTestScriptFunctionBlocker:: -IsFunctionBlocked(const cmListFileFunction& , cmMakefile &) +IsFunctionBlocked(const cmListFileFunction& , cmMakefile &) { m_CTestScriptHandler->UpdateElapsedTime(); return false; @@ -82,7 +82,7 @@ IsFunctionBlocked(const cmListFileFunction& , cmMakefile &) //---------------------------------------------------------------------- cmCTestScriptHandler::cmCTestScriptHandler() { - m_Backup = false; + m_Backup = false; m_EmptyBinDir = false; m_EmptyBinDirOnce = false; m_Makefile = 0; @@ -91,7 +91,7 @@ cmCTestScriptHandler::cmCTestScriptHandler() m_GlobalGenerator = 0; m_ScriptStartTime = 0; - + // the *60 is becuase the settings are in minutes but GetTime is seconds m_MinimumInterval = 30*60; m_ContinuousDuration = -1; @@ -104,7 +104,7 @@ void cmCTestScriptHandler::Initialize() m_Backup = false; m_EmptyBinDir = false; m_EmptyBinDirOnce = false; - + m_SourceDir = ""; m_BinaryDir = ""; m_BackupSourceDir = ""; @@ -124,7 +124,7 @@ void cmCTestScriptHandler::Initialize() // what time in seconds did this script start running m_ScriptStartTime = 0; - + m_Makefile = 0; 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_arg = total_script_arg.substr(total_script_arg.find(",")+1); } - + // make sure the file exists 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->SetGlobalGenerator(m_GlobalGenerator); m_Makefile = m_LocalGenerator->GetMakefile(); - + // set a variable with the path to the current script m_Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY", cmSystemTools::GetFilenamePath(script).c_str()); @@ -268,7 +268,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) m_CTest->GetCMakeExecutable()); m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true); this->UpdateElapsedTime(); - + // add any ctest specific commands, probably should have common superclass // for ctest commands to clean this up. If a couple more commands are // 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 cmCTestTestCommand); this->AddCTestCommand(new cmCTestUpdateCommand); - + // add the script arg if defined if (script_arg.size()) { @@ -294,13 +294,13 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmCTestScriptFunctionBlocker *f = new cmCTestScriptFunctionBlocker(); f->m_CTestScriptHandler = this; m_Makefile->AddFunctionBlocker(f); - + // finally read in the script if (!m_Makefile->ReadListFile(0, script.c_str())) { return 2; } - + return 0; } @@ -322,13 +322,16 @@ int cmCTestScriptHandler::ExtractVariables() m_CTestEnv = m_Makefile->GetSafeDefinition("CTEST_ENVIRONMENT"); m_InitCache = m_Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE"); 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_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"); char updateVar[40]; @@ -341,7 +344,8 @@ int cmCTestScriptHandler::ExtractVariables() { if ( m_CVSCmd.empty() ) { - cmSystemTools::Error(updateVar, " specified without specifying CTEST_CVS_COMMAND."); + cmSystemTools::Error(updateVar, + " specified without specifying CTEST_CVS_COMMAND."); return 12; } m_ExtraUpdates.push_back(updateVal); @@ -352,13 +356,13 @@ int cmCTestScriptHandler::ExtractVariables() if (m_Backup && m_CVSCheckOut.empty()) { cmSystemTools::Error( - "Backup was requested without specifying CTEST_CVS_CHECKOUT."); + "Backup was requested without specifying CTEST_CVS_CHECKOUT."); return 3; } - + // make sure the required info is here - if (this->m_SourceDir.empty() || - this->m_BinaryDir.empty() || + if (this->m_SourceDir.empty() || + this->m_BinaryDir.empty() || this->m_CTestCmd.empty()) { std::string message = "CTEST_SOURCE_DIRECTORY = "; @@ -372,7 +376,7 @@ int cmCTestScriptHandler::ExtractVariables() message.c_str()); return 4; } - + // if the dashboard root isn't specified then we can compute it from the // m_SourceDir if (m_CTestRoot.empty() ) @@ -389,8 +393,8 @@ int cmCTestScriptHandler::ExtractVariables() { m_ContinuousDuration = 60.0 * atof(contDuration); } - - + + this->UpdateElapsedTime(); return 0; @@ -408,20 +412,21 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait) //---------------------------------------------------------------------- // run a specific script -int cmCTestScriptHandler::RunConfigurationScript(const std::string& total_script_arg) +int cmCTestScriptHandler::RunConfigurationScript( + const std::string& total_script_arg) { int result; - - m_ScriptStartTime = + + m_ScriptStartTime = cmSystemTools::GetTime(); - + // read in the script result = this->ReadInScript(total_script_arg); if (result) { return result; } - + // only run the curent script if we should if (m_Makefile && m_Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT")) { @@ -440,14 +445,14 @@ int cmCTestScriptHandler::RunCurrentScript() // no popup widows cmSystemTools::SetRunCommandHideConsole(true); - + // extract the vars from the cache and store in ivars result = this->ExtractVariables(); if (result) { return result; } - + // set any environment variables if (!m_CTestEnv.empty()) { @@ -503,21 +508,22 @@ int cmCTestScriptHandler::CheckOutSourceDir() std::string command; std::string output; int retVal; - bool res; + bool res; - if (!cmSystemTools::FileExists(m_SourceDir.c_str()) && + if (!cmSystemTools::FileExists(m_SourceDir.c_str()) && !m_CVSCheckOut.empty()) { // we must now checkout the src dir output = ""; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << m_CVSCheckOut << std::endl); - res = cmSystemTools::RunSingleCommand(m_CVSCheckOut.c_str(), &output, + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << m_CVSCheckOut + << std::endl); + res = cmSystemTools::RunSingleCommand(m_CVSCheckOut.c_str(), &output, &retVal, m_CTestRoot.c_str(), m_HandlerVerbose, 0 /*m_TimeOut*/); if (!res || retVal != 0) { - cmSystemTools::Error("Unable to perform cvs checkout:\n", - output.c_str()); + cmSystemTools::Error("Unable to perform cvs checkout:\n", + output.c_str()); return 6; } } @@ -534,7 +540,7 @@ int cmCTestScriptHandler::BackupDirectories() m_BackupSourceDir += "_CMakeBackup"; m_BackupBinaryDir = m_BinaryDir; m_BackupBinaryDir += "_CMakeBackup"; - + // backup the binary and src directories if requested if (m_Backup) { @@ -547,11 +553,11 @@ int cmCTestScriptHandler::BackupDirectories() { 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_BinaryDir.c_str(), m_BackupBinaryDir.c_str()); - + // we must now checkout the src dir retVal = this->CheckOutSourceDir(); if (retVal) @@ -571,7 +577,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() std::string command; std::string output; int retVal; - bool res; + bool res; // do an initial cvs update as required command = m_CVSCmd; @@ -587,13 +593,14 @@ int cmCTestScriptHandler::PerformExtraUpdates() fullCommand += cvsArgs[1]; output = ""; retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run CVS: " << fullCommand.c_str() << std::endl); - res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run CVS: " + << fullCommand.c_str() << std::endl); + res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, &retVal, cvsArgs[0].c_str(), m_HandlerVerbose, 0 /*m_TimeOut*/); 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()); return 0; } @@ -611,7 +618,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() std::string command; std::string output; int retVal; - bool res; + bool res; // make sure the src directory is there, if it isn't then we might be able // to check it out from cvs @@ -627,24 +634,25 @@ int cmCTestScriptHandler::RunConfigurationDashboard() { return retVal; } - + // clear the binary directory? if (m_EmptyBinDir) { 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 - if (!cmSystemTools::FileExists(m_BinaryDir.c_str()) && + if (!cmSystemTools::FileExists(m_BinaryDir.c_str()) && m_SourceDir != m_BinaryDir) { if (!cmSystemTools::MakeDirectory(m_BinaryDir.c_str())) { - cmSystemTools::Error("Unable to create the binary directory:\n", - m_BinaryDir.c_str()); + cmSystemTools::Error("Unable to create the binary directory:\n", + m_BinaryDir.c_str()); this->RestoreBackupDirectories(); return 7; } @@ -658,10 +666,14 @@ int cmCTestScriptHandler::RunConfigurationDashboard() // make sure we have the required info 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; } - + // we must now checkout the src dir retVal = this->CheckOutSourceDir(); if (retVal) @@ -670,7 +682,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() return retVal; } } - + // backup the dirs if requested retVal = this->PerformExtraUpdates(); if (retVal) @@ -710,8 +722,9 @@ int cmCTestScriptHandler::RunConfigurationDashboard() output = ""; command += "\""; retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " << command.c_str() << std::endl); - res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " + << command.c_str() << std::endl); + res = cmSystemTools::RunSingleCommand(command.c_str(), &output, &retVal, m_BinaryDir.c_str(), m_HandlerVerbose, 0 /*m_TimeOut*/); @@ -723,7 +736,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard() 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); cmGeneratedFileStream fout(cmakeOutputFile.c_str()); if ( fout ) @@ -753,11 +767,12 @@ int cmCTestScriptHandler::RunConfigurationDashboard() command = ctestCommands[i]; output = ""; retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " << command.c_str() << std::endl); - res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " + << command.c_str() << std::endl); + res = cmSystemTools::RunSingleCommand(command.c_str(), &output, &retVal, m_BinaryDir.c_str(), m_HandlerVerbose, 0 /*m_TimeOut*/); - + // did something critical fail in ctest if (!res || cmakeFailed || retVal & cmCTest::BUILD_ERRORS) @@ -778,7 +793,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() return retVal * 100; } } - + // if all was succesful, delete the backup dirs to free up disk space if (m_Backup) { @@ -786,7 +801,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() cmSystemTools::RemoveADirectory(m_BackupBinaryDir.c_str()); } - return 0; + return 0; } @@ -806,7 +821,7 @@ void cmCTestScriptHandler::RestoreBackupDirectories() { 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_BackupBinaryDir.c_str(), m_BinaryDir.c_str()); } @@ -829,7 +844,7 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname) { return false; } - + // try to avoid deleting directories that we shouldn't std::string check = sname; check += "/CMakeCache.txt"; diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 20e657194..1160805c2 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -56,19 +56,22 @@ bool cmCTestStartCommand::InitialPass( } 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; } 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; } m_CTest->EmptyCTestConfiguration(); 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 << " Build directory: " << bld_dir << std::endl); diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index 2bed7d77f..3e81d3316 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,11 +29,11 @@ class cmCTestStartCommand : public cmCTestCommand public: cmCTestStartCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestStartCommand* ni = new cmCTestStartCommand; ni->m_CTest = this->m_CTest; @@ -55,11 +55,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Starts the testing for a given model"; } - + /** * More documentation. */ @@ -67,10 +67,10 @@ public: { return " CTEST_START(Model [source [binary]])\n" - "Starts the testing for a given model. The command should be called after " - "the binary directory is initialized. If the 'source' and 'binary' " - "directory are not specified, it reads the CTEST_SOURCE_DIRECTORY and " - "CTEST_BINARY_DIRECTORY."; + "Starts the testing for a given model. The command should be called " + "after the binary directory is initialized. If the 'source' and " + "'binary' directory are not specified, it reads the " + "CTEST_SOURCE_DIRECTORY and CTEST_BINARY_DIRECTORY."; } cmTypeMacro(cmCTestStartCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 3026e9261..bfa0edb8e 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -36,24 +36,30 @@ bool cmCTestSubmitCommand::InitialPass( { 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; } havereturn_variable = true; - } + } else { 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()); return false; } } - const char* ctestDropMethod = m_Makefile->GetDefinition("CTEST_DROP_METHOD"); - const char* ctestDropSite = m_Makefile->GetDefinition("CTEST_DROP_SITE"); - const char* ctestDropLocation = m_Makefile->GetDefinition("CTEST_DROP_LOCATION"); - const char* ctestTriggerSite = m_Makefile->GetDefinition("CTEST_TRIGGER_SITE"); + const char* ctestDropMethod + = m_Makefile->GetDefinition("CTEST_DROP_METHOD"); + const char* ctestDropSite + = 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 ) { @@ -69,8 +75,10 @@ bool cmCTestSubmitCommand::InitialPass( } if ( !ctestTriggerSite ) { - ctestTriggerSite = "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi"; - cmCTestLog(m_CTest, HANDLER_OUTPUT, "* Use default trigger site: " << ctestTriggerSite << std::endl;); + ctestTriggerSite + = "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi"; + cmCTestLog(m_CTest, HANDLER_OUTPUT, "* Use default trigger site: " + << ctestTriggerSite << std::endl;); } m_CTest->SetCTestConfiguration("DropMethod", ctestDropMethod); @@ -78,18 +86,22 @@ bool cmCTestSubmitCommand::InitialPass( m_CTest->SetCTestConfiguration("DropLocation", ctestDropLocation); m_CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "ScpCommand", "CTEST_SCP_COMMAND"); + m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, + "DropSiteUser", "CTEST_DROP_SITE_USER"); + 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) { std::vector notesFiles; std::vector newNotesFiles; cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles); std::vector::iterator it; - for ( it = notesFiles.begin(); + for ( it = notesFiles.begin(); it != notesFiles.end(); ++ it ) { @@ -97,14 +109,15 @@ bool cmCTestSubmitCommand::InitialPass( } 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) { std::vector extraFiles; std::vector newExtraFiles; cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles); std::vector::iterator it; - for ( it = extraFiles.begin(); + for ( it = extraFiles.begin(); it != extraFiles.end(); ++ it ) { diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 8eb077165..843c652c2 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -22,18 +22,19 @@ /** \class cmCTestSubmit * \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 { public: cmCTestSubmitCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestSubmitCommand* ni = new cmCTestSubmitCommand; ni->m_CTest = this->m_CTest; @@ -55,11 +56,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Submits the repository."; } - + /** * More documentation. */ diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index e8feadea3..4f71b6b07 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -9,8 +9,8 @@ Version: $Revision$ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -36,11 +36,13 @@ PURPOSE. See the above copyright notices for more information. typedef std::vector cmCTestSubmitHandlerVectorOfChar; 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; - cmCTestSubmitHandlerVectorOfChar *vec = static_cast(data); + cmCTestSubmitHandlerVectorOfChar *vec + = static_cast(data); const char* chPtr = static_cast(ptr); vec->insert(vec->end(), chPtr, chPtr + realsize); @@ -48,9 +50,11 @@ cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, vo } 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(data); + cmCTestSubmitHandlerVectorOfChar *vec + = static_cast(data); vec->insert(vec->end(), chPtr, chPtr + 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& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url) { CURL *curl; @@ -98,12 +102,12 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, { /* get a curl handle */ curl = curl_easy_init(); - if(curl) + if(curl) { // Using proxy 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) { case 2: @@ -113,7 +117,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); break; 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; } - cmStdString upload_as = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); + cmStdString upload_as + = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); struct stat 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_global_cleanup(); + ::curl_global_cleanup(); return false; } ftpfile = ::fopen(local_file.c_str(), "rb"); *m_LogFile << "\tUpload file: " << local_file.c_str() << " to " << upload_as.c_str() << std::endl; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " + << local_file.c_str() << " to " << upload_as.c_str() << std::endl); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); @@ -151,14 +158,17 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); // and give the size of the upload (optional) - ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast(st.st_size)); + ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, + static_cast(st.st_size)); // and give curl the buffer for errors ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); // specify handler for output - ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); - ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); + ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, + cmCTestSubmitHandlerWriteMemoryCallback); + ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, + cmCTestSubmitHandlerCurlDebugCallback); /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; @@ -172,42 +182,50 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, if ( chunk.size() > 0 ) { cmCTestLog(m_CTest, DEBUG, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); } if ( chunkDebug.size() > 0 ) { cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" - << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); + << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" + << std::endl); } fclose(ftpfile); if ( res ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " + << local_file.c_str() << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " + << error_buffer << std::endl); + *m_LogFile << " Error when uploading file: " << local_file.c_str() + << std::endl << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + << " Curl output was: " + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; 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_global_cleanup(); + ::curl_global_cleanup(); return false; } // always cleanup ::curl_easy_cleanup(curl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file + << std::endl); } } - ::curl_global_cleanup(); + ::curl_global_cleanup(); return true; } //---------------------------------------------------------------------------- // Uploading files is simpler -bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, +bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url) { CURL *curl; @@ -224,13 +242,13 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, { /* get a curl handle */ curl = curl_easy_init(); - if(curl) + if(curl) { // Using proxy 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) { case 2: @@ -261,7 +279,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, { 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 " << remote_file.c_str() << std::endl; @@ -285,25 +304,27 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, sprintf(hexCh, "%%%02X", (int)c); ofile.append(hexCh); break; - default: + default: ofile.append(hexCh); } } - cmStdString upload_as - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + cmStdString upload_as + = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + "FileName=" + ofile; struct stat 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_global_cleanup(); + ::curl_global_cleanup(); return false; } 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); @@ -314,14 +335,17 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); // and give the size of the upload (optional) - ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast(st.st_size)); + ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, + static_cast(st.st_size)); // and give curl the buffer for errors ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); // specify handler for output - ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); - ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); + ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, + cmCTestSubmitHandlerWriteMemoryCallback); + ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, + cmCTestSubmitHandlerCurlDebugCallback); /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; @@ -335,40 +359,49 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, if ( chunk.size() > 0 ) { cmCTestLog(m_CTest, DEBUG, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); } if ( chunkDebug.size() > 0 ) { cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" - << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); + << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" + << std::endl); } fclose(ftpfile); if ( res ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when uploading file: " + << local_file.c_str() << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " + << error_buffer << std::endl); + *m_LogFile << " Error when uploading file: " << local_file.c_str() + << std::endl << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + << " Curl output was: " + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; 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_global_cleanup(); + ::curl_global_cleanup(); return false; } // always cleanup ::curl_easy_cleanup(curl); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Uploaded: " + local_file + << std::endl); } } - ::curl_global_cleanup(); + ::curl_global_cleanup(); return true; } //---------------------------------------------------------------------------- -bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, - const cmStdString& remoteprefix, +bool cmCTestSubmitHandler::TriggerUsingHTTP( + const std::set& files, + const cmStdString& remoteprefix, const cmStdString& url) { CURL *curl; @@ -382,12 +415,12 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, { /* get a curl handle */ curl = curl_easy_init(); - if(curl) + if(curl) { // Using proxy 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) { case 2: @@ -397,7 +430,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); break; default: - curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); if (m_HTTPProxyAuth.size() > 0) { curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, @@ -412,8 +445,10 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); // specify handler for output - ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); - ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback); + ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, + cmCTestSubmitHandlerWriteMemoryCallback); + ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, + cmCTestSubmitHandlerCurlDebugCallback); /* we pass our 'chunk' struct to the callback function */ cmCTestSubmitHandlerVectorOfChar chunk; @@ -421,7 +456,8 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); - cmStdString rfile = remoteprefix + cmSystemTools::GetFilenameName(*file); + cmStdString rfile + = remoteprefix + cmSystemTools::GetFilenameName(*file); cmStdString ofile = ""; cmStdString::iterator kk; for ( kk = rfile.begin(); kk < rfile.end(); ++ kk) @@ -442,39 +478,47 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, sprintf(hexCh, "%%%02X", (int)c); ofile.append(hexCh); break; - default: + default: ofile.append(hexCh); } } - cmStdString turl - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + cmStdString turl + = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + "xmlfile=" + ofile; *m_LogFile << "Trigger url: " << turl.c_str() << std::endl; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " << turl.c_str() << std::endl); + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " + << turl.c_str() << std::endl); curl_easy_setopt(curl, CURLOPT_URL, turl.c_str()); if ( curl_easy_perform(curl) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when triggering: " << turl.c_str() << std::endl); - cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *m_LogFile << "\tTrigerring failed with error: " << error_buffer << std::endl + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error when triggering: " + << turl.c_str() << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, " Error message was: " + << error_buffer << std::endl); + *m_LogFile << "\tTrigerring failed with error: " << error_buffer + << std::endl << " Error message was: " << error_buffer << std::endl - << " Curl output was: " << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + << " Curl output was: " + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; 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_global_cleanup(); + ::curl_global_cleanup(); return false; } if ( chunk.size() > 0 ) { cmCTestLog(m_CTest, DEBUG, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); } if ( chunkDebug.size() > 0 ) { cmCTestLog(m_CTest, DEBUG, "CURL debug output: [" - << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl); + << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) + << "]" << std::endl); } // always cleanup @@ -482,17 +526,18 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set& files, cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl); } } - ::curl_global_cleanup(); - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Dart server triggered..." << std::endl); + ::curl_global_cleanup(); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Dart server triggered..." + << std::endl); return true; } //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingSCP( - const cmStdString& scp_command, - const cmStdString& localprefix, + const cmStdString& scp_command, + const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url) { if ( !scp_command.size() || !localprefix.size() || @@ -524,9 +569,10 @@ bool cmCTestSubmitHandler::SubmitUsingSCP( argv[1] = lfname.c_str(); std::string rfname = url + "/" + remoteprefix + *file; 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); - *m_LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \"" + *m_LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \"" << argv[2] << "\"" << std::endl; cmsysProcess_SetCommand(cp, &*argv.begin()); @@ -536,7 +582,8 @@ bool cmCTestSubmitHandler::SubmitUsingSCP( 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); @@ -548,7 +595,8 @@ bool cmCTestSubmitHandler::SubmitUsingSCP( retVal = cmsysProcess_GetExitValue(cp); 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; problems ++; } @@ -556,16 +604,18 @@ bool cmCTestSubmitHandler::SubmitUsingSCP( else if(result == cmsysProcess_State_Exception) { 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; problems ++; } 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; problems ++; - } + } else if(result == cmsysProcess_State_Error) { 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& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url) { xmlrpc_env env; @@ -601,7 +651,8 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, xmlrpc_env_init(&env); /* Call the famous server at UserLand. */ - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submitting to: " << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submitting to: " + << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl); cmCTest::tm_SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { @@ -612,11 +663,13 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, { 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; 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; } @@ -624,7 +677,8 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, FILE* fp = fopen(local_file.c_str(), "rb"); 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; } @@ -633,7 +687,8 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, { delete [] fileBuffer; 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; } fclose(fp); @@ -647,7 +702,8 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, 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_client_cleanup(); return false; @@ -668,10 +724,13 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, //---------------------------------------------------------------------------- int cmCTestSubmitHandler::ProcessHandler() { - const std::string &buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory"); + const std::string &buildDirectory + = m_CTest->GetCTestConfiguration("BuildDirectory"); 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; } @@ -742,11 +801,13 @@ int cmCTestSubmitHandler::ProcessHandler() if ( m_HTTPProxy.size() > 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use HTTP Proxy: " << m_HTTPProxy << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use HTTP Proxy: " << m_HTTPProxy + << std::endl); } if ( m_FTPProxy.size() > 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use FTP Proxy: " << m_FTPProxy << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use FTP Proxy: " << m_FTPProxy + << std::endl); } cmGeneratedFileStream ofs; this->StartLogFile("Submit", ofs); @@ -762,17 +823,20 @@ int cmCTestSubmitHandler::ProcessHandler() if ( m_CTest->AddIfExists(files, "Coverage.xml") ) { 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; 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) ) { size_t cc; for ( cc = 0; cc < gfiles.size(); cc ++ ) { 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]); } } @@ -803,60 +867,75 @@ int cmCTestSubmitHandler::ProcessHandler() 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); this->SetLogFile(&ofs); if ( m_CTest->GetCTestConfiguration("DropMethod") == "" || m_CTest->GetCTestConfiguration("DropMethod") == "ftp" ) { ofs << "Using drop method: FTP" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using FTP submit method" << std::endl + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using FTP submit method" + << std::endl << " Drop site: ftp://"); std::string url = "ftp://"; - url += cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropSiteUser")) + ":" + - cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropSitePassword")) + "@" + - m_CTest->GetCTestConfiguration("DropSite") + + url += cmCTest::MakeURLSafe( + m_CTest->GetCTestConfiguration("DropSiteUser")) + ":" + + cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration( + "DropSitePassword")) + "@" + + m_CTest->GetCTestConfiguration("DropSite") + cmCTest::MakeURLSafe(m_CTest->GetCTestConfiguration("DropLocation")); if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); + cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration( + "DropSiteUser").c_str()); if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) { cmCTestLog(m_CTest, HANDLER_OUTPUT, ":******"); } cmCTestLog(m_CTest, HANDLER_OUTPUT, "@"); } - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSite") + cmCTestLog(m_CTest, HANDLER_OUTPUT, + m_CTest->GetCTestConfiguration("DropSite") << 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) ) { - 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; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" << std::endl - << " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") << std::endl); - if ( !this->TriggerUsingHTTP(files, prefix, m_CTest->GetCTestConfiguration("TriggerSite")) ) + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" + << std::endl + << " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") + << std::endl); + if ( !this->TriggerUsingHTTP(files, prefix, + m_CTest->GetCTestConfiguration("TriggerSite")) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when triggering via HTTP" << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, + " Problems when triggering via HTTP" << std::endl); ofs << " Problems when triggering via HTTP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" + << std::endl); ofs << " Submission successful" << std::endl; return 0; } else if ( m_CTest->GetCTestConfiguration("DropMethod") == "http" ) { ofs << "Using drop method: HTTP" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP submit method" << std::endl + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP submit method" + << std::endl << " Drop site: http://"); std::string url = "http://"; if ( m_CTest->GetCTestConfiguration("DropSiteUser").size() > 0 ) { url += m_CTest->GetCTestConfiguration("DropSiteUser"); - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); + cmCTestLog(m_CTest, HANDLER_OUTPUT, + m_CTest->GetCTestConfiguration("DropSiteUser").c_str()); if ( m_CTest->GetCTestConfiguration("DropSitePassword").size() > 0 ) { url += ":" + m_CTest->GetCTestConfiguration("DropSitePassword"); @@ -865,40 +944,53 @@ int cmCTestSubmitHandler::ProcessHandler() url += "@"; cmCTestLog(m_CTest, HANDLER_OUTPUT, "@"); } - url += m_CTest->GetCTestConfiguration("DropSite") + m_CTest->GetCTestConfiguration("DropLocation"); - cmCTestLog(m_CTest, HANDLER_OUTPUT, m_CTest->GetCTestConfiguration("DropSite") + url += m_CTest->GetCTestConfiguration("DropSite") + + m_CTest->GetCTestConfiguration("DropLocation"); + cmCTestLog(m_CTest, HANDLER_OUTPUT, + m_CTest->GetCTestConfiguration("DropSite") << m_CTest->GetCTestConfiguration("DropLocation") << std::endl); - if ( !this->SubmitUsingHTTP(buildDirectory +"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) + 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; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" << std::endl - << " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") << std::endl); - if ( !this->TriggerUsingHTTP(files, prefix, m_CTest->GetCTestConfiguration("TriggerSite")) ) + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using HTTP trigger method" + << std::endl + << " Trigger site: " << m_CTest->GetCTestConfiguration("TriggerSite") + << std::endl); + if ( !this->TriggerUsingHTTP(files, prefix, + m_CTest->GetCTestConfiguration("TriggerSite")) ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, " Problems when triggering via HTTP" << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, + " Problems when triggering via HTTP" << std::endl); ofs << " Problems when triggering via HTTP" << std::endl; return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Submission successful" + << std::endl); ofs << " Submission successful" << std::endl; return 0; } else if ( m_CTest->GetCTestConfiguration("DropMethod") == "xmlrpc" ) { ofs << "Using drop method: XML-RPC" << std::endl; - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using XML-RPC submit method" << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Using XML-RPC submit method" + << std::endl); std::string url = m_CTest->GetCTestConfiguration("DropSite"); prefix = m_CTest->GetCTestConfiguration("DropLocation"); - if ( !this->SubmitUsingXMLRPC(buildDirectory+"/Testing/"+m_CTest->GetCurrentTag(), files, prefix, url) ) + 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; 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; return 0; } @@ -910,7 +1002,8 @@ int cmCTestSubmitHandler::ProcessHandler() { 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 // 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) ) { 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; return -1; } 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; 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; } diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index c35029c55..746f0205e 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -63,7 +63,8 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() { testsToRunString << m_Values[ctt_STRIDE]; } - handler->SetOption("TestsToRunInformation", testsToRunString.str().c_str()); + handler->SetOption("TestsToRunInformation", + testsToRunString.str().c_str()); } return handler; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 97527553c..8c9d29cd5 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,7 +29,7 @@ #include "cmCommand.h" #include "cmSystemTools.h" -#include +#include #include #include @@ -42,7 +42,7 @@ public: /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestSubdirCommand* c = new cmCTestSubdirCommand; c->m_TestHandler = m_TestHandler; @@ -78,14 +78,14 @@ bool cmCTestSubdirCommand::InitialPass(std::vector const& args) return false; } std::vector::const_iterator it; - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); + std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); for ( it = args.begin(); it != args.end(); ++ it ) { cmSystemTools::ChangeDirectory(cwd.c_str()); std::string fname = cwd; fname += "/"; fname += *it; - + if ( !cmSystemTools::FileExists(fname.c_str()) ) { // No subdirectory? So what... @@ -111,7 +111,8 @@ bool cmCTestSubdirCommand::InitialPass(std::vector const& args) } fname += "/"; 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()); if(!readit) { @@ -131,7 +132,7 @@ public: /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestAddTestCommand* c = new cmCTestAddTestCommand; c->m_TestHandler = m_TestHandler; @@ -176,9 +177,10 @@ public: /** * 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; return c; } @@ -204,7 +206,8 @@ public: }; //---------------------------------------------------------------------- -bool cmCTestSetTestsPropertiesCommand::InitialPass(std::vector const& args) +bool cmCTestSetTestsPropertiesCommand::InitialPass( + std::vector const& args) { return m_TestHandler->SetTestsProperties(args); } @@ -224,15 +227,15 @@ bool TryExecutable(const char *dir, const char *file, tryPath = dir; tryPath += "/"; } - + if (subdir && strcmp(subdir,"")) { tryPath += subdir; tryPath += "/"; } - + tryPath += file; - + // find the file without an executable extension if(cmSystemTools::FileExists(tryPath.c_str())) { @@ -247,7 +250,7 @@ bool TryExecutable(const char *dir, const char *file, *fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); return true; } - + // not found at all, 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 , // 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. -inline int GetNextNumber(std::string const& in, +inline int GetNextNumber(std::string const& in, int& val, std::string::size_type& pos, 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 , // 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. -inline int GetNextRealNumber(std::string const& in, +inline int GetNextRealNumber(std::string const& in, double& val, std::string::size_type& pos, std::string::size_type& pos2) @@ -328,19 +331,19 @@ inline int GetNextRealNumber(std::string const& in, } } - + //---------------------------------------------------------------------- cmCTestTestHandler::cmCTestTestHandler() { m_UseUnion = false; - + m_UseIncludeRegExp = false; m_UseExcludeRegExp = false; m_UseExcludeRegExpFirst = false; m_CustomMaximumPassedTestOutputSize = 1 * 1024; m_CustomMaximumFailedTestOutputSize = 300 * 1024; - + m_MemCheck = false; m_LogFile = 0; @@ -382,18 +385,18 @@ void cmCTestTestHandler::Initialize() //---------------------------------------------------------------------- void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf) { - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST", + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST", m_CustomPreTest); - cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST", + cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST", m_CustomPostTest); cmCTest::PopulateCustomVector(mf, - "CTEST_CUSTOM_TESTS_IGNORE", + "CTEST_CUSTOM_TESTS_IGNORE", m_CustomTestsIgnore); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE", + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE", m_CustomMaximumPassedTestOutputSize); - cmCTest::PopulateCustomInteger(mf, - "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE", + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE", m_CustomMaximumFailedTestOutputSize); } @@ -402,7 +405,8 @@ int cmCTestTestHandler::PreProcessHandler() { 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 1; @@ -413,7 +417,8 @@ int cmCTestTestHandler::PostProcessHandler() { 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 1; @@ -443,7 +448,8 @@ int cmCTestTestHandler::ProcessHandler() 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() ) { return -1; @@ -465,18 +471,20 @@ int cmCTestTestHandler::ProcessHandler() { 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 { - if (m_HandlerVerbose && passed.size() && - (m_UseIncludeRegExp || m_UseExcludeRegExp)) + if (m_HandlerVerbose && passed.size() && + (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::iterator j = passed.begin(); j != passed.end(); ++j) - { + { cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j << std::endl); } } @@ -486,16 +494,18 @@ int cmCTestTestHandler::ProcessHandler() { percent = 99; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl << static_cast(percent + .5) << "% tests passed, " + cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl + << static_cast(percent + .5) << "% tests passed, " << failed.size() << " tests failed out of " << total << std::endl); //fprintf(stderr,"\n%.0f%% tests passed, %i tests failed out of %i\n", // percent, int(failed.size()), total); - if (failed.size()) + if (failed.size()) { 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); std::vector::iterator ftit; @@ -505,9 +515,9 @@ int cmCTestTestHandler::ProcessHandler() if ( ftit->m_Status != cmCTestTestHandler::COMPLETED ) { 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); - //fprintf(stderr, "\t%3d - %s (%s)\n", ftit->m_TestCount, ftit->m_Name.c_str(), - // this->GetTestStatus(ftit->m_Status)); + cmCTestLog(m_CTest, HANDLER_OUTPUT, "\t" << std::setw(3) + << ftit->m_TestCount << " - " << ftit->m_Name.c_str() << " (" + << this->GetTestStatus(ftit->m_Status) << ")" << std::endl); } } @@ -517,9 +527,11 @@ int cmCTestTestHandler::ProcessHandler() if ( m_CTest->GetProduceXML() ) { 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); m_LogFile = 0; return 1; @@ -543,7 +555,7 @@ int cmCTestTestHandler::ProcessHandler() } //---------------------------------------------------------------------- -void cmCTestTestHandler::ProcessDirectory(std::vector &passed, +void cmCTestTestHandler::ProcessDirectory(std::vector &passed, std::vector &failed) { std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); @@ -578,7 +590,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, { this->ExpandTestsToRunInformation(inREcnt); } - + int cnt = 0; inREcnt = 0; std::string last_directory = ""; @@ -599,7 +611,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, 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"); *m_LogFile << "Changing directory into: " << it->m_Directory.c_str() << std::endl; @@ -608,12 +620,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, } cres.m_Name = testname; cres.m_Path = it->m_Directory.c_str(); - + if (m_UseUnion) { // if it is not in the list and not in the regexp then skip - if ((m_TestsToRun.size() && - std::find(m_TestsToRun.begin(), m_TestsToRun.end(), cnt) + if ((m_TestsToRun.size() && + std::find(m_TestsToRun.begin(), m_TestsToRun.end(), cnt) == m_TestsToRun.end()) && !it->m_IsInBasedOnREOptions) { continue; @@ -622,8 +634,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, else { // is this test in the list of tests to run? If not then skip it - if ((m_TestsToRun.size() && - std::find(m_TestsToRun.begin(), m_TestsToRun.end(), inREcnt) + if ((m_TestsToRun.size() && + std::find(m_TestsToRun.begin(), m_TestsToRun.end(), inREcnt) == m_TestsToRun.end()) || !it->m_IsInBasedOnREOptions) { continue; @@ -654,11 +666,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, { cmCTestLog(m_CTest, HANDLER_OUTPUT, outname.c_str()); } - + cmCTestLog(m_CTest, DEBUG, "Testing " << args[0].c_str() << " ... "); // find the test executable 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 if (testCommand == "") @@ -670,7 +683,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, if ( !m_CTest->GetShowOnly() ) { cres.m_FullCommandLine = actualCommand; - m_TestResults.push_back( cres ); + m_TestResults.push_back( cres ); failed.push_back(testname); continue; } @@ -698,8 +711,10 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, int retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl << (m_MemCheck?"MemCheck":"Test") << " command: " << testCommand << std::endl); - *m_LogFile << cnt << "/" << tmsize + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, std::endl + << (m_MemCheck?"MemCheck":"Test") << " command: " << testCommand + << std::endl); + *m_LogFile << cnt << "/" << tmsize << " Test: " << testname.c_str() << std::endl; *m_LogFile << "Command: "; std::vector::size_type ll; @@ -707,12 +722,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, { *m_LogFile << "\"" << arguments[ll] << "\" "; } - *m_LogFile - << std::endl - << "Directory: " << it->m_Directory << std::endl - << "\"" << testname.c_str() << "\" start time: " + *m_LogFile + << std::endl + << "Directory: " << it->m_Directory << std::endl + << "\"" << testname.c_str() << "\" start time: " << m_CTest->CurrentTime() << std::endl - << "Output:" << std::endl + << "Output:" << std::endl << "----------------------------------------------------------" << std::endl; int res = 0; @@ -734,12 +749,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, int seconds = static_cast(ttime) % 60; char buffer[100]; sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds); - *m_LogFile + *m_LogFile << "----------------------------------------------------------" << std::endl - << "\"" << testname.c_str() << "\" end time: " + << "\"" << testname.c_str() << "\" end time: " << m_CTest->CurrentTime() << std::endl - << "\"" << testname.c_str() << "\" time elapsed: " + << "\"" << testname.c_str() << "\" time elapsed: " << buffer << std::endl << "----------------------------------------------------------" << std::endl << std::endl; @@ -783,8 +798,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, } } - if (res == cmsysProcess_State_Exited && - (retVal == 0 || it->m_RequiredRegularExpressions.size()) && + if (res == cmsysProcess_State_Exited && + (retVal == 0 || it->m_RequiredRegularExpressions.size()) && !forceFail) { cmCTestLog(m_CTest, HANDLER_OUTPUT, " Passed"); @@ -839,7 +854,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, } 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; } else @@ -869,18 +885,21 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, { std::string dartString = m_DartStuff.match(1); cmSystemTools::ReplaceString(output, dartString.c_str(),""); - cres.m_RegressionImages = this->GenerateRegressionImages(dartString); + cres.m_RegressionImages + = this->GenerateRegressionImages(dartString); } } } if ( cres.m_Status == cmCTestTestHandler::COMPLETED ) { - this->CleanTestOutput(output, static_cast(m_CustomMaximumPassedTestOutputSize)); + this->CleanTestOutput(output, static_cast( + m_CustomMaximumPassedTestOutputSize)); } else { - this->CleanTestOutput(output, static_cast(m_CustomMaximumFailedTestOutputSize)); + this->CleanTestOutput(output, static_cast( + m_CustomMaximumFailedTestOutputSize)); } cres.m_Output = output; @@ -948,29 +967,34 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) m_CTest->GetShortPathToFile(result->m_Path.c_str())) << "\n" << "\t\t" << cmCTest::MakeXMLSafe( m_CTest->GetShortPathToFile(testPath.c_str())) << "\n" - << "\t\t" - << cmCTest::MakeXMLSafe(result->m_FullCommandLine) + << "\t\t" + << cmCTest::MakeXMLSafe(result->m_FullCommandLine) << "\n" << "\t\t" << std::endl; 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" - << this->GetTestStatus(result->m_Status) << "\n" - << "\t\t\t" - << result->m_ReturnValue << "" << std::endl; + os << "\t\t\t" + << this->GetTestStatus(result->m_Status) << "" + "\n" + << "\t\t\t" + << result->m_ReturnValue << "" + << std::endl; } os << result->m_RegressionImages; os << "\t\t\t" << result->m_ExecutionTime << "\n"; - os + os << "\t\t\t" << result->m_CompletionStatus << "\n"; } - os + os << "\t\t\t\n" << "\t\t\t\t"; os << cmCTest::MakeXMLSafe(result->m_Output); @@ -982,7 +1006,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) } os << "\t" << m_EndTest << "\n" - << "" + << "" << static_cast(m_ElapsedTestingTime/6)/10.0 << "" << "" << std::endl; @@ -996,11 +1020,13 @@ int cmCTestTestHandler::ExecuteCommands(std::vector& vec) for ( it = vec.begin(); it != vec.end(); ++it ) { int retVal = 0; - cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it << std::endl); - if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, true /*m_Verbose*/) || - retVal != 0 ) + cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it + << std::endl); + 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; } } @@ -1017,9 +1043,10 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe) std::string file; cmSystemTools::SplitProgramPath(exe, dir, file); - // first try to find the executable given a config type subdir if there is one - if(m_CTest->GetConfigType() != "" && - ::TryExecutable(dir.c_str(), file.c_str(), &fullPath, + // first try to find the executable given a config type subdir if there is + // one + if(m_CTest->GetConfigType() != "" && + ::TryExecutable(dir.c_str(), file.c_str(), &fullPath, m_CTest->GetConfigType().c_str())) { return fullPath; @@ -1088,7 +1115,8 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe) dir += m_CTest->GetConfigType(); dir += "/"; 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()); return ""; } @@ -1107,27 +1135,30 @@ void cmCTestTestHandler::GetListOfTests() { 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; cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); std::auto_ptr lg(gg.CreateLocalGenerator()); lg->SetGlobalGenerator(&gg); 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 cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand; newCom1->m_TestHandler = this; cm.AddCommand(newCom1); - // Add handler for SUBDIR + // Add handler for SUBDIR cmCTestSubdirCommand* newCom2 = new cmCTestSubdirCommand; newCom2->m_TestHandler = this; cm.AddCommand(newCom2); // Add handler for SET_SOURCE_FILES_PROPERTIES - cmCTestSetTestsPropertiesCommand* newCom3 = new cmCTestSetTestsPropertiesCommand; + cmCTestSetTestsPropertiesCommand* newCom3 + = new cmCTestSetTestsPropertiesCommand; newCom3->m_TestHandler = this; cm.AddCommand(newCom3); @@ -1155,13 +1186,14 @@ void cmCTestTestHandler::GetListOfTests() { 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() { - this->m_UseIncludeRegExp = true; + this->m_UseIncludeRegExp = true; } //---------------------------------------------------------------------- @@ -1170,7 +1202,7 @@ void cmCTestTestHandler::UseExcludeRegExp() this->m_UseExcludeRegExp = true; this->m_UseExcludeRegExpFirst = this->m_UseIncludeRegExp ? false : true; } - + //---------------------------------------------------------------------- const char* cmCTestTestHandler::GetTestStatus(int status) { @@ -1187,7 +1219,7 @@ const char* cmCTestTestHandler::GetTestStatus(int status) "Completed" }; - if ( status < cmCTestTestHandler::NOT_RUN || + if ( status < cmCTestTestHandler::NOT_RUN || status > cmCTestTestHandler::COMPLETED ) { return "No Status"; @@ -1202,7 +1234,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests) { return; } - + int start; int end = -1; double stride = -1; @@ -1239,7 +1271,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests) { end = numTests; } - + // if the stride wasn't specified then it defaults to 1 if(stride == -1) { @@ -1260,7 +1292,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests) // sort the array std::sort(m_TestsToRun.begin(), m_TestsToRun.end(), std::less()); // remove duplicates - std::vector::iterator new_end = + std::vector::iterator new_end = std::unique(m_TestsToRun.begin(), m_TestsToRun.end()); m_TestsToRun.erase(new_end, m_TestsToRun.end()); } @@ -1273,27 +1305,27 @@ std::string cmCTestTestHandler::GenerateRegressionImages( const std::string& xml) { cmsys::RegularExpression twoattributes( - "([^<]*)"); cmsys::RegularExpression threeattributes( - "([^<]*)"); cmsys::RegularExpression fourattributes( - "([^<]*)"); cmsys::RegularExpression measurementfile( - "([^<]*)"); cmOStringStream ostr; @@ -1304,42 +1336,54 @@ std::string cmCTestTestHandler::GenerateRegressionImages( if ( twoattributes.find(cxml) ) { ostr - << "\t\t\t" << twoattributes.match(5) - << "" + << "\t\t\t" << twoattributes.match(5) + << "" << std::endl; - cxml.erase(twoattributes.start(), twoattributes.end() - twoattributes.start()); + cxml.erase(twoattributes.start(), + twoattributes.end() - twoattributes.start()); } else if ( threeattributes.find(cxml) ) { ostr - << "\t\t\t" << threeattributes.match(7) - << "" + << "\t\t\t" << threeattributes.match(7) + << "" << std::endl; - cxml.erase(threeattributes.start(), threeattributes.end() - threeattributes.start()); + cxml.erase(threeattributes.start(), + threeattributes.end() - threeattributes.start()); } else if ( fourattributes.find(cxml) ) { ostr - << "\t\t\t" << fourattributes.match(9) - << "" + << "\t\t\t" << fourattributes.match(9) + << "" << std::endl; - cxml.erase(fourattributes.start(), fourattributes.end() - fourattributes.start()); + cxml.erase(fourattributes.start(), + fourattributes.end() - fourattributes.start()); } else if ( measurementfile.find(cxml) ) { - const std::string& filename = + const std::string& filename = cmCTest::CleanString(measurementfile.match(5)); if ( cmSystemTools::FileExists(filename.c_str()) ) { @@ -1357,34 +1401,38 @@ std::string cmCTestTestHandler::GenerateRegressionImages( if ( cmSystemTools::LowerCase(k2) == "type" ) { v2 = "text/string"; - } - + } + ostr - << "\t\t\tImage " << filename.c_str() + << ">Image " << filename.c_str() << " is empty"; } else { - std::ifstream ifs(filename.c_str(), std::ios::in + std::ifstream ifs(filename.c_str(), std::ios::in #ifdef _WIN32 | std::ios::binary #endif ); unsigned char *file_buffer = new unsigned char [ len + 1 ]; ifs.read(reinterpret_cast(file_buffer), len); - unsigned char *encoded_buffer = new unsigned char [ static_cast(len * 1.5 + 5) ]; - - unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); + unsigned char *encoded_buffer + = new unsigned char [ static_cast(len * 1.5 + 5) ]; + + unsigned long rlen + = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); unsigned long cc; - + ostr - << "\t\t\t" << std::endl << "\t\t\t\t"; for ( cc = 0; cc < rlen; cc ++ ) @@ -1396,7 +1444,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages( } } ostr - << "" << std::endl << "\t\t\t" + << "" << std::endl << "\t\t\t" << std::endl; delete [] file_buffer; delete [] encoded_buffer; @@ -1410,14 +1458,17 @@ std::string cmCTestTestHandler::GenerateRegressionImages( idx = 2; } ostr - << "\t\t\tFile " << filename.c_str() << " not found" + << ">File " << filename.c_str() + << " not found" << 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 { @@ -1447,7 +1498,8 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in) return; } 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)) { 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 ) { @@ -1512,7 +1565,8 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t remove_thre } 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; } output = ostr.str(); @@ -1520,7 +1574,8 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t remove_thre } //---------------------------------------------------------------------- -bool cmCTestTestHandler::SetTestsProperties(const std::vector& args) +bool cmCTestTestHandler::SetTestsProperties( + const std::vector& args) { std::vector::const_iterator it; std::vector tests; @@ -1567,7 +1622,8 @@ bool cmCTestTestHandler::SetTestsProperties(const std::vector& args std::vector::iterator 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" ) @@ -1577,7 +1633,8 @@ bool cmCTestTestHandler::SetTestsProperties(const std::vector& args std::vector::iterator 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& args) { std::vector::iterator it; bool found = false; - for ( it = m_CustomTestsIgnore.begin(); + for ( it = m_CustomTestsIgnore.begin(); it != m_CustomTestsIgnore.end(); ++ it ) { if ( *it == testname ) @@ -1612,7 +1669,8 @@ bool cmCTestTestHandler::AddTest(const std::vector& args) } 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; } } @@ -1620,7 +1678,7 @@ bool cmCTestTestHandler::AddTest(const std::vector& args) { std::vector::iterator it; bool found = false; - for ( it = m_CustomTestsIgnore.begin(); + for ( it = m_CustomTestsIgnore.begin(); it != m_CustomTestsIgnore.end(); ++ it ) { if ( *it == testname ) @@ -1631,7 +1689,8 @@ bool cmCTestTestHandler::AddTest(const std::vector& args) } 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; } } @@ -1642,7 +1701,8 @@ bool cmCTestTestHandler::AddTest(const std::vector& args) test.m_Directory = cmSystemTools::GetCurrentWorkingDirectory(); test.m_IsInBasedOnREOptions = true; 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; } diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index fc0e23099..0153e2755 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -37,7 +37,7 @@ public: * The main entry point for this class */ int ProcessHandler(); - + /** * 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 @@ -49,14 +49,14 @@ public: * This method is called when reading CTest custom file */ void PopulateCustomVectors(cmMakefile *mf); - + ///! Control the use of the regular expresisons, call these methods to turn ///them on void UseIncludeRegExp(); void UseExcludeRegExp(); void SetIncludeRegExp(const char *); void SetExcludeRegExp(const char *); - + ///! pass the -I argument down void SetTestsToRunInformation(const char*); @@ -140,9 +140,9 @@ private: /** * Run the test for a directory and any subdirectories */ - void ProcessDirectory(std::vector &passed, + void ProcessDirectory(std::vector &passed, std::vector &failed); - + typedef std::vector tm_ListOfTests; /** diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 6b6d44307..04bbe9316 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -43,16 +43,18 @@ bool cmCTestUpdateCommand::InitialPass( { 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; } havereturn_variable = true; - } + } else if(args[i] == "SOURCE") { 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; } havesource = true; @@ -60,20 +62,28 @@ bool cmCTestUpdateCommand::InitialPass( else { 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()); return false; } } - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS"); - m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "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"); + m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, + "UpdateCommand", "CTEST_UPDATE_COMMAND"); + m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, + "UpdateOptions", "CTEST_UPDATE_OPTIONS"); + m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, + "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 ) { initialCheckoutCommand = m_Makefile->GetDefinition("CTEST_CVS_CHECKOUT"); @@ -95,14 +105,16 @@ bool cmCTestUpdateCommand::InitialPass( { handler->SetOption("InitialCheckout", initialCheckoutCommand); } - if ( (!cmSystemTools::FileExists(source_dir) || !cmSystemTools::FileIsDirectory(source_dir)) + if ( (!cmSystemTools::FileExists(source_dir) || + !cmSystemTools::FileIsDirectory(source_dir)) && !initialCheckoutCommand ) { cmOStringStream str; str << "cannot find source directory: " << source_dir << "."; if ( !cmSystemTools::FileExists(source_dir) ) { - str << " Looks like it is not checked out yet. Please specify CTEST_CHECKOUT_COMMAND."; + str << " Looks like it is not checked out yet. Please specify " + "CTEST_CHECKOUT_COMMAND."; } this->SetError(str.str().c_str()); return false; diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index 543e4b586..1cb667231 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -9,8 +9,8 @@ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ @@ -29,11 +29,11 @@ class cmCTestUpdateCommand : public cmCTestCommand public: cmCTestUpdateCommand() {} - + /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { cmCTestUpdateCommand* ni = new cmCTestUpdateCommand; ni->m_CTest = this->m_CTest; @@ -55,11 +55,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Updates the repository."; } - + /** * More documentation. */ @@ -67,8 +67,8 @@ public: { return " CTEST_UPDATE([SOURCE source] [RETURN_VALUE res])\n" - "Updates the given source directory and stores results in Update.xml. The " - "second argument is a variable that will hold the number of files " + "Updates the given source directory and stores results in Update.xml. " + "The second argument is a variable that will hold the number of files " "modified. If there is a problem, the variable will be -1."; } diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index ae23f8f57..855dcad2c 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -48,7 +48,8 @@ static const char* cmCTestUpdateHandlerUpdateStrings[] = 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]; } @@ -116,7 +117,8 @@ protected: { 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 << "\tDate: " << m_CommitLog.m_Date.c_str() << std::endl << "\tMessage: " << m_CommitLog.m_Message.c_str() << std::endl); @@ -124,15 +126,18 @@ protected: } 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 ) { - 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 ) { - 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()); } @@ -184,7 +189,8 @@ void cmCTestUpdateHandler::Initialize() //---------------------------------------------------------------------- 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 ) { cmCTestLog(m_CTest, DEBUG, "Type specified: " << type << std::endl); @@ -200,7 +206,8 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) } 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); 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"); - cmCTestLog(m_CTest, DEBUG, "Check directory: " << sourceDirectory.c_str() << std::endl); + cmCTestLog(m_CTest, DEBUG, "Check directory: " << sourceDirectory.c_str() + << std::endl); sourceDirectory += "/.svn"; if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) { @@ -246,7 +254,9 @@ int cmCTestUpdateHandler::ProcessHandler() const char* sourceDirectory = this->GetOption("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; } @@ -261,39 +271,49 @@ int cmCTestUpdateHandler::ProcessHandler() const char* initialCheckoutCommand = this->GetOption("InitialCheckout"); 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); if ( parent.empty() ) { - cmCTestLog(m_CTest, ERROR_MESSAGE, - "Something went wrong when trying to determine the parent directory of " << sourceDirectory << std::endl); + cmCTestLog(m_CTest, ERROR_MESSAGE, "Something went wrong when trying " + "to determine the parent directory of " << sourceDirectory + << std::endl); return -1; } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Perform checkout in directory: " << parent.c_str() << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Perform checkout in directory: " + << parent.c_str() << std::endl); if ( !cmSystemTools::MakeDirectory(parent.c_str()) ) { cmCTestLog(m_CTest, ERROR_MESSAGE, - "Cannot create parent directory: " << parent.c_str() << " of the source directory: " << sourceDirectory << std::endl); + "Cannot create parent directory: " << parent.c_str() + << " of the source directory: " << sourceDirectory << std::endl); return -1; } ofs << "* Run initial checkout" << std::endl; ofs << " Command: " << initialCheckoutCommand << std::endl; - cmCTestLog(m_CTest, DEBUG, " Before: " << initialCheckoutCommand << std::endl); - bool retic = m_CTest->RunCommand(initialCheckoutCommand, &goutput, &errors, &retVal, parent.c_str(), 0 /* Timeout */); - cmCTestLog(m_CTest, DEBUG, " After: " << initialCheckoutCommand << std::endl); + cmCTestLog(m_CTest, DEBUG, " Before: " + << initialCheckoutCommand << std::endl); + bool retic = m_CTest->RunCommand(initialCheckoutCommand, &goutput, + &errors, &retVal, parent.c_str(), 0 /* Timeout */); + cmCTestLog(m_CTest, DEBUG, " After: " + << initialCheckoutCommand << std::endl); ofs << " Output: " << goutput.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; if ( !retic || retVal ) { cmOStringStream ostr; - ostr << "Problem running initial checkout Output [" << goutput << "] Errors [" << errors << "]"; + ostr << "Problem running initial checkout Output [" << goutput + << "] Errors [" << errors << "]"; cmCTestLog(m_CTest, ERROR_MESSAGE, ostr.str().c_str() << std::endl); checkoutErrorMessages += ostr.str(); updateProducedError = true; } m_CTest->InitializeFromCommand(m_Command); } - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Updating the repository: " << sourceDirectory << std::endl); + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Updating the repository: " + << sourceDirectory << std::endl); // Get update command std::string updateCommand = m_CTest->GetCTestConfiguration("UpdateCommand"); @@ -305,7 +325,9 @@ int cmCTestUpdateHandler::ProcessHandler() updateCommand = m_CTest->GetCTestConfiguration("SVNCommand"); 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; } else @@ -320,10 +342,13 @@ int cmCTestUpdateHandler::ProcessHandler() } 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 std::string updateOptions = m_CTest->GetCTestConfiguration("UpdateOptions"); @@ -348,7 +373,8 @@ int cmCTestUpdateHandler::ProcessHandler() std::string extra_update_opts; 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()); char current_time[1024]; 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() ) { - 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() ) { ofs << "* Get repository information" << std::endl; @@ -422,12 +450,16 @@ int cmCTestUpdateHandler::ProcessHandler() break; 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()) ) { - std::string currentRevisionString = current_revision_regex.match(1); + std::string currentRevisionString + = current_revision_regex.match(1); 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; @@ -435,7 +467,8 @@ int cmCTestUpdateHandler::ProcessHandler() } 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(); 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() ) { command = ""; @@ -474,7 +508,8 @@ int cmCTestUpdateHandler::ProcessHandler() " " + extra_update_opts; ofs << "* Update repository: " << 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*/); ofs << " Output: " << partialOutput.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; @@ -494,7 +529,7 @@ int cmCTestUpdateHandler::ProcessHandler() if ( ofs ) { ofs << "--- Update repository ---" << std::endl; - ofs << goutput << std::endl;; + ofs << goutput << std::endl; } } if ( !res || retVal ) @@ -514,10 +549,12 @@ int cmCTestUpdateHandler::ProcessHandler() os << "\t" << start_time << "\n" << "\t" << m_CTest->MakeXMLSafe(command) << "\n" - << "\t" << m_CTest->MakeXMLSafe(cmCTestUpdateHandlerUpdateToString(updateType)) + << "\t" << m_CTest->MakeXMLSafe( + cmCTestUpdateHandlerUpdateToString(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 lines; cmSystemTools::Split(goutput.c_str(), lines); std::vector errLines; @@ -525,16 +562,23 @@ int cmCTestUpdateHandler::ProcessHandler() lines.insert(lines.end(), errLines.begin(), errLines.end()); // 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_end_of_file_regex("^=============================================================================$"); - cmsys::RegularExpression cvs_end_of_comment_regex("^----------------------------$"); + cmsys::RegularExpression cvs_end_of_file_regex( + "^==========================================" + "===================================$"); + cmsys::RegularExpression cvs_end_of_comment_regex( + "^----------------------------$"); // Subversion style regular expressions - cmsys::RegularExpression svn_status_line_regex("^ *([0-9]+) *([0-9]+) *([^ ]+) *([^ ][^\t\r\n]*)[ \t\r\n]*$"); - cmsys::RegularExpression svn_latest_revision_regex("(Updated to|At) revision ([0-9]+)\\."); + cmsys::RegularExpression svn_status_line_regex( + "^ *([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]) *(.*)"); std::string current_path = ""; bool first_file = true; @@ -546,28 +590,35 @@ int cmCTestUpdateHandler::ProcessHandler() // In subversion, get the latest revision 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(); 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 ) { - 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 { - 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; 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(); if ( file_removed_line.find(line) ) @@ -596,7 +647,8 @@ int cmCTestUpdateHandler::ProcessHandler() modifiedOrConflict = true; } 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; if ( modifiedOrConflict ) @@ -608,22 +660,27 @@ int cmCTestUpdateHandler::ProcessHandler() logcommand = updateCommand + " -z3 log -N \"" + file + "\""; break; 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; - logCommandStream << updateCommand << " log -r " << svn_current_revision << ":" << svn_latest_revision + logCommandStream << updateCommand << " log -r " + << svn_current_revision << ":" << svn_latest_revision << " --xml \"" << file << "\""; logcommand = logCommandStream.str(); } else { - logcommand = updateCommand + " status --verbose \"" + file + "\""; + logcommand = updateCommand + + " status --verbose \"" + file + "\""; svn_use_status = 1; } break; } 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 << " Command: " << logcommand.c_str() << std::endl; res = m_CTest->RunCommand(logcommand.c_str(), &output, &errors, @@ -669,7 +726,8 @@ int cmCTestUpdateHandler::ProcessHandler() 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; if ( !have_first ) @@ -683,7 +741,8 @@ int cmCTestUpdateHandler::ProcessHandler() 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 ) { @@ -719,16 +778,24 @@ int cmCTestUpdateHandler::ProcessHandler() srevision1 = str.str(); 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 ) { - 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 { 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 ) { srevision2 = str.str(); @@ -743,7 +810,8 @@ int cmCTestUpdateHandler::ProcessHandler() { int minrev = parser.GetMinRevision(); int maxrev = parser.GetMaxRevision(); - cmCTestUpdateHandlerSVNXMLParser::t_VectorOfCommits::iterator it; + cmCTestUpdateHandlerSVNXMLParser:: + t_VectorOfCommits::iterator it; for ( it = parser.GetCommits()->begin(); it != parser.GetCommits()->end(); ++ it ) @@ -823,14 +891,18 @@ int cmCTestUpdateHandler::ProcessHandler() { 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() << " from revision: " << srevision2.c_str() << std::endl); - os << "\t\t" << cmCTest::MakeXMLSafe(fname) + os << "\t\t" + << cmCTest::MakeXMLSafe(fname) << "\n" - << "\t\t" << cmCTest::MakeXMLSafe(path) << "\n" + << "\t\t" << cmCTest::MakeXMLSafe(path) + << "\n" << "\t\t" << cmCTest::MakeXMLSafe(file) << "\n" - << "\t\t" << cmCTest::MakeXMLSafe(sdate1) << "\n" + << "\t\t" << cmCTest::MakeXMLSafe(sdate1) + << "\n" << "\t\t" << cmCTest::MakeXMLSafe(sauthor1) << "\n" << "\t\t" << cmCTest::MakeXMLSafe(semail1) << "\n" << "\t\t" << cmCTest::MakeXMLSafe(comment1) << "\n" @@ -842,19 +914,29 @@ int cmCTestUpdateHandler::ProcessHandler() os << "\t\t\n" << "\t\t\t" << srevision1 << "\n" - << "\t\t\t" << srevision2 << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(sauthor1) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(sdate1) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(comment1) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(semail1) << "\n" + << "\t\t\t" << srevision2 + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(sauthor1) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(sdate1) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(comment1) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(semail1) + << "\n" << "\t\t\n" << "\t\t\n" << "\t\t\t" << srevision2 << "\n" - << "\t\t\t" << srevision2 << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(sauthor2) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(sdate2) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(comment2) << "\n" - << "\t\t\t" << cmCTest::MakeXMLSafe(semail2) << "\n" + << "\t\t\t" << srevision2 + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(sauthor2) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(sdate2) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(comment2) + << "\n" + << "\t\t\t" << cmCTest::MakeXMLSafe(semail2) + << "\n" << "\t\t" << std::endl; } if ( mod == 'C' ) @@ -890,21 +972,25 @@ int cmCTestUpdateHandler::ProcessHandler() } 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 ) { - cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_modified << " locally modified files" + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Found " << num_modified + << " locally modified files" << std::endl); } 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); } 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 ) { @@ -936,21 +1022,26 @@ int cmCTestUpdateHandler::ProcessHandler() << "\t"; if ( num_modified > 0 || num_conflicting > 0 ) { - os << "Update error: There are modified or conflicting files in the repository"; - cmCTestLog(m_CTest, ERROR_MESSAGE, " There are modified or conflicting files in the repository" << std::endl); + os << "Update error: There are modified or conflicting files in the " + "repository"; + cmCTestLog(m_CTest, ERROR_MESSAGE, + " There are modified or conflicting files in the repository" + << std::endl); } if ( updateProducedError ) { os << "Update error: "; 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 << "" << std::endl; os << "" << std::endl; 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); return -1; }