diff --git a/src/lib/test/run.hpp b/src/lib/test/run.hpp index bcb38e222..013581e41 100644 --- a/src/lib/test/run.hpp +++ b/src/lib/test/run.hpp @@ -28,7 +28,7 @@ ** ** @see HelloWorld_test ** @see test::Suite - ** @see mainsuite.cpp + ** @see testrunner.cpp ** @see main.cpp */ diff --git a/src/lib/test/suite.cpp b/src/lib/test/suite.cpp index aaf10dcb1..f1d569884 100644 --- a/src/lib/test/suite.cpp +++ b/src/lib/test/suite.cpp @@ -195,7 +195,7 @@ namespace test { * in this suite is invoked with a empty cmdline vector. * @param cmdline ref to the vector of commandline tokens */ - void + bool Suite::run (Arg cmdline) { PTestMap tests = testcases.getGroup(groupID_); @@ -214,7 +214,7 @@ namespace test { cmdline.erase (cmdline.begin()); VALID (test,testID); exitCode_ |= invokeTestCase (*(*test)(), cmdline); // TODO confusing statement, improve definition of test collection datatype Ticket #289 - return; + return true; } else throw lumiera::error::Invalid ("unknown test : "+testID); @@ -229,6 +229,7 @@ namespace test { VALID (test, i->first); exitCode_ |= invokeTestCase (*(*test)(), cmdline); // actually no cmdline arguments } + return true; } diff --git a/src/lib/test/suite.hpp b/src/lib/test/suite.hpp index 953642150..6e88d4a2b 100644 --- a/src/lib/test/suite.hpp +++ b/src/lib/test/suite.hpp @@ -33,7 +33,7 @@ ** @see test::Test ** @see test::TestOption ** @see run.hpp - ** @see mainsuite.cpp + ** @see testrunner.cpp */ @@ -70,7 +70,7 @@ namespace test { public: Suite (string groupID); - void run (Arg cmdline); + bool run (Arg cmdline); void describe (); int getExitCode () const; static void enrol (Launcher *test, string testID, string groups); diff --git a/src/lib/test/testoption.cpp b/src/lib/test/testoption.cpp index 9e0598d2b..dcb64aedb 100644 --- a/src/lib/test/testoption.cpp +++ b/src/lib/test/testoption.cpp @@ -76,9 +76,6 @@ namespace test { // remove all recognised options from original cmdline vector cmdline = op::collect_unrecognized(parsed.options, op::include_positional); - - if (parameters.count("help")) - std::cerr << *this; } @@ -107,11 +104,25 @@ namespace test { /** @return \c true if --describe switch was given */ bool - TestOption::getDescribe () + TestOption::shouldDescribe () { return parameters["describe"].as(); } + /** handles the --help switch by printing a syntax description + * @return \c false if there was no help request and the + * Suite should indeed be executed. + */ + bool + TestOption::handleHelpRequest() + { + if (parameters.count("help")) + { + std::cerr << *this; + return true; + } + return false; + } ostream& diff --git a/src/lib/test/testoption.hpp b/src/lib/test/testoption.hpp index 4d41de8e6..9691b7b82 100644 --- a/src/lib/test/testoption.hpp +++ b/src/lib/test/testoption.hpp @@ -56,7 +56,8 @@ namespace test { TestOption (lib::Cmdline& cmdline); const string getTestgroup (); const string getTestID (); - bool getDescribe (); + bool handleHelpRequest(); + bool shouldDescribe (); private: boost::program_options::options_description syntax; diff --git a/tests/testrunner.cpp b/tests/testrunner.cpp index 4493fc9b6..28dd91a77 100644 --- a/tests/testrunner.cpp +++ b/tests/testrunner.cpp @@ -1,5 +1,5 @@ /* - mainsuite.cpp - execute a suite of test objects, possibly filtered by category + testrunner.cpp - execute a suite of test objects, possibly filtered by category Copyright (C) Lumiera.org 2008, Christian Thaeter @@ -44,10 +44,10 @@ int main (int argc, const char* argv[]) test::Suite suite (optparser.getTestgroup()); LifecycleHook::trigger (ON_GLOBAL_INIT); - if (optparser.getDescribe()) + if (optparser.shouldDescribe()) suite.describe(); else - suite.run (args); + optparser.handleHelpRequest() || suite.run (args); LifecycleHook::trigger (ON_GLOBAL_SHUTDOWN); return suite.getExitCode();