fix long standing error in testsuite runner

...uncovered by switching to c++11
When invoking an individual test, we used to erase
the 0-th cmdline argument, which happens to be allways
the name of the test being invoked. Yet none of our
tests actually complied to that contract. Rather,
all tests taking arguments access them by 1-based
argument index. Previously, the argument values just
happened to be still in memory at the original location
after erasing the 0st element.

"Fixed" that by changing the contract. Now, the 0th argument
remains in place, but when there are no additional arguments,
the whole cmdline is cleared.
This is messy, but the test runer needs to be rewritten
entirely, the whole API is clumsy and dangerous. Ticket #289
This commit is contained in:
Fischlurch 2014-05-06 00:24:45 +02:00
parent a4c41d1c12
commit 643dfe3ea8
7 changed files with 17 additions and 12 deletions

View file

@ -159,7 +159,7 @@ namespace test {
#define VALID(test,testID) \
#define IS_VALID(test,testID) \
ASSERT ((test), "NULL testcase launcher for test '%s' found in testsuite '%s'", groupID_.c_str(),testID.c_str());
@ -200,7 +200,7 @@ namespace test {
{
PTestMap tests = testcases.getGroup(groupID_);
if (!tests)
throw lumiera::error::Invalid ("test group not found"); ///////// TODO: pass error description
throw lumiera::error::Invalid ("No tests found for test group \""+groupID_+"\"");
if (0 < cmdline.size())
{
@ -211,8 +211,12 @@ namespace test {
// first cmdline argument denotes a valid testcase registered in
// this group: invoke just this test with the remaining cmdline
Launcher* test = (*tests)[testID];
cmdline.erase (cmdline.begin());
VALID (test,testID);
IS_VALID (test,testID);
// Special contract: in case the cmdline holds no actual arguments
// beyond the test name, then it's cleared entirely.
if (1 == cmdline.size()) cmdline.clear(); // TODO this invalidates also testID -- really need to redesign the API ////TICKET #289
exitCode_ |= invokeTestCase (*(*test)(), cmdline); // TODO confusing statement, improve definition of test collection datatype Ticket #289
return true;
}
@ -226,7 +230,7 @@ namespace test {
{
std::cout << "\n ----------"<< i->first<< "----------\n";
Launcher* test = (i->second);
VALID (test, i->first);
IS_VALID (test, i->first);
exitCode_ |= invokeTestCase (*(*test)(), cmdline); // actually no cmdline arguments
}
return true;
@ -251,7 +255,7 @@ namespace test {
cout << "\n\n";
cout << "TEST \""<<key<<"\" "<<key<<" <<END\n";
Launcher* test = (i->second);
VALID (test, i->first);
IS_VALID (test, i->first);
try
{
(*test)()->run(noCmdline); // run it to insert test generated output

View file

@ -40,7 +40,8 @@ namespace test {
*/
class HelloWorld_test : public Test
{
virtual void run(Arg arg)
virtual void
run (Arg arg)
{
int num= isnil(arg)? 1 : lexical_cast<int> (arg[1]);

View file

@ -89,7 +89,7 @@ namespace test{
virtual void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[0]);
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
checkDistinctValIter();

View file

@ -184,7 +184,7 @@ namespace test{
virtual void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[0]);
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
useSimpleWrappedContainer ();

View file

@ -165,7 +165,7 @@ namespace test{
virtual void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[0]);
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
verify_simpleIters();
verify_transformIter();

View file

@ -98,7 +98,7 @@ namespace test{
virtual void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[0]);
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
TestSource source(NUM_ELMS);

View file

@ -128,7 +128,7 @@ namespace test {
void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[0]);
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
VecI container = buildTestNumberz (NUM_ELMS);
RangeI iterator(container.begin(), container.end());