diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2009-02-10 19:24:24 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2009-02-10 19:24:24 (GMT) |
commit | 4e710a9ebe0ba2bb1b61018469bd981b138e584d (patch) | |
tree | 02fd27ca753aa63f6637d9a4dc2fd1a8524a71cd /Source/CTest/cmCTestTestHandler.cxx | |
parent | 70363cbf8f24e3cb7b340095130777ccf1a16ca3 (diff) | |
download | CMake-4e710a9ebe0ba2bb1b61018469bd981b138e584d.zip CMake-4e710a9ebe0ba2bb1b61018469bd981b138e584d.tar.gz CMake-4e710a9ebe0ba2bb1b61018469bd981b138e584d.tar.bz2 |
ENH: add the ability to run tests by labels
Diffstat (limited to 'Source/CTest/cmCTestTestHandler.cxx')
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 102 |
1 files changed, 101 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index cb2c1aa..7f3b995 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -391,6 +391,8 @@ cmCTestTestHandler::cmCTestTestHandler() { this->UseUnion = false; + this->UseIncludeLabelRegExpFlag = false; + this->UseExcludeLabelRegExpFlag = false; this->UseIncludeRegExpFlag = false; this->UseExcludeRegExpFlag = false; this->UseExcludeRegExpFirst = false; @@ -433,6 +435,8 @@ void cmCTestTestHandler::Initialize() this->UseIncludeRegExpFlag = false; this->UseExcludeRegExpFlag = false; this->UseExcludeRegExpFirst = false; + this->IncludeLabelRegularExpression = ""; + this->ExcludeLabelRegularExpression = ""; this->IncludeRegExp = ""; this->ExcludeRegExp = ""; @@ -492,6 +496,18 @@ int cmCTestTestHandler::ProcessHandler() this->SetTestsToRunInformation(this->GetOption("TestsToRunInformation")); this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion"))); const char* val; + val = this->GetOption("LabelRegularExpression"); + if ( val ) + { + this->UseIncludeLabelRegExpFlag = true; + this->IncludeLabelRegExp = val; + } + val = this->GetOption("ExcludeLabelRegularExpression"); + if ( val ) + { + this->UseExcludeLabelRegExpFlag = true; + this->ExcludeLabelRegularExpression = val; + } val = this->GetOption("IncludeRegularExpression"); if ( val ) { @@ -939,6 +955,79 @@ void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it, } //---------------------------------------------------------------------- +void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it) +{ + // if not using Labels to filter then return + if (!this->UseIncludeLabelRegExpFlag ) + { + return; + } + // if there are no labels and we are filtering by labels + // then exclude the test as it does not have the label + if(it.Labels.size() == 0 ) + { + it.IsInBasedOnREOptions = false; + return; + } + // check to see if the label regular expression matches + bool found = false; // assume it does not match + // loop over all labels and look for match + for(std::vector<std::string>::iterator l = it.Labels.begin(); + l != it.Labels.end(); ++l) + { + if(this->IncludeLabelRegularExpression.find(*l)) + { + found = true; + } + } + // if no match was found, exclude the test + if(!found) + { + it.IsInBasedOnREOptions = false; + } +} + + +//---------------------------------------------------------------------- +void cmCTestTestHandler::CheckLabelFilterExclude(cmCTestTestProperties& it) +{ + // if not using Labels to filter then return + if (!this->UseExcludeLabelRegExpFlag ) + { + return; + } + // if there are no labels and we are excluding by labels + // then do nothing as a no label can not be a match + if(it.Labels.size() == 0 ) + { + return; + } + // check to see if the label regular expression matches + bool found = false; // assume it does not match + // loop over all labels and look for match + for(std::vector<std::string>::iterator l = it.Labels.begin(); + l != it.Labels.end(); ++l) + { + if(this->ExcludeLabelRegularExpression.find(*l)) + { + found = true; + } + } + // if match was found, exclude the test + if(found) + { + it.IsInBasedOnREOptions = false; + } +} + +//---------------------------------------------------------------------- +void cmCTestTestHandler::CheckLabelFilter(cmCTestTestProperties& it) +{ + this->CheckLabelFilterInclude(it); + this->CheckLabelFilterExclude(it); +} + +//---------------------------------------------------------------------- void cmCTestTestHandler::ComputeTestList() { this->TestList.clear(); // clear list of test @@ -952,12 +1041,12 @@ void cmCTestTestHandler::ComputeTestList() this->GetListOfTests(); } cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size(); - // how many tests are in based on RegExp? int inREcnt = 0; cmCTestTestHandler::ListOfTests::iterator it; for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ ) { + this->CheckLabelFilter(*it); if (it->IsInBasedOnREOptions) { inREcnt ++; @@ -1808,6 +1897,16 @@ std::string cmCTestTestHandler //---------------------------------------------------------------------- void cmCTestTestHandler::GetListOfTests() { + if ( !this->IncludeLabelRegExp.empty() ) + { + this->IncludeLabelRegularExpression. + compile(this->IncludeLabelRegExp.c_str()); + } + if ( !this->IncludeLabelRegExp.empty() ) + { + this->ExcludeLabelRegularExpression. + compile(this->ExcludeLabelRegExp.c_str()); + } if ( !this->IncludeRegExp.empty() ) { this->IncludeTestsRegularExpression.compile(this->IncludeRegExp.c_str()); @@ -2376,6 +2475,7 @@ bool cmCTestTestHandler::SetTestsProperties( { rtit->Labels.push_back(*crit); } + } if ( key == "MEASUREMENT" ) { |