From c3003ab8c3a4536b3e3d117dba3d88fed2f3f947 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Tue, 6 Jan 2004 19:13:55 -0500 Subject: ENH: Improve notes support (now you can specify them with the rest of the command line), improve reading of configuration file (now it actually rereads configuration file after running update/configure/build...). Remember the model (nightly/experimental) across runs --- Source/cmCTest.cxx | 154 ++++++++++++++++++++++++++++++++++++----------------- Source/cmCTest.h | 10 ++++ Source/ctest.cxx | 5 +- 3 files changed, 116 insertions(+), 53 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index e59a48b..726f39f 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -325,49 +325,9 @@ void cmCTest::Initialize() { m_ToplevelPath = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ConvertToUnixSlashes(m_ToplevelPath); - // parse the dart test file - std::ifstream fin("DartConfiguration.tcl"); - if(!fin) - { - return; - } - - char buffer[1024]; - while ( fin ) - { - buffer[0] = 0; - fin.getline(buffer, 1023); - buffer[1023] = 0; - std::string line = ::CleanString(buffer); - if(line.size() == 0) - { - continue; - } - while ( fin && (line[line.size()-1] == '\\') ) - { - line = line.substr(0, line.size()-1); - buffer[0] = 0; - fin.getline(buffer, 1023); - buffer[1023] = 0; - line += ::CleanString(buffer); - } - if ( line[0] == '#' ) - { - continue; - } - std::string::size_type cpos = line.find_first_of(":"); - if ( cpos == line.npos ) - { - continue; - } - std::string key = line.substr(0, cpos); - std::string value = ::CleanString(line.substr(cpos+1, line.npos)); - m_DartConfiguration[key] = value; - } - fin.close(); + this->UpdateCTestConfiguration(); if ( m_DartMode ) { - m_TimeOut = atoi(m_DartConfiguration["TimeOut"].c_str()); std::string testingDir = m_ToplevelPath + "/Testing"; if ( cmSystemTools::FileExists(testingDir.c_str()) ) { @@ -392,10 +352,8 @@ void cmCTest::Initialize() std::string tag; time_t tctime = time(0); struct tm *lctime = gmtime(&tctime); - if ( tfin ) + if ( tfin && cmSystemTools::GetLineFromStream(tfin, tag) ) { - tfin >> tag; - tfin.close(); int year = 0; int mon = 0; int day = 0; @@ -409,7 +367,15 @@ void cmCTest::Initialize() { tag = ""; } - + std::string tagmode; + if ( cmSystemTools::GetLineFromStream(tfin, tagmode) ) + { + if ( tagmode.size() > 4 && !( m_Tests[cmCTest::START_TEST] || m_Tests[ALL_TEST] )) + { + m_TestModel = cmCTest::GetTestModelFromString(tagmode.c_str()); + } + } + tfin.close(); } if ( tag.size() == 0 || m_Tests[cmCTest::START_TEST] || m_Tests[ALL_TEST]) { @@ -431,14 +397,64 @@ void cmCTest::Initialize() if ( ofs ) { ofs << tag << std::endl; + ofs << this->GetTestModelString() << std::endl; } ofs.close(); - std::cout << "Create new tag: " << tag << std::endl; + std::cout << "Create new tag: " << tag << " - " + << this->GetTestModelString() << std::endl; } m_CurrentTag = tag; } } +void cmCTest::UpdateCTestConfiguration() +{ + // parse the dart test file + std::ifstream fin("DartConfiguration.tcl"); + if(!fin) + { + return; + } + + char buffer[1024]; + while ( fin ) + { + buffer[0] = 0; + fin.getline(buffer, 1023); + buffer[1023] = 0; + std::string line = ::CleanString(buffer); + if(line.size() == 0) + { + continue; + } + while ( fin && (line[line.size()-1] == '\\') ) + { + line = line.substr(0, line.size()-1); + buffer[0] = 0; + fin.getline(buffer, 1023); + buffer[1023] = 0; + line += ::CleanString(buffer); + } + if ( line[0] == '#' ) + { + continue; + } + std::string::size_type cpos = line.find_first_of(":"); + if ( cpos == line.npos ) + { + continue; + } + std::string key = line.substr(0, cpos); + std::string value = ::CleanString(line.substr(cpos+1, line.npos)); + m_DartConfiguration[key] = value; + } + fin.close(); + if ( m_DartMode ) + { + m_TimeOut = atoi(m_DartConfiguration["TimeOut"].c_str()); + } +} + bool cmCTest::SetTest(const char* ttype) { if ( cmSystemTools::LowerCase(ttype) == "all" ) @@ -636,7 +652,7 @@ int cmCTest::UpdateDirectory() } os << "\n" - << "\n" + << "\n" << "\t" <\n" << "\t" << m_DartConfiguration["BuildName"] << "\n" @@ -2485,6 +2501,7 @@ int cmCTest::ProcessTests() } if ( m_Tests[BUILD_TEST] || m_Tests[ALL_TEST] ) { + this->UpdateCTestConfiguration(); if (this->BuildDirectory()) { res |= CTEST_BUILD_ERRORS; @@ -2492,6 +2509,7 @@ int cmCTest::ProcessTests() } if ( m_Tests[TEST_TEST] || m_Tests[ALL_TEST] || notest ) { + this->UpdateCTestConfiguration(); if (this->TestDirectory(false)) { res |= CTEST_TEST_ERRORS; @@ -2499,17 +2517,28 @@ int cmCTest::ProcessTests() } if ( m_Tests[COVERAGE_TEST] || m_Tests[ALL_TEST] ) { + this->UpdateCTestConfiguration(); this->CoverageDirectory(); } if ( m_Tests[MEMCHECK_TEST] || m_Tests[ALL_TEST] ) { + this->UpdateCTestConfiguration(); if (this->TestDirectory(true)) { res |= CTEST_MEMORY_ERRORS; } } + if ( m_Tests[NOTES_TEST] || m_Tests[ALL_TEST] ) + { + this->UpdateCTestConfiguration(); + if ( m_NotesFiles.size() ) + { + this->GenerateNotesFile(m_NotesFiles.c_str()); + } + } if ( m_Tests[SUBMIT_TEST] || m_Tests[ALL_TEST] ) { + this->UpdateCTestConfiguration(); this->SubmitResults(); } return res; @@ -2527,6 +2556,24 @@ std::string cmCTest::GetTestModelString() return "Experimental"; } +int cmCTest::GetTestModelFromString(const char* str) +{ + if ( !str ) + { + return cmCTest::EXPERIMENTAL; + } + std::string rstr = cmSystemTools::LowerCase(str); + if ( strncmp(rstr.c_str(), "cont", 4) == 0 ) + { + return cmCTest::CONTINUOUS; + } + if ( strncmp(rstr.c_str(), "nigh", 4) == 0 ) + { + return cmCTest::NIGHTLY; + } + return cmCTest::EXPERIMENTAL; +} + #define SPACE_REGEX "[ \t\r\n]" std::string cmCTest::GenerateRegressionImages(const std::string& xml) @@ -3109,7 +3156,7 @@ void cmCTest::StartXML(std::ostream& ostr) << "GetTestModelString() << "\" Name=\"" - << m_DartConfiguration["Site"] << "\">" << std::endl; + << m_DartConfiguration["Site"] << "\" Generator=\"ctest\">" << std::endl; } void cmCTest::EndXML(std::ostream& ostr) @@ -3288,7 +3335,7 @@ int cmCTest::GenerateDartNotesOutput(std::ostream& os, const cmCTest::tm_VectorO << " \"?>\n" << "GetTestModelString() << "\" Name=\"" - << m_DartConfiguration["Site"] << "\">\n" + << m_DartConfiguration["Site"] << "\" Generator=\"ctest\">\n" << "" << std::endl; for ( it = files.begin(); it != files.end(); it ++ ) @@ -3349,3 +3396,12 @@ int cmCTest::GenerateNotesFile(const char* cfiles) return 0; } +void cmCTest::SetNotesFiles(const char* notes) +{ + if ( !notes ) + { + return; + } + m_NotesFiles = notes; +} + diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 6fe457b..6f740c9 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -109,13 +109,18 @@ public: { m_TestModel = mode; } + std::string GetTestModelString(); + static int GetTestModelFromString(const char* str); /** * constructor */ cmCTest(); + //! Set the notes files to be created. + void SetNotesFiles(const char* notes); + bool m_UseIncludeRegExp; std::string m_IncludeRegExp; @@ -284,6 +289,11 @@ private: int m_CompatibilityMode; + std::string m_NotesFiles; + + //! Reread the configuration file + void UpdateCTestConfiguration(); + /** * Generate the Dart compatible output */ diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 1c037b2..86abcdf 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -383,10 +383,7 @@ int main (int argc, char *argv[]) { inst.m_DartMode = true; inst.SetTest("Notes"); - inst.Initialize(); - int ires = inst.GenerateNotesFile(args[i+1].c_str()); - inst.Finalize(); - return ires; + inst.SetNotesFiles(argv[i+1]); } } -- cgit v0.12