diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-01-27 15:15:01 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-01-27 15:15:01 (GMT) |
commit | 62b310bc52b9feefab32992f7bcebaecbf3aa857 (patch) | |
tree | f1070331289cf33a4e15edcf4f616005f6b3ff8b | |
parent | 14477cee6e8a380e74f4cbf70afe5f3c3bfbd8a2 (diff) | |
download | CMake-62b310bc52b9feefab32992f7bcebaecbf3aa857.zip CMake-62b310bc52b9feefab32992f7bcebaecbf3aa857.tar.gz CMake-62b310bc52b9feefab32992f7bcebaecbf3aa857.tar.bz2 |
ENH: Add compression support to XML files
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 13 | ||||
-rw-r--r-- | Source/CTest/cmCTestConfigureHandler.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 13 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.h | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 13 | ||||
-rw-r--r-- | Source/CTest/cmCTestUpdateHandler.cxx | 7 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 78 | ||||
-rw-r--r-- | Source/cmCTest.h | 8 |
8 files changed, 82 insertions, 62 deletions
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index b4d96ed..1c40b23 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -22,6 +22,7 @@ #include "cmMakefile.h" #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" +#include "cmGeneratedFileStream.h" //#include <cmsys/RegularExpression.hxx> #include <cmsys/Process.h> @@ -211,12 +212,13 @@ int cmCTestBuildHandler::BuildDirectory(cmCTest *ctest_inst) return 1; } - std::ofstream ofs; + cmGeneratedFileStream ofs; double elapsed_time_start = cmSystemTools::GetTime(); if ( !m_CTest->OpenOutputFile("Temporary", "LastBuild.log", ofs) ) { std::cerr << "Cannot create LastBuild.log file" << std::endl; } + m_StartBuild = m_CTest->CurrentTime(); std::string output; int retVal = 0; @@ -237,10 +239,6 @@ int cmCTestBuildHandler::BuildDirectory(cmCTest *ctest_inst) { std::cerr << "Error(s) when building project" << std::endl; } - if ( ofs ) - { - ofs.close(); - } std::vector<cmStdString>::size_type cc; if ( m_CTest->GetDartConfiguration("SourceDirectory").size() > 20 || @@ -440,12 +438,13 @@ int cmCTestBuildHandler::BuildDirectory(cmCTest *ctest_inst) std::cout << " " << errors << " Compiler errors" << std::endl; std::cout << " " << warnings << " Compiler warnings" << std::endl; - if( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), "Build.xml", ofs) ) + cmGeneratedFileStream xofs; + if( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), "Build.xml", xofs, true) ) { std::cerr << "Cannot create build XML file" << std::endl; return 1; } - this->GenerateDartBuildOutput(ofs, errorsWarnings, elapsed_build_time); + this->GenerateDartBuildOutput(xofs, errorsWarnings, elapsed_build_time); return 0; } diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 65950a7..fbf88b4 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -18,6 +18,7 @@ #include "cmCTestConfigureHandler.h" #include "cmCTest.h" +#include "cmGeneratedFileStream.h" #include "cmake.h" #include <cmsys/Process.h> @@ -59,15 +60,15 @@ int cmCTestConfigureHandler::ConfigureDirectory(cmCTest *ctest_inst) int res = 0; if ( !m_CTest->GetShowOnly() ) { - std::ofstream os; - if ( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), "Configure.xml", os) ) + cmGeneratedFileStream os; + if ( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), "Configure.xml", os, true) ) { std::cerr << "Cannot open configure file" << std::endl; return 1; } std::string start_time = m_CTest->CurrentTime(); - std::ofstream ofs; + cmGeneratedFileStream ofs; m_CTest->OpenOutputFile("Temporary", "LastConfigure.log", ofs); res = m_CTest->RunMakeCommand(cCommand.c_str(), &output, &retVal, buildDirectory.c_str(), diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 204d684..8883b39 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -20,6 +20,7 @@ #include "cmCTest.h" #include "cmake.h" #include "cmSystemTools.h" +#include "cmGeneratedFileStream.h" #include "cmGlob.h" #include <cmsys/Process.h> #include <cmsys/RegularExpression.hxx> @@ -38,13 +39,13 @@ cmCTestCoverageHandler::cmCTestCoverageHandler() } //---------------------------------------------------------------------- -bool cmCTestCoverageHandler::StartLogFile(std::ofstream& covLogFile, int logFileCount) +bool cmCTestCoverageHandler::StartLogFile(cmGeneratedFileStream& covLogFile, int logFileCount) { char covLogFilename[1024]; sprintf(covLogFilename, "CoverageLog-%d.xml", logFileCount); std::cout << "Open file: " << covLogFilename << std::endl; if (!m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), - covLogFilename, covLogFile)) + covLogFilename, covLogFile, true)) { std::cerr << "Cannot open log file: " << covLogFilename << std::endl; return false; @@ -57,7 +58,7 @@ bool cmCTestCoverageHandler::StartLogFile(std::ofstream& covLogFile, int logFile } //---------------------------------------------------------------------- -void cmCTestCoverageHandler::EndLogFile(std::ofstream& ostr, int logFileCount) +void cmCTestCoverageHandler::EndLogFile(cmGeneratedFileStream& ostr, int logFileCount) { std::string local_end_time = m_CTest->CurrentTime(); ostr << "\t<EndDateTime>" << local_end_time << "</EndDateTime>" << std::endl @@ -324,11 +325,11 @@ int cmCTestCoverageHandler::CoverageDirectory(cmCTest *ctest_inst) } } - std::ofstream covSumFile; - std::ofstream covLogFile; + cmGeneratedFileStream covSumFile; + cmGeneratedFileStream covLogFile; if (!m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), - "Coverage.xml", covSumFile)) + "Coverage.xml", covSumFile, true)) { std::cerr << "Cannot open coverage summary file: Coverage.xml" << std::endl; return 1; diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index caf8589..c6a80a6 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -23,6 +23,7 @@ #include "cmListFileCache.h" class cmCTest; +class cmGeneratedFileStream; /** \class cmCTestCoverageHandler * \brief A class that handles coverage computaiton for ctest @@ -49,8 +50,8 @@ private: cmCTest *m_CTest; bool ShouldIDoCoverage(const char* file, const char* srcDir, const char* binDir, bool verbose); - bool StartLogFile(std::ofstream& ostr, int logFileCount); - void EndLogFile(std::ofstream& ostr, int logFileCount); + bool StartLogFile(cmGeneratedFileStream& ostr, int logFileCount); + void EndLogFile(cmGeneratedFileStream& ostr, int logFileCount); struct cmCTestCoverage { diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 60e6b94..9e8945b 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -19,6 +19,7 @@ #include "cmCTest.h" #include "cmake.h" +#include "cmGeneratedFileStream.h" #include <cmsys/Process.h> #include <cmsys/RegularExpression.hxx> #include <cmsys/Base64.h> @@ -302,7 +303,7 @@ int cmCTestTestHandler::TestDirectory(cmCTest *ctest_inst, bool memcheck) if (failed.size()) { - std::ofstream ofs; + cmGeneratedFileStream ofs; std::cerr << "\nThe following tests FAILED:\n"; m_CTest->OpenOutputFile("Temporary", "LastTestsFailed.log", ofs); @@ -324,9 +325,9 @@ int cmCTestTestHandler::TestDirectory(cmCTest *ctest_inst, bool memcheck) if ( m_CTest->GetProduceXML() ) { - std::ofstream xmlfile; + cmGeneratedFileStream xmlfile; if( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), - (memcheck ? "DynamicAnalysis.xml" : "Test.xml"), xmlfile) ) + (memcheck ? "DynamicAnalysis.xml" : "Test.xml"), xmlfile, true) ) { std::cerr << "Cannot create " << (memcheck ? "memory check" : "testing") << " XML file" << std::endl; @@ -372,8 +373,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, this->GetListOfTests(&testlist, memcheck); tm_ListOfTests::size_type tmsize = testlist.size(); - std::ofstream ofs; - std::ofstream *olog = 0; + cmGeneratedFileStream ofs; + cmGeneratedFileStream *olog = 0; if ( !m_CTest->GetShowOnly() && tmsize > 0 && m_CTest->OpenOutputFile("Temporary", (memcheck?"LastMemCheck.log":"LastTest.log"), ofs) ) @@ -1670,7 +1671,7 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t remove_thre } cmOStringStream ostr; std::string::size_type cc; - std::string::size_type skipsize; + std::string::size_type skipsize = 0; int inTag = 0; int skipped = 0; for ( cc = 0; cc < output.size(); cc ++ ) diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index c3eff5d..cbdb3ad 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -23,6 +23,7 @@ #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmVersion.h" +#include "cmGeneratedFileStream.h" //#include <cmsys/RegularExpression.hxx> #include <cmsys/Process.h> @@ -95,8 +96,8 @@ int cmCTestUpdateHandler::UpdateDirectory(cmCTest *ctest_inst) std::string command = cvsCommand + " -z3 update " + cvsOptions + " " + extra_update_opts; - std::ofstream os; - if ( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), "Update.xml", os) ) + cmGeneratedFileStream os; + if ( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), "Update.xml", os, true) ) { std::cerr << "Cannot open log file" << std::endl; } @@ -106,7 +107,7 @@ int cmCTestUpdateHandler::UpdateDirectory(cmCTest *ctest_inst) std::string goutput; int retVal = 0; bool res = true; - std::ofstream ofs; + cmGeneratedFileStream ofs; if ( !m_CTest->GetShowOnly() ) { res = cmSystemTools::RunSingleCommand(command.c_str(), &goutput, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 302ba52..daa05c0 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -24,6 +24,7 @@ #include <cmsys/Directory.hxx> #include "cmGlob.h" #include "cmDynamicLoader.h" +#include "cmGeneratedFileStream.h" #include "cmCTestBuildHandler.h" #include "cmCTestCoverageHandler.h" @@ -231,6 +232,7 @@ cmCTest::cmCTest() m_TestModel = cmCTest::EXPERIMENTAL; m_InteractiveDebugMode = true; m_TimeOut = 0; + m_CompressXMLFiles = false; int cc; for ( cc=0; cc < cmCTest::LAST_TEST; cc ++ ) { @@ -481,7 +483,8 @@ void cmCTest::Finalize() bool cmCTest::OpenOutputFile(const std::string& path, - const std::string& name, std::ofstream& stream) + const std::string& name, cmGeneratedFileStream& stream, + bool compress) { std::string testingDir = m_ToplevelPath + "/Testing"; if ( path.size() > 0 ) @@ -508,43 +511,59 @@ bool cmCTest::OpenOutputFile(const std::string& path, } } std::string filename = testingDir + "/" + name; - stream.open(filename.c_str()); + stream.Open(filename.c_str()); if( !stream ) { std::cerr << "Problem opening file: " << filename << std::endl; return false; } + if ( compress ) + { + if ( m_CompressXMLFiles ) + { + stream.SetCompression(true); + } + } + return true; +} + +bool cmCTest::AddIfExists(tm_VectorOfStrings& files, const char* file) +{ + if ( this->CTestFileExists(file) ) + { + files.push_back(file); + } + else + { + std::string name = file; + name += ".gz"; + if ( this->CTestFileExists(name.c_str()) ) + { + files.push_back(name.c_str()); + } + else + { + return false; + } + } return true; } int cmCTest::SubmitResults() { - std::ofstream ofs; + cmGeneratedFileStream ofs; this->OpenOutputFile("Temporary", "LastSubmit.log", ofs); cmCTest::tm_VectorOfStrings files; std::string prefix = this->GetSubmitResultsPrefix(); // TODO: // Check if test is enabled - if ( this->CTestFileExists("Update.xml") ) - { - files.push_back("Update.xml"); - } - if ( this->CTestFileExists("Configure.xml") ) - { - files.push_back("Configure.xml"); - } - if ( this->CTestFileExists("Build.xml") ) - { - files.push_back("Build.xml"); - } - if ( this->CTestFileExists("Test.xml") ) + this->AddIfExists(files, "Update.xml"); + this->AddIfExists(files, "Configure.xml"); + this->AddIfExists(files, "Build.xml"); + this->AddIfExists(files, "Test.xml"); + if ( this->AddIfExists(files, "Coverage.xml") ) { - files.push_back("Test.xml"); - } - if ( this->CTestFileExists("Coverage.xml") ) - { - files.push_back("Coverage.xml"); cmCTest::tm_VectorOfStrings gfiles; std::string gpath = m_ToplevelPath + "/Testing/" + m_CurrentTag; std::string::size_type glen = gpath.size() + 1; @@ -565,18 +584,9 @@ int cmCTest::SubmitResults() std::cerr << "Problem globbing" << std::endl; } } - if ( this->CTestFileExists("DynamicAnalysis.xml") ) - { - files.push_back("DynamicAnalysis.xml"); - } - if ( this->CTestFileExists("Purify.xml") ) - { - files.push_back("Purify.xml"); - } - if ( this->CTestFileExists("Notes.xml") ) - { - files.push_back("Notes.xml"); - } + this->AddIfExists(files, "DynamicAnalysis.xml"); + this->AddIfExists(files, "Purify.xml"); + this->AddIfExists(files, "Notes.xml"); if ( ofs ) { @@ -1134,7 +1144,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles) return 1; } - std::ofstream ofs; + cmGeneratedFileStream ofs; if ( !this->OpenOutputFile(m_CurrentTag, "Notes.xml", ofs) ) { std::cerr << "Cannot open notes file" << std::endl; diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 2fdb033..9df0b80 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -30,6 +30,7 @@ class cmCTestCoverageHandler; class cmCTestScriptHandler; class cmCTestTestHandler; class cmCTestUpdateHandler; +class cmGeneratedFileStream; class cmCTest { @@ -87,6 +88,7 @@ public: * Check if CTest file exists */ bool CTestFileExists(const std::string& filename); + bool AddIfExists(tm_VectorOfStrings& files, const char* file); /** * Set the cmake test @@ -140,7 +142,9 @@ public: int GenerateNotesFile(const char* files); bool OpenOutputFile(const std::string& path, - const std::string& name, std::ofstream& stream); + const std::string& name, + cmGeneratedFileStream& stream, + bool compress = false); static std::string MakeXMLSafe(const std::string&); static std::string MakeURLSafe(const std::string&); @@ -255,6 +259,8 @@ private: bool m_InteractiveDebugMode; bool m_ShortDateFormat; + + bool m_CompressXMLFiles; void BlockTestErrorDiagnostics(); |