[Cmake-commits] [cmake-commits] hoffman committed cmCTestTestCommand.cxx 1.11 1.12 cmCTestTestCommand.h 1.8 1.9 cmCTestTestHandler.cxx 1.91 1.92 cmCTestTestHandler.h 1.34 1.35

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Feb 10 14:24:26 EST 2009


Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv911/Source/CTest

Modified Files:
	cmCTestTestCommand.cxx cmCTestTestCommand.h 
	cmCTestTestHandler.cxx cmCTestTestHandler.h 
Log Message:
ENH: add the ability to run tests by labels 


Index: cmCTestTestCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestCommand.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C 2 -d -r1.8 -r1.9
*** cmCTestTestCommand.h	8 Oct 2008 21:58:39 -0000	1.8
--- cmCTestTestCommand.h	10 Feb 2009 19:24:23 -0000	1.9
***************
*** 64,68 ****
        "             [START start number] [END end number]\n"
        "             [STRIDE stride number] [EXCLUDE exclude regex ]\n"
!       "             [INCLUDE include regex] [RETURN_VALUE res] )\n"
        "Tests the given build directory and stores results in Test.xml. The "
        "second argument is a variable that will hold value. Optionally, "
--- 64,70 ----
        "             [START start number] [END end number]\n"
        "             [STRIDE stride number] [EXCLUDE exclude regex ]\n"
!       "             [INCLUDE include regex] [RETURN_VALUE res] \n" 
!       "             [EXCLUDE_LABEL exclude regex] \n"
!       "             [INCLUDE_LABEL label regex] )\n"
        "Tests the given build directory and stores results in Test.xml. The "
        "second argument is a variable that will hold value. Optionally, "
***************
*** 70,74 ****
        "END, the number of tests to skip between each test STRIDE, a regular "
        "expression for tests to run INCLUDE, or a regular expression for tests "
!       "to not run EXCLUDE.";
      }
  
--- 72,78 ----
        "END, the number of tests to skip between each test STRIDE, a regular "
        "expression for tests to run INCLUDE, or a regular expression for tests "
!       "to not run EXCLUDE. EXCLUDE_LABEL and INCLUDE_LABEL are regular "
!       "expression for test to be included or excluded by the test "
!       "property LABEL.";
      }
  
***************
*** 87,90 ****
--- 91,96 ----
      ctt_EXCLUDE,
      ctt_INCLUDE,
+     ctt_EXCLUDE_LABEL,
+     ctt_INCLUDE_LABEL,
      ctt_LAST
    };

Index: cmCTestTestCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestCommand.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -C 2 -d -r1.11 -r1.12
*** cmCTestTestCommand.cxx	9 Sep 2008 15:44:16 -0000	1.11
--- cmCTestTestCommand.cxx	10 Feb 2009 19:24:23 -0000	1.12
***************
*** 27,30 ****
--- 27,32 ----
    this->Arguments[ctt_EXCLUDE] = "EXCLUDE";
    this->Arguments[ctt_INCLUDE] = "INCLUDE";
+   this->Arguments[ctt_EXCLUDE_LABEL] = "EXCLUDE_LABEL";
+   this->Arguments[ctt_INCLUDE_LABEL] = "INCLUDE_LABEL";
    this->Arguments[ctt_LAST] = 0;
    this->Last = ctt_LAST;
***************
*** 79,82 ****
--- 81,94 ----
      handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]);
      }
+   if(this->Values[ctt_EXCLUDE_LABEL])
+     {
+     handler->SetOption("ExcludeLabelRegularExpression",
+                        this->Values[ctt_EXCLUDE_LABEL]);
+     }
+   if(this->Values[ctt_INCLUDE_LABEL])
+     {
+     handler->SetOption("LabelRegularExpression", 
+                        this->Values[ctt_INCLUDE_LABEL]);
+     }
    return handler;
  }

Index: cmCTestTestHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestHandler.cxx,v
retrieving revision 1.91
retrieving revision 1.92
diff -C 2 -d -r1.91 -r1.92
*** cmCTestTestHandler.cxx	5 Feb 2009 21:31:37 -0000	1.91
--- cmCTestTestHandler.cxx	10 Feb 2009 19:24:23 -0000	1.92
***************
*** 392,395 ****
--- 392,397 ----
    this->UseUnion = false;
  
+   this->UseIncludeLabelRegExpFlag   = false;
+   this->UseExcludeLabelRegExpFlag   = false;
    this->UseIncludeRegExpFlag   = false;
    this->UseExcludeRegExpFlag   = false;
***************
*** 434,437 ****
--- 436,441 ----
    this->UseExcludeRegExpFlag = false;
    this->UseExcludeRegExpFirst = false;
+   this->IncludeLabelRegularExpression = "";
+   this->ExcludeLabelRegularExpression = "";
    this->IncludeRegExp = "";
    this->ExcludeRegExp = "";
***************
*** 493,496 ****
--- 497,512 ----
    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 )
***************
*** 940,943 ****
--- 956,1032 ----
  
  //----------------------------------------------------------------------
+ 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()
  {
***************
*** 953,957 ****
      }
    cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size();
- 
    // how many tests are in based on RegExp?
    int inREcnt = 0;
--- 1042,1045 ----
***************
*** 959,962 ****
--- 1047,1051 ----
    for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ )
      {
+     this->CheckLabelFilter(*it);
      if (it->IsInBasedOnREOptions)
        {
***************
*** 1809,1812 ****
--- 1898,1911 ----
  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() )
      {
***************
*** 2377,2380 ****
--- 2476,2480 ----
                rtit->Labels.push_back(*crit);
                }
+             
              }
            if ( key == "MEASUREMENT" )

Index: cmCTestTestHandler.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestHandler.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -C 2 -d -r1.34 -r1.35
*** cmCTestTestHandler.h	2 Feb 2009 18:24:26 -0000	1.34
--- cmCTestTestHandler.h	10 Feb 2009 19:24:24 -0000	1.35
***************
*** 235,243 ****
--- 235,249 ----
    std::vector<int>        TestsToRun;
  
+   bool UseIncludeLabelRegExpFlag;
+   bool UseExcludeLabelRegExpFlag;
    bool UseIncludeRegExpFlag;
    bool UseExcludeRegExpFlag;
    bool UseExcludeRegExpFirst;
+   std::string IncludeLabelRegExp;
+   std::string ExcludeLabelRegExp;
    std::string IncludeRegExp;
    std::string ExcludeRegExp;
+   cmsys::RegularExpression IncludeLabelRegularExpression;
+   cmsys::RegularExpression ExcludeLabelRegularExpression;
    cmsys::RegularExpression IncludeTestsRegularExpression;
    cmsys::RegularExpression ExcludeTestsRegularExpression;
***************
*** 245,248 ****
--- 251,257 ----
    std::string GenerateRegressionImages(const std::string& xml);
    cmsys::RegularExpression DartStuff1;
+   void CheckLabelFilter(cmCTestTestProperties& it);
+   void CheckLabelFilterExclude(cmCTestTestProperties& it);
+   void CheckLabelFilterInclude(cmCTestTestProperties& it);
  
    std::string TestsToRunString;



More information about the Cmake-commits mailing list