avoid the ugly hack with adding an empty string to m_registries to indicate that we need to run all tests

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60000 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-04-03 16:38:20 +00:00
parent f253c22f29
commit e992b97f1b

View File

@@ -216,6 +216,15 @@ public:
private: private:
void List(Test *test, const string& parent = "") const; void List(Test *test, const string& parent = "") const;
// call List() if m_list or runner.addTest() otherwise
void AddTest(CppUnit::TestRunner& runner, Test *test)
{
if (m_list)
List(test);
else
runner.addTest(test);
}
// command lines options/parameters // command lines options/parameters
bool m_list; bool m_list;
bool m_longlist; bool m_longlist;
@@ -349,11 +358,6 @@ bool TestApp::OnCmdLineParsed(wxCmdLineParser& parser)
for (size_t i = 0; i < parser.GetParamCount(); i++) for (size_t i = 0; i < parser.GetParamCount(); i++)
m_registries.push_back(parser.GetParam(i)); m_registries.push_back(parser.GetParam(i));
} }
else
{
// FIXME: this is an ugly and unnecessary hack
m_registries.push_back("");
}
m_longlist = parser.Found("longlist"); m_longlist = parser.Found("longlist");
m_list = m_longlist || parser.Found("list"); m_list = m_longlist || parser.Found("list");
@@ -442,19 +446,17 @@ int TestApp::OnRun()
CppUnit::TextTestRunner runner; CppUnit::TextTestRunner runner;
if ( m_registries.empty() )
{
// run or list all tests
AddTest(runner, TestFactoryRegistry::getRegistry().makeTest());
}
else // run only the selected tests
{
for (size_t i = 0; i < m_registries.size(); i++) for (size_t i = 0; i < m_registries.size(); i++)
{ {
Test *test; const wxString reg = m_registries[i];
Test *test = GetTestByName(reg);
wxString reg = m_registries[i];
if ( reg.empty() )
{
// no test name, run all the tests
test = TestFactoryRegistry::getRegistry().makeTest();
}
else // test name specified, run just this test
{
test = GetTestByName(reg);
if ( !test && !reg.EndsWith("TestCase") ) if ( !test && !reg.EndsWith("TestCase") )
{ {
@@ -466,12 +468,9 @@ int TestApp::OnRun()
cerr << "No such test suite: " << string(reg.mb_str()) << endl; cerr << "No such test suite: " << string(reg.mb_str()) << endl;
return 2; return 2;
} }
}
if (m_list) AddTest(runner, test);
List(test); }
else
runner.addTest(test);
} }
if ( m_list ) if ( m_list )