Skip to content

Commit 7de2c9e

Browse files
authored
Fixed --exclude duplication issue, Conflate case ignore warning in parallel, and minor cleanup (#2017)
1 parent 790e43a commit 7de2c9e

File tree

6 files changed

+56
-45
lines changed

6 files changed

+56
-45
lines changed

hoot-core-test/src/test/cpp/hoot/core/test/ConflateCaseTestSuite.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
namespace hoot
4141
{
4242

43-
ConflateCaseTestSuite::ConflateCaseTestSuite(QString dir) :
44-
AbstractTestSuite(dir)
43+
ConflateCaseTestSuite::ConflateCaseTestSuite(QString dir, bool hideDisableTests)
44+
: AbstractTestSuite(dir),
45+
_hideDisableTests(hideDisableTests)
4546
{
4647
QStringList confs;
4748
loadDir(dir, confs);
@@ -66,13 +67,13 @@ void ConflateCaseTestSuite::loadDir(QString dir, QStringList confs)
6667
QStringList ignoreList;
6768

6869
# ifndef HOOT_HAVE_RND
69-
ignoreList << "hoot-rnd";
70+
ignoreList << "hoot-rnd";
7071
# endif
7172
# ifndef HOOT_HAVE_SERVICES
72-
ignoreList << "hoot-services";
73+
ignoreList << "hoot-services";
7374
# endif
7475
# ifndef HOOT_HAVE_NODEJS
75-
ignoreList << "hoot-js";
76+
ignoreList << "hoot-js";
7677
# endif
7778

7879
QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
@@ -92,7 +93,8 @@ void ConflateCaseTestSuite::loadDir(QString dir, QStringList confs)
9293

9394
if (ignore)
9495
{
95-
LOG_WARN("Disabling: " + path);
96+
if (!_hideDisableTests)
97+
LOG_WARN("Disabling: " + path);
9698
}
9799
else
98100
{

hoot-core-test/src/test/cpp/hoot/core/test/ConflateCaseTestSuite.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ConflateCaseTestSuite : public AbstractTestSuite
4040

4141
public:
4242

43-
ConflateCaseTestSuite(QString dir);
43+
ConflateCaseTestSuite(QString dir, bool hideDisableTests = false);
4444

4545
/**
4646
* Attempts to load a conflate case test given a directory
@@ -49,6 +49,10 @@ class ConflateCaseTestSuite : public AbstractTestSuite
4949
* @param confs hoot configuration files to pass to the test
5050
*/
5151
virtual void loadDir(QString dir, QStringList confs);
52+
53+
private:
54+
55+
bool _hideDisableTests;
5256
};
5357

5458
}

hoot-rnd/src/test/cpp/hoot/rnd/conflate/opt/AbstractRegressionTestFitnessFunction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ namespace hoot
4242

4343
AbstractRegressionTestFitnessFunction::AbstractRegressionTestFitnessFunction(QString dir,
4444
QString configFile,
45-
QString testDirExtension) :
46-
AbstractTestFitnessFunction(),
47-
_configFile(configFile)
45+
QString testDirExtension)
46+
: AbstractTestFitnessFunction(),
47+
_configFile(configFile)
4848
{
4949
_testSuite.reset(new RegressionTestSuite(dir, testDirExtension));
5050
QStringList confs;

hoot-rnd/src/test/cpp/hoot/rnd/conflate/opt/CaseTestFitnessFunction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
namespace hoot
3333
{
3434

35-
CaseTestFitnessFunction::CaseTestFitnessFunction(QString dir, QString configFile) :
36-
AbstractTestFitnessFunction(),
37-
_configFile(configFile)
35+
CaseTestFitnessFunction::CaseTestFitnessFunction(QString dir, QString configFile)
36+
: AbstractTestFitnessFunction(),
37+
_configFile(configFile)
3838
{
3939
_testSuite.reset(new ConflateCaseTestSuite(dir));
4040
QStringList confs;

hoot-rnd/src/test/cpp/hoot/rnd/conflate/opt/RegressionTestSuite.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
namespace hoot
3939
{
4040

41-
RegressionTestSuite::RegressionTestSuite(QString dir, QString testDirExtension) :
42-
AbstractTestSuite(dir),
43-
_testDirExtension(testDirExtension)
41+
RegressionTestSuite::RegressionTestSuite(QString dir, QString testDirExtension)
42+
: AbstractTestSuite(dir),
43+
_testDirExtension(testDirExtension)
4444
{
4545
QDir dirInfo(dir);
4646
_topLevelDir = dirInfo.dirName();

hoot-test/src/main/cpp/hoot/test/main.cpp

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)