@@ -155,43 +155,41 @@ class HootTestListener : public CppUnit::TestListener
155155 double _slowTest;
156156};
157157
158- void filterPattern (CppUnit::Test* from, std::vector<CppUnit::Test*> &to, QString pattern,
159- bool includeOnMatch)
158+ void getTestVector (CppUnit::Test* from, vector<CppUnit::Test*>& to)
160159{
161- QRegExp regex (pattern);
162-
163160 for (int i = 0 ; i < from->getChildTestCount (); i++)
164161 {
165162 CppUnit::Test* child = from->getChildTestAt (i);
166- QString name = QString::fromStdString (child->getName ());
167163 if (dynamic_cast <CppUnit::TestComposite*>(child))
168- {
169- filterPattern (child, to, pattern, includeOnMatch);
170- }
171- else if (regex.exactMatch (name) == includeOnMatch)
172- {
164+ getTestVector (child, to);
165+ else
166+ to.push_back (child);
167+ }
168+ }
169+
170+ void getTestVector (const vector<TestPtr>& from, vector<CppUnit::Test*>& to)
171+ {
172+ for (vector<TestPtr>::size_type i = 0 ; i < from.size (); ++i)
173+ {
174+ CppUnit::Test* child = from[i].get ();
175+ if (dynamic_cast <CppUnit::TestComposite*>(child))
176+ getTestVector (child, to);
177+ else
173178 to.push_back (child);
174- }
175179 }
176180}
177181
178- void filterPattern (const std::vector<TestPtr > &from, std::vector<CppUnit::Test*> &to, QString pattern ,
179- bool includeOnMatch)
182+ void filterPattern (const std::vector<CppUnit::Test* > &from, std::vector<CppUnit::Test*> &to,
183+ QString pattern, bool includeOnMatch)
180184{
181185 QRegExp regex (pattern);
182186
183187 for (size_t i = 0 ; i < from.size (); i++)
184188 {
185- CppUnit::Test* child = from[i]. get () ;
189+ CppUnit::Test* child = from[i];
186190 QString name = QString::fromStdString (child->getName ());
187- if (dynamic_cast <CppUnit::TestComposite*>(child))
188- {
189- filterPattern (child, to, pattern, includeOnMatch);
190- }
191- else if (regex.exactMatch (name) == includeOnMatch)
192- {
191+ if (regex.exactMatch (name) == includeOnMatch)
193192 to.push_back (child);
194- }
195193 }
196194}
197195
@@ -363,7 +361,7 @@ void populateTests(_TestType t, std::vector<TestPtr> &vTests, bool printDiff, bo
363361 vTests.push_back (TestPtr (new ScriptTestSuite (" test-files/cmd/quick/" , printDiff, QUICK_WAIT, hideDisableTests)));
364362 vTests.push_back (TestPtr (new ScriptTestSuite (" test-files/cmd/slow/" , printDiff, SLOW_WAIT, hideDisableTests)));
365363 vTests.push_back (TestPtr (new ScriptTestSuite (" test-files/cmd/slow/serial/" , printDiff, SLOW_WAIT, hideDisableTests)));
366- vTests.push_back (TestPtr (new ConflateCaseTestSuite (" test-files/cases" )));
364+ vTests.push_back (TestPtr (new ConflateCaseTestSuite (" test-files/cases" , hideDisableTests )));
367365 vTests.push_back (TestPtr (CppUnit::TestFactoryRegistry::getRegistry (" current" ).makeTest ()));
368366 vTests.push_back (TestPtr (CppUnit::TestFactoryRegistry::getRegistry (" quick" ).makeTest ()));
369367 vTests.push_back (TestPtr (CppUnit::TestFactoryRegistry::getRegistry (" TgsTest" ).makeTest ()));
@@ -372,7 +370,7 @@ void populateTests(_TestType t, std::vector<TestPtr> &vTests, bool printDiff, bo
372370 case SLOW_ONLY:
373371 vTests.push_back (TestPtr (new ScriptTestSuite (" test-files/cmd/slow/" , printDiff, SLOW_WAIT, hideDisableTests)));
374372 vTests.push_back (TestPtr (new ScriptTestSuite (" test-files/cmd/slow/serial/" , printDiff, SLOW_WAIT, hideDisableTests)));
375- vTests.push_back (TestPtr (new ConflateCaseTestSuite (" test-files/cases" )));
373+ vTests.push_back (TestPtr (new ConflateCaseTestSuite (" test-files/cases" , hideDisableTests )));
376374 vTests.push_back (TestPtr (CppUnit::TestFactoryRegistry::getRegistry (" slow" ).makeTest ()));
377375 break ;
378376 case GLACIAL:
@@ -384,7 +382,7 @@ void populateTests(_TestType t, std::vector<TestPtr> &vTests, bool printDiff, bo
384382 vTests.push_back (TestPtr (new ScriptTestSuite (" test-files/cmd/slow/serial/" , printDiff, SLOW_WAIT, hideDisableTests)));
385383 vTests.push_back (TestPtr (new ScriptTestSuite (" test-files/cmd/glacial/" , printDiff, GLACIAL_WAIT, hideDisableTests)));
386384 vTests.push_back (TestPtr (new ScriptTestSuite (" test-files/cmd/glacial/serial/" , printDiff, GLACIAL_WAIT, hideDisableTests)));
387- vTests.push_back (TestPtr (new ConflateCaseTestSuite (" test-files/cases" )));
385+ vTests.push_back (TestPtr (new ConflateCaseTestSuite (" test-files/cases" , hideDisableTests )));
388386 vTests.push_back (TestPtr (CppUnit::TestFactoryRegistry::getRegistry (" current" ).makeTest ()));
389387 vTests.push_back (TestPtr (CppUnit::TestFactoryRegistry::getRegistry (" quick" ).makeTest ()));
390388 vTests.push_back (TestPtr (CppUnit::TestFactoryRegistry::getRegistry (" TgsTest" ).makeTest ()));
@@ -564,31 +562,38 @@ int main(int argc, char *argv[])
564562 populateTests (GLACIAL_ONLY, vAllTests, printDiff);
565563 }
566564
565+ vector<CppUnit::Test*> vTests;
566+ getTestVector (vAllTests, vTests);
567567 bool filtered = false ;
568+
568569 for (int i = 0 ; i < args.size (); i++)
569570 {
570571 if (args[i].startsWith (" --exclude=" ))
571572 {
573+ if (vTestsToRun.size () > 0 )
574+ {
575+ // On the second (or more) time around exclude from the excluded list
576+ vTests.swap (vTestsToRun);
577+ vTestsToRun.clear ();
578+ }
572579 int equalsPos = args[i].indexOf (' =' );
573580 QString regex = args[i].mid (equalsPos + 1 );
574581 LOG_WARN (" Excluding pattern: " << regex);
575- filterPattern (vAllTests , vTestsToRun, regex, false );
582+ filterPattern (vTests , vTestsToRun, regex, false );
576583 filtered = true ;
577584 }
578585 else if (args[i].startsWith (" --include=" ))
579586 {
580587 int equalsPos = args[i].indexOf (' =' );
581588 QString regex = args[i].mid (equalsPos + 1 );
582589 LOG_WARN (" Including only tests that match: " << regex);
583- filterPattern (vAllTests , vTestsToRun, regex, true );
590+ filterPattern (vTests , vTestsToRun, regex, true );
584591 filtered = true ;
585592 }
586593 }
587594
588595 if (!filtered) // Do all tests
589- {
590- filterPattern (vAllTests, vTestsToRun, " .*" , true );
591- }
596+ vTestsToRun.swap (vTests);
592597 cout << " Running core tests. Test count: " << vTestsToRun.size () << endl;
593598 }
594599
0 commit comments