diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-12-26 20:02:26 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-12-26 20:02:26 (GMT) |
commit | 2f2596c213c5be33ec653ed2d4662dc3bbafc60f (patch) | |
tree | 9c23692c9fe48d0d9bc348d21aa58170a2dbcf6e /Source | |
parent | 32accc160762ca80f1138d4e9c710d9edb72479c (diff) | |
download | CMake-2f2596c213c5be33ec653ed2d4662dc3bbafc60f.zip CMake-2f2596c213c5be33ec653ed2d4662dc3bbafc60f.tar.gz CMake-2f2596c213c5be33ec653ed2d4662dc3bbafc60f.tar.bz2 |
ENH: Add option to submit notes. Implements Bug #465 - Add notes support to CTest
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCTest.cxx | 89 | ||||
-rw-r--r-- | Source/cmCTest.h | 10 | ||||
-rw-r--r-- | Source/ctest.cxx | 12 |
3 files changed, 108 insertions, 3 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 136f2d2..c1c3331 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -470,6 +470,10 @@ bool cmCTest::SetTest(const char* ttype) { m_Tests[cmCTest::MEMCHECK_TEST] = 1; } + else if ( cmSystemTools::LowerCase(ttype) == "notes" ) + { + m_Tests[cmCTest::NOTES_TEST] = 1; + } else if ( cmSystemTools::LowerCase(ttype) == "submit" ) { m_Tests[cmCTest::SUBMIT_TEST] = 1; @@ -924,7 +928,8 @@ int cmCTest::ConfigureDirectory() std::ofstream os; if ( !this->OpenOutputFile(m_CurrentTag, "Configure.xml", os) ) { - std::cerr << "Cannot open log file" << std::endl; + std::cerr << "Cannot open configure file" << std::endl; + return 1; } std::string start_time = ::CurrentTime(); @@ -2194,6 +2199,10 @@ int cmCTest::SubmitResults() { files.push_back("Purify.xml"); } + if ( this->CTestFileExists("Notes.xml") ) + { + files.push_back("Notes.xml"); + } cmCTestSubmit submit; submit.SetVerbose(m_Verbose); if ( m_DartConfiguration["DropMethod"] == "" || @@ -3259,3 +3268,81 @@ bool cmCTest::ProcessMemCheckOutput(const std::string& str, std::string& log, in return true; } + +int cmCTest::GenerateDartNotesOutput(std::ostream& os, const cmCTest::tm_VectorOfStrings& files) +{ + cmCTest::tm_VectorOfStrings::const_iterator it; + for ( it = files.begin(); it != files.end(); it ++ ) + { + if ( !cmSystemTools::FileExists(it->c_str()) ) + { + std::cerr << "Error creating notes. File " << it->c_str() << " does not exists" << std::endl; + return 0; + } + } + + os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + << "<?xml-stylesheet type=\"text/xsl\" href=\"Dart/Source/Server/XSL/Build.xsl <file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n" + << "<Site BuildName=\"" << m_DartConfiguration["BuildName"] << "\" BuildStamp=\"" + << m_CurrentTag << "-" << this->GetTestModelString() << "\" Name=\"" + << m_DartConfiguration["Site"] << "\">\n" + << "<Notes>" << std::endl; + + for ( it = files.begin(); it != files.end(); it ++ ) + { + std::cout << "\tAdd file: " << it->c_str() << std::endl; + std::string note_time = ::CurrentTime(); + os << "<Note>\n" + << "<DateTime>" << note_time << "</DateTime>\n" + << "<Text>" << std::endl; + std::ifstream ifs(it->c_str()); + if ( ifs ) + { + std::string line; + while ( cmSystemTools::GetLineFromStream(ifs, line) ) + { + os << this->MakeXMLSafe(line) << std::endl; + } + ifs.close(); + } + else + { + os << "Problem reading file: " << it->c_str() << std::endl; + std::cerr << "Problem reading file: " << it->c_str() << " while creating notes" << std::endl; + } + os << "</Text>\n" + << "</Note>" << std::endl; + } + os << "</Notes>\n" + << "</Site>" << std::endl; + return 1; +} + +int cmCTest::GenerateNotesFile(const char* cfiles) +{ + if ( !cfiles ) + { + return 1; + } + + std::vector<cmStdString> files; + + std::cout << "Create notes file" << std::endl; + + files = cmSystemTools::SplitString(cfiles, ';'); + if ( files.size() == 0 ) + { + return 1; + } + + std::ofstream ofs; + if ( !this->OpenOutputFile(m_CurrentTag, "Notes.xml", ofs) ) + { + std::cerr << "Cannot open notes file" << std::endl; + return 1; + } + + this->GenerateDartNotesOutput(ofs, files); + return 0; +} + diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 8321581..6fe457b 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -137,6 +137,8 @@ public: CONTINUOUS }; + int GenerateNotesFile(const char* files); + private: enum { FIRST_TEST = 0, @@ -148,8 +150,9 @@ private: COVERAGE_TEST = 6, MEMCHECK_TEST = 7, SUBMIT_TEST = 8, - ALL_TEST = 9, - LAST_TEST = 10 + NOTES_TEST = 9, + ALL_TEST = 10, + LAST_TEST = 11 }; enum { // Program statuses @@ -313,6 +316,9 @@ private: //! End CTest XML output file void EndXML(std::ostream& ostr); + //! Create not from files. + int GenerateDartNotesOutput(std::ostream& os, const tm_VectorOfStrings& files); + //! Parse Valgrind/Purify/Bounds Checker result out of the output string. After running, // log holds the output and results hold the different memmory errors. bool ProcessMemCheckOutput(const std::string& str, std::string& log, int* results); diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 902955d..1c037b2 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -79,6 +79,8 @@ static const cmDocumentationEntry cmDocumentationOptions[] = "ctest will do what is required to create and run a dashboard. This " "option basically sets up a dashboard and then runs ctest -D with the " "appropriate options."}, + {"-A <Notes file>", "Add a notes file with submission", + "This option tells ctest to include a notes file when submitting dashboard. "}, {0,0,0} }; @@ -376,6 +378,16 @@ int main (int argc, char *argv[]) inst.m_ExcludeRegExp = args[i+1]; inst.m_UseExcludeRegExpFirst = inst.m_UseIncludeRegExp ? false : true; } + + if(arg.find("-A",0) == 0 && i < args.size() - 1) + { + inst.m_DartMode = true; + inst.SetTest("Notes"); + inst.Initialize(); + int ires = inst.GenerateNotesFile(args[i+1].c_str()); + inst.Finalize(); + return ires; + } } // call process directory |