39 #include <boost/algorithm/string.hpp> 53 using boost::algorithm::trim;
60 typedef map<string, Launcher*> TestMap;
61 typedef shared_ptr<TestMap> PTestMap;
62 typedef map<string,PTestMap> GroupMap;
83 getGroup (
string grpID)
85 return groups_[grpID];
89 add2group (
Launcher*
test,
string testID,
string groupID)
92 REQUIRE( !isnil(testID) );
93 REQUIRE( !isnil(groupID) );
95 PTestMap& group = getGroup(groupID);
97 group.reset(
new TestMap );
98 (*group)[testID] = test;
121 REQUIRE( !isnil(testID) );
123 std::istringstream ss(groups);
126 testcases.add2group(test, testID, group);
129 testcases.add2group(test,testID, ALLGROUP);
137 const int Suite::TEST_OK = 0;
150 REQUIRE( !isnil(groupID) );
151 TRACE(
test,
"Test-Suite( groupID=%s )\n", groupID.c_str () );
154 std::srand (std::time (
nullptr));
156 if (!testcases.getGroup(groupID))
162 Suite::getExitCode ()
const 169 #define IS_VALID(test,testID) \ 170 ASSERT ((test), "NULL testcase launcher for test '%s' found in testsuite '%s'", groupID_.c_str(),testID.c_str()); 176 invokeTestCase (
Test& theTest, Arg cmdline)
180 INFO (
test,
"++------------------- invoking TEST: %s", cStr(typeStr (theTest)));
181 theTest.run (cmdline);
182 return Suite::TEST_OK;
187 cerr <<
"*** Test Failure " << theTest << endl;
188 cerr <<
"*** : " << failure.
what() << endl;
189 ERROR (
test,
"Error state %s", errorID);
190 WARN (progress,
"Caught exception %s", failure.
what());
208 PTestMap tests = testcases.getGroup(groupID_);
212 if (0 < cmdline.size())
214 string& testID (cmdline[0]);
216 if ( contains (*tests, testID))
221 IS_VALID (test,testID);
225 if (1 == cmdline.size()) cmdline.clear();
227 exitCode_ |= invokeTestCase (*test->makeInstance(), cmdline);
236 for ( TestMap::iterator i=tests->begin(); i!=tests->end(); ++i )
238 cout <<
"\n ----------"<< i->first<<
"----------\n";
240 IS_VALID (test, i->first);
241 exitCode_ |= invokeTestCase (*test->makeInstance(), cmdline);
254 PTestMap tests = testcases.getGroup(groupID_);
257 cout <<
"TESTING \"Component Test Suite: " << groupID_ <<
"\" ./test-components\n\n";
259 for ( TestMap::iterator i=tests->begin(); i!=tests->end(); ++i )
261 string key (i->first);
263 cout <<
"TEST \""<<key<<
"\" "<<key<<
" <<END\n";
265 IS_VALID (test, i->first);
268 test->makeInstance()->run(noCmdline);
virtual CStr what() const noexcept override
std::exception interface : yield a diagnostic message
const char * cStr(string const &org)
convenience shortcut: conversion to c-String via string.
This header is for including and configuring NoBug.
helper to collect and manage the test cases.
static const int EXCEPTION_THROWN
exit code returned when any individual test threw
Derived specific exceptions within Lumiera's exception hierarchy.
Abstract Base Class for all testcases.
bool run(Arg cmdline)
run all testcases contained in this Suite.
Suite(string groupID)
create a suite comprised of all the testcases previously registered with this this group...
Class to encapsulate the typical C-style commandline definition.
Simple test class runner.
Building and running a suite of tests, implemented as test classes.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
lumiera_err lumiera_error(void)
Get and clear current error state.
static const string ALLGROUP
"magic" groupID containing all registered testcases
Helper to use a single extension point for specialised hash functions.
interface: generic testcase creating functor.
Lumiera error handling (C++ interface).
void describe()
print to stdout an enumeration of all testcases in this suite, in a format suitable for use with Ceht...
static void enrol(Launcher *test, string testID, string groups)
register the given test-launcher, so it can be later accessed either as a member of one of the specif...
Abstraction of the usual int argc, int** argv-Commandline, to be able to treat it as a vector of stri...
Interface and Base definition for all Lumiera Exceptions.
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container