torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RegressionFilter Class Reference

Test suite visitor to disable regression tests. More...

+ Inheritance diagram for RegressionFilter:
+ Collaboration diagram for RegressionFilter:

Public Member Functions

virtual ~RegressionFilter (void)
 Removes all test suites marked for pruning. More...
 
virtual string getFullyQualifiedPath (void)
 Returns the current fully qualified test suite path. More...
 
virtual string getFullyQualifiedName (const boost::unit_test::test_case &inTestCase)
 Returns a fully qualified name for the given test case. More...
 
virtual void useTest (const boost::unit_test::test_case &inTestCase)
 Flags the given test case and its parents as being used. More...
 
virtual void visit (const boost::unit_test::test_case &inTestCase)
 Determines whether or not to include the given test case. More...
 
virtual bool test_suite_start (const boost::unit_test::test_suite &inTestSuite)
 Enters a new test suite. More...
 
virtual void test_suite_finish (const boost::unit_test::test_suite &inTestSuite)
 Exits a test suite and prunes it if no test cases remain in it. More...
 

Private Types

typedef
boost::unit_test::test_suite 
test_suite
 Imported type. More...
 
typedef std::string string
 Imported type. More...
 

Private Attributes

std::vector< const test_suite * > mTestSuiteVector
 Vector of test suite pointers. More...
 
std::vector< bool > mTestSuiteUsed
 Vector of test suite usage flags. More...
 
std::vector
< boost::unit_test::test_unit_id > 
mTestSuitePruningIDs
 Vector of test suites to remove. More...
 

Detailed Description

Test suite visitor to disable regression tests.

Definition at line 30 of file UnitTestMain.cpp.

Member Typedef Documentation

typedef std::string RegressionFilter::string
private

Imported type.

Definition at line 33 of file UnitTestMain.cpp.

typedef boost::unit_test::test_suite RegressionFilter::test_suite
private

Imported type.

Definition at line 32 of file UnitTestMain.cpp.

Constructor & Destructor Documentation

virtual RegressionFilter::~RegressionFilter ( void  )
inlinevirtual

Removes all test suites marked for pruning.

Definition at line 43 of file UnitTestMain.cpp.

43  {
44  for(size_t i = 0; i < mTestSuitePruningIDs.size(); i++) {
45  boost::unit_test::framework::master_test_suite().remove(mTestSuitePruningIDs[i]);
46  }
47  }
std::vector< boost::unit_test::test_unit_id > mTestSuitePruningIDs
Vector of test suites to remove.

Member Function Documentation

virtual string RegressionFilter::getFullyQualifiedName ( const boost::unit_test::test_case &  inTestCase)
inlinevirtual

Returns a fully qualified name for the given test case.

Definition at line 58 of file UnitTestMain.cpp.

58  {
59  // assemble the fully qualified name
60  return getFullyQualifiedPath() + inTestCase.p_name.get();
61  }
virtual string getFullyQualifiedPath(void)
Returns the current fully qualified test suite path.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual string RegressionFilter::getFullyQualifiedPath ( void  )
inlinevirtual

Returns the current fully qualified test suite path.

Definition at line 49 of file UnitTestMain.cpp.

49  {
50  // assemble all of the test suite names
51  string name = "";
52  for(size_t i = 0; i < mTestSuiteVector.size(); i++) {
53  name += mTestSuiteVector[i]->p_name.get() + "/";
54  }
55  return name;
56  }
std::vector< const test_suite * > mTestSuiteVector
Vector of test suite pointers.

+ Here is the caller graph for this function:

virtual void RegressionFilter::test_suite_finish ( const boost::unit_test::test_suite &  inTestSuite)
inlinevirtual

Exits a test suite and prunes it if no test cases remain in it.

Definition at line 89 of file UnitTestMain.cpp.

89  {
90 //std::cout << "leaving test suite " << getFullyQualifiedPath() << std::endl;
91  // if nobody needs this test suite, remove it
92  if(!mTestSuiteUsed.back()) {
93  inTestSuite.p_enabled.set(false);
94  mTestSuitePruningIDs.push_back(inTestSuite.p_id);
95  std::cout << "pruning suite " << getFullyQualifiedPath() << std::endl;
96  }
97  // pop the suite information
98  mTestSuiteVector.pop_back();
99  mTestSuiteUsed.pop_back();
100  }
virtual string getFullyQualifiedPath(void)
Returns the current fully qualified test suite path.
std::vector< const test_suite * > mTestSuiteVector
Vector of test suite pointers.
std::vector< boost::unit_test::test_unit_id > mTestSuitePruningIDs
Vector of test suites to remove.
std::vector< bool > mTestSuiteUsed
Vector of test suite usage flags.

+ Here is the call graph for this function:

virtual bool RegressionFilter::test_suite_start ( const boost::unit_test::test_suite &  inTestSuite)
inlinevirtual

Enters a new test suite.

Definition at line 81 of file UnitTestMain.cpp.

81  {
82  // push the new suite information
83  mTestSuiteVector.push_back(&inTestSuite);
84  mTestSuiteUsed.push_back(false);
85 //std::cout << "entering test suite " << getFullyQualifiedPath() << std::endl;
86  return true;
87  }
std::vector< const test_suite * > mTestSuiteVector
Vector of test suite pointers.
std::vector< bool > mTestSuiteUsed
Vector of test suite usage flags.
virtual void RegressionFilter::useTest ( const boost::unit_test::test_case &  inTestCase)
inlinevirtual

Flags the given test case and its parents as being used.

Definition at line 63 of file UnitTestMain.cpp.

63  {
64  // mark this suite and all parents as used
65  for(size_t i = 0; i < mTestSuiteVector.size(); i++) mTestSuiteUsed[i] = true;
66  }
std::vector< const test_suite * > mTestSuiteVector
Vector of test suite pointers.
std::vector< bool > mTestSuiteUsed
Vector of test suite usage flags.

+ Here is the caller graph for this function:

virtual void RegressionFilter::visit ( const boost::unit_test::test_case &  inTestCase)
inlinevirtual

Determines whether or not to include the given test case.

Definition at line 68 of file UnitTestMain.cpp.

68  {
69  string name = getFullyQualifiedName(inTestCase);
70  // determine whether to include the test
71  if(name.find("Regression") == string::npos && name.find("regression") == string::npos) {
72 std::cout << "keeping case " << name << std::endl;
73  useTest(inTestCase);
74  } else {
75  inTestCase.p_enabled.set(false);
76  boost::unit_test::framework::master_test_suite().remove(inTestCase.p_id);
77 std::cout << "pruning case " << name << std::endl;
78  }
79  }
virtual string getFullyQualifiedName(const boost::unit_test::test_case &inTestCase)
Returns a fully qualified name for the given test case.
virtual void useTest(const boost::unit_test::test_case &inTestCase)
Flags the given test case and its parents as being used.

+ Here is the call graph for this function:

Field Documentation

std::vector<boost::unit_test::test_unit_id> RegressionFilter::mTestSuitePruningIDs
private

Vector of test suites to remove.

Definition at line 40 of file UnitTestMain.cpp.

std::vector<bool> RegressionFilter::mTestSuiteUsed
private

Vector of test suite usage flags.

Definition at line 38 of file UnitTestMain.cpp.

std::vector<const test_suite*> RegressionFilter::mTestSuiteVector
private

Vector of test suite pointers.

Definition at line 36 of file UnitTestMain.cpp.


The documentation for this class was generated from the following file: