Branch: Tag:

2002-05-05

2002-05-05 00:01:28 by Martin Stjernholm <mast@lysator.liu.se>

Include line number info in the tests. Unfortunately the linenumber
capabilities in m4 are too primitive to make accurate line directives
in the test code possible (it's clobbered e.g. for tests inside cond
blocks), but it's at least a bit easier to find the whereabouts of the
failing tests. Also did some minor tweaking of the output from
test_pike.pike.

Rev: bin/mktestsuite:1.19
Rev: bin/test_pike.pike:1.64

1:   #!/usr/local/bin/pike    - /* $Id: test_pike.pike,v 1.63 2002/05/02 16:00:31 nilsson Exp $ */ + /* $Id: test_pike.pike,v 1.64 2002/05/05 00:01:28 mast Exp $ */      import Stdio;   
374:    {    signal_watchdog();    -  int skip=0; +  int skip=0, prev_errors = errors;    string test,condition;    string|int type;    object o;
422:    }    }    +  int testno, testline; +  sscanf(test, "%s\n%s", type, test); +  sscanf(type, "%s: test %d, expected result: %s", string testfile, testno, type); +  +  if (testfile) { +  array split = testfile / ":"; +  testline = (int) split[-1]; +  testfile = split[..sizeof (split) - 2] * ":"; +  } +  +  string pad_on_error = "\n";    if(istty())    { -  if(!verbose) -  werror("%6d\r",e+1); +  if(!verbose) { +  werror("test %d, line %d\r", e+1, testline); +  pad_on_error = " \r";    } -  +  }    else if(quiet){    if(skip) {    if(qmade) werror(" Made %d test%s.\n", qmade, qmade==1?"":"s");
468:    }    if(skip) continue;    -  int testno; -  sscanf(test, "%s\n%s", type, test); -  sscanf(type, "test %d, expected result: %s", testno, type); +  if (!testfile || !testno || !type) { +  werror ("%sInvalid format in test file: %O\n", pad_on_error, type); +  errors++; +  continue; +  }       if (prompt) {    if (Stdio.Readline()->
482:       if(verbose)    { -  werror("Doing test %d (%d total)%s\n", testno, successes+errors+1, extra_info); +  werror("Doing test %d (%d total) at %s:%d%s\n", +  testno, successes+errors+1, testfile, testline, extra_info);    if(verbose>1) bzot(test);    }       if(check > 1) _verify_internals();       shift++; -  string fname = testsuite + ": Test " + testno + +  string fname = testfile + ":" + testline + ": Test " + testno +    " (shift " + (shift%3) + ")";       string widener = ([ 0:"",
541:    mixed err;    case "COMPILE":    _dmalloc_set_name(fname,0); -  if(catch(compile_string(to_compile, fname))) +  if(catch(compile_string(to_compile, testsuite)))    {    _dmalloc_set_name(); -  werror("\n" + fname + " failed.\n"); +  werror(pad_on_error + fname + " failed.\n");    bzot(test);    errors++;    }
557:    case "COMPILE_ERROR":    master()->set_inhibit_compile_errors(1);    _dmalloc_set_name(fname,0); -  if(catch(compile_string(to_compile, fname))) +  if(catch(compile_string(to_compile, testsuite)))    {    _dmalloc_set_name();    successes++;    }    else {    _dmalloc_set_name(); -  werror("\n" + fname + " failed (expected compile error).\n"); +  werror(pad_on_error + fname + " failed (expected compile error).\n");    bzot(test);    errors++;    }
577:       at = gauge {    err=catch { -  clone(compile_string(to_compile, fname))->a(); +  clone(compile_string(to_compile, testsuite))->a();    };    };    if(err)
589:    }    else {    _dmalloc_set_name(); -  werror("\n" + fname + " failed (expected eval error).\n"); +  werror(pad_on_error + fname + " failed (expected eval error).\n");    bzot(test);    errors++;    }
599:    default:    if (err = catch{    _dmalloc_set_name(fname,0); -  o=clone(compile_string(to_compile,fname)); +  o=clone(compile_string(to_compile,testsuite));    _dmalloc_set_name();       if(check > 1) _verify_internals();
626:       }) {    // trace(0); -  werror("\n" + fname + " failed.\n"); +  werror(pad_on_error + fname + " failed.\n");    bzot(test);    if (arrayp(err) && sizeof(err) && stringp(err[0])) {    werror("Error: " + master()->describe_backtrace(err));
641:    if( o->__cpp_line != o->__rtl_line ||    ( computed_line && computed_line!=o->__cpp_line))    { -  werror("\n" + fname + " Line numbering failed.\n"); +  werror(pad_on_error + fname + " Line numbering failed.\n");    bzot(test + linetester);    werror(" CPP lines: %d\n",o->__cpp_line);    werror(" RTL lines: %d\n",o->__rtl_line);
658:    case "FALSE":    if(a)    { -  werror("\n" + fname + " failed.\n"); +  werror(pad_on_error + fname + " failed.\n");    bzot(test);    werror(sprintf("o->a(): %O\n",a));    errors++;
671:    case "TRUE":    if(!a)    { -  werror("\n" + fname + " failed.\n"); +  werror(pad_on_error + fname + " failed.\n");    bzot(test);    werror(sprintf("o->a(): %O\n",a));    errors++;
687:       case "RUNCT":    if(!a || !arrayp(a) || sizeof(a)!=2 || !intp(a[0]) || !intp(a[1])) { -  werror("\n" + fname + " failed to return proper results.\n"); +  werror(pad_on_error + fname + " failed to return proper results.\n");    bzot(test);    werror(sprintf("o->a(): %O\n",a));    errors++;
695:    else {    successes += a[0];    errors += a[1]; +  if (verbose)    if(a[1])    werror("%d/%d tests failed.\n", a[1], a[0]+a[1]);    else
705:    case "EQ":    if(a!=b)    { -  werror("\n" + fname + " failed.\n"); +  werror(pad_on_error + fname + " failed.\n");    bzot(test);    werror(sprintf("o->a(): %O\n",a));    werror(sprintf("o->b(): %O\n",b));
719:    case "EQUAL":    if(!equal(a,b))    { -  werror("\n" + fname + " failed.\n"); +  werror(pad_on_error + fname + " failed.\n");    bzot(test);    werror(sprintf("o->a(): %O\n",a));    werror(sprintf("o->b(): %O\n",b));
736:    }    }    +  if (errors > prev_errors) werror ("\n"); +     if(check > 2) _verify_internals();       if(fail && errors)
751:       if(istty())    { -  werror(" \r"); +  werror(" \r");    }    else if(quiet) {    if(!qskipp && !qmadep);