39 #include <boost/algorithm/string.hpp> 53 using boost::algorithm::trim;
59 typedef map<string, Launcher*> TestMap;
60 typedef shared_ptr<TestMap> PTestMap;
61 typedef map<string,PTestMap> GroupMap;
82 getGroup (
string grpID)
84 return groups_[grpID];
88 add2group (
Launcher*
test,
string testID,
string groupID)
91 REQUIRE( !isnil(testID) );
92 REQUIRE( !isnil(groupID) );
94 PTestMap& group = getGroup(groupID);
96 group.reset(
new TestMap );
97 (*group)[testID] = test;
120 REQUIRE( !isnil(testID) );
122 std::istringstream ss(groups);
125 testcases.add2group(test, testID, group);
128 testcases.add2group(test,testID, ALLGROUP);
136 const int Suite::TEST_OK = 0;
149 REQUIRE( !isnil(groupID) );
150 TRACE(
test,
"Test-Suite( groupID=%s )\n", groupID.c_str () );
153 std::srand (std::time (
nullptr));
155 if (!testcases.getGroup(groupID))
161 Suite::getExitCode ()
const 168 #define IS_VALID(test,testID) \ 169 ASSERT ((test), "NULL testcase launcher for test '%s' found in testsuite '%s'", groupID_.c_str(),testID.c_str()); 175 invokeTestCase (
Test& theTest, Arg cmdline)
179 INFO (
test,
"++------------------- invoking TEST: %s",
cStr(typeStr (theTest)));
180 theTest.run (cmdline);
181 return Suite::TEST_OK;
186 cerr <<
"*** Test Failure " << theTest << endl;
187 cerr <<
"*** : " << failure.
what() << endl;
188 ERROR (
test,
"Error state %s", errorID);
189 WARN (progress,
"Caught exception %s", failure.
what());
207 PTestMap tests = testcases.getGroup(groupID_);
211 if (0 < cmdline.size())
213 string& testID (cmdline[0]);
215 if ( contains (*tests, testID))
220 IS_VALID (test,testID);
224 if (1 == cmdline.size()) cmdline.clear();
226 exitCode_ |= invokeTestCase (*test->makeInstance(), cmdline);
235 for ( TestMap::iterator i=tests->begin(); i!=tests->end(); ++i )
237 cout <<
"\n ----------"<< i->first<<
"----------\n";
239 IS_VALID (test, i->first);
240 exitCode_ |= invokeTestCase (*test->makeInstance(), cmdline);
253 PTestMap tests = testcases.getGroup(groupID_);
256 cout <<
"TESTING \"Component Test Suite: " << groupID_ <<
"\" ./test-components\n\n";
258 for ( TestMap::iterator i=tests->begin(); i!=tests->end(); ++i )
260 string key (i->first);
262 cout <<
"TEST \""<<key<<
"\" "<<key<<
" <<END\n";
264 IS_VALID (test, i->first);
267 test->makeInstance()->run(noCmdline);
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
virtual CStr what() const noexcept override
std::exception interface : yield a diagnostic message
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