diff options
author | Ken Martin <ken.martin@kitware.com> | 2004-11-13 14:55:31 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2004-11-13 14:55:31 (GMT) |
commit | 5a0366c6e0415294dde67b4bd2167d1cbf5d9ff1 (patch) | |
tree | 24585d0edb451644a77305b5362037bdcad75827 | |
parent | 247c367a59552be299583cf77705709ae972a295 (diff) | |
download | CMake-5a0366c6e0415294dde67b4bd2167d1cbf5d9ff1.zip CMake-5a0366c6e0415294dde67b4bd2167d1cbf5d9ff1.tar.gz CMake-5a0366c6e0415294dde67b4bd2167d1cbf5d9ff1.tar.bz2 |
ENH: added -U option to take union of -R and -I
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 100 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 22 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 4 | ||||
-rw-r--r-- | Source/ctest.cxx | 14 |
4 files changed, 91 insertions, 49 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index e6c8aef..5839ac7 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -193,7 +193,8 @@ cmCTestTestHandler::cmCTestTestHandler() { m_Verbose = false; m_CTest = 0; - + m_UseUnion = false; + m_UseIncludeRegExp = false; m_UseExcludeRegExp = false; m_UseExcludeRegExpFirst = false; @@ -381,15 +382,36 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, << std::endl; } - // expand the test list - this->ExpandTestsToRunInformation((int)tmsize); + // how many tests are in based on RegExp? + int inREcnt = 0; + tm_ListOfTests::iterator it; + for ( it = testlist.begin(); it != testlist.end(); it ++ ) + { + if (it->m_IsInBasedOnREOptions) + { + inREcnt ++; + } + } + // expand the test list based on the union flag + if (m_UseUnion) + { + this->ExpandTestsToRunInformation((int)tmsize); + } + else + { + this->ExpandTestsToRunInformation(inREcnt); + } int cnt = 0; - tm_ListOfTests::iterator it; + inREcnt = 0; std::string last_directory = ""; for ( it = testlist.begin(); it != testlist.end(); it ++ ) { cnt ++; + if (it->m_IsInBasedOnREOptions) + { + inREcnt++; + } const std::string& testname = it->m_Name; tm_VectorOfListFileArgs& args = it->m_Args; cmCTestTestResult cres; @@ -408,30 +430,41 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, } cres.m_Name = testname; cres.m_Path = it->m_Directory.c_str(); - if(m_TestsToRun.size() && - std::find(m_TestsToRun.begin(), m_TestsToRun.end(), cnt) == m_TestsToRun.end()) + + if (m_UseUnion) { - continue; + // 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) + == m_TestsToRun.end()) && !it->m_IsInBasedOnREOptions) + { + continue; + } } + 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) + == m_TestsToRun.end()) || !it->m_IsInBasedOnREOptions) + { + continue; + } + } + + std::cerr.width(3); + std::cerr << cnt << "/"; + std::cerr.width(3); + std::cerr << tmsize << " Testing "; + std::string outname = testname; + outname.resize(30, ' '); if ( m_CTest->GetShowOnly() ) { - std::cerr.width(3); - std::cerr << cnt << "/"; - std::cerr.width(3); - std::cerr << tmsize << " Testing "; - std::string outname = testname; - outname.resize(30, ' '); std::cerr << outname.c_str() << "\n"; - } + } else { - std::cerr.width(3); - std::cerr << cnt << "/"; - std::cerr.width(3); - std::cerr << tmsize << " Testing "; - std::string outname = testname; - outname.resize(30, ' '); std::cerr << outname.c_str(); std::cerr.flush(); } @@ -1121,22 +1154,21 @@ void cmCTestTestHandler::GetListOfTests(tm_ListOfTests* testlist, } } - + cmCTestTestProperties test; + test.m_Name = testname; + test.m_Args = args; + test.m_Directory = cmSystemTools::GetCurrentWorkingDirectory(); + test.m_IsInBasedOnREOptions = true; if (this->m_UseIncludeRegExp && !ireg.find(testname.c_str())) { - continue; + test.m_IsInBasedOnREOptions = false; } - if (this->m_UseExcludeRegExp && - !this->m_UseExcludeRegExpFirst && - ereg.find(testname.c_str())) + else if (this->m_UseExcludeRegExp && + !this->m_UseExcludeRegExpFirst && + ereg.find(testname.c_str())) { - continue; + test.m_IsInBasedOnREOptions = false; } - - cmCTestTestProperties test; - test.m_Name = testname; - test.m_Args = args; - test.m_Directory = cmSystemTools::GetCurrentWorkingDirectory(); testlist->push_back(test); } } @@ -1244,12 +1276,6 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(int numTests) std::vector<int>::iterator new_end = std::unique(m_TestsToRun.begin(), m_TestsToRun.end()); m_TestsToRun.erase(new_end, m_TestsToRun.end()); - std::cout << "Running tests: "; - for(unsigned int i =0; i < m_TestsToRun.size(); ++i) - { - std::cout << m_TestsToRun[i] << " "; - } - std::cout << "\n"; } #define SPACE_REGEX "[ \t\r\n]" diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 9d7f451..4bca7d0 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -42,9 +42,16 @@ public: * If verbose then more informaiton is printed out */ void SetVerbose(bool val) { m_Verbose = val; } - - void PopulateCustomVectors(cmMakefile *mf); + /* + * When both -R and -I are used should te resulting test list be the + * intersection or the union of the lists. By default it is the + * intersection. + */ + void SetUseUnion(bool val) { m_UseUnion = val; } + + void PopulateCustomVectors(cmMakefile *mf); + ///! Control the use of the regular expresisons, call these methods to turn ///them on void UseIncludeRegExp(); @@ -58,7 +65,7 @@ public: void SetTestsToRunInformation(const char*); typedef std::vector<cmListFileArgument> tm_VectorOfListFileArgs; - + private: enum { // Memory checkers @@ -152,13 +159,14 @@ private: void ProcessDirectory(std::vector<cmStdString> &passed, std::vector<cmStdString> &failed, bool memcheck); - + struct cmCTestTestProperties - { + { cmStdString m_Name; cmStdString m_Directory; tm_VectorOfListFileArgs m_Args; - }; + bool m_IsInBasedOnREOptions; + }; typedef std::vector<cmCTestTestProperties> tm_ListOfTests; /** @@ -205,7 +213,7 @@ private: std::string& log, int* results); std::string TestsToRunString; - + bool m_UseUnion; }; #endif diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f0cf6b4..73ac926 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1453,6 +1453,10 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output) i++; this->TestHandler->SetTestsToRunInformation(args[i].c_str()); } + if(arg.find("-U",0) == 0) + { + this->TestHandler->SetUseUnion(true); + } if(arg.find("-R",0) == 0 && i < args.size() - 1) { this->TestHandler->UseIncludeRegExp(); diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 3be9293..027927c 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -81,11 +81,15 @@ static const cmDocumentationEntry cmDocumentationOptions[] = "appropriate options."}, {"-A <Notes file>", "Add a notes file with submission", "This option tells ctest to include a notes file when submitting dashboard. "}, - {"-I [Start,End,Stride,test#,test#|Test file]", "Run a specific number of tests by number.", - "This option causes ctest to run tests starting at number Start, ending at number End, " - "and incrementing by Stride. Any additional numbers after Stride are considered individual " - "test numbers. Start, End,or stride can be empty. Optionally a file can be given that contains " - "the same syntax as the command line."}, + {"-I [Start,End,Stride,test#,test#|Test file]", + "Run a specific number of tests by number.", + "This option causes ctest to run tests starting at number Start, ending " + "at number End, and incrementing by Stride. Any additional numbers after " + "Stride are considered individual test numbers. Start, End,or stride " + "can be empty. Optionally a file can be given that contains the same " + "syntax as the command line."}, + {"-U", "When both -R and -I are specified by default the intersection of " + "tests are run. By specifying -U the union of tests is run instead."}, {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1.", "This option causes ctest to run tests in either an interactive mode or a non-interactive mode. " "On Windows this means that in non-interactive mode, all system debug pop up windows are blocked. " |