pike.git / bin / test_pike.pike

version» Context lines:

pike.git/bin/test_pike.pike: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;      #if !constant(_verify_internals)   #define _verify_internals()   #endif      #if !constant(_dmalloc_set_name)   void _dmalloc_set_name(mixed ... args) {}   #endif
pike.git/bin/test_pike.pike:367:    {    tests = read_tests( testsuite );       werror("Doing tests in %s (%d tests)\n", testsuite, sizeof(tests));    int qmade, qskipped, qmadep, qskipp;       for(e=start;e<sizeof(tests);e++)    {    signal_watchdog();    -  int skip=0; +  int skip=0, prev_errors = errors;    string test,condition;    string|int type;    object o;    mixed a,b;       if(check)    {    if(check>0 || (e % -check)==0 )    _verify_internals();    }
pike.git/bin/test_pike.pike:415:    if(tmp==-1)    {    if(verbose)    werror("Not doing test "+(e+1)+"\n");    successes++;    skipped++;    skip=1;    }    }    +  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");    qmade=0;    qskipp=1;    qskipped++;    }    else {    if(qskipped) werror(" Skipped %d test%s.\n", qskipped, qskipped==1?"":"s");    qskipped=0;
pike.git/bin/test_pike.pike:461:    default:    werror(skip?"-":"+");    break;       case 49:    werror(skip?"-\n":"+\n");    }    }    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()->    read(sprintf("About to run test: %d. [<RETURN>/'quit']: ",    testno)) == "quit") {    break testloop;    }    }       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:"",    1:"\nint \x30c6\x30b9\x30c8=0;\n",    2:"\nint \x10001=0;\n" ])[shift%3];       // widener += "#pragma strict_types\n";       if(test[-1]!='\n') test+="\n";   
pike.git/bin/test_pike.pike:534:       // _optimizer_debug(5);       if(verbose>9) bzot(to_compile);    switch(type)    {    mixed at,bt;    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++;    }    else {    _dmalloc_set_name();    successes++;    }    break;       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++;    }    master()->set_inhibit_compile_errors(0);    break;       case "EVAL_ERROR":    master()->set_inhibit_compile_errors(1);    _dmalloc_set_name(fname,0);       at = gauge {    err=catch { -  clone(compile_string(to_compile, fname))->a(); +  clone(compile_string(to_compile, testsuite))->a();    };    };    if(err)    {    _dmalloc_set_name();    successes++;    if(verbose>2)    werror("Time in a(): %f\n",at);    }    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++;    }    master()->set_inhibit_compile_errors(0);    break;       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();       a=b=0;    if(t) trace(t);    _dmalloc_set_name(fname,1);    if(functionp(o->a))    {    // trace(10);
pike.git/bin/test_pike.pike:619:    bt = gauge { b=o->b(); };    }       _dmalloc_set_name();       if(t) trace(0);    if(check > 1) _verify_internals();       }) {    // 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));    }    if (objectp(err)) {    werror("Error: " + master()->describe_backtrace(err));    }    errors++;    break;    }       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);    if(computed_line)    werror("Actual lines: %d\n",computed_line);    errors++;    }       if(verbose>2)    werror("Time in a(): %f, Time in b(): %O\n",at,bt);       switch(type)    {    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++;    }    else {    successes++;    }    break;       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++;    }    else {    successes++;    }    break;       case "RUN":    successes++;    break;       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++;    }    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    werror("Did %d tests in %s.\n", a[0], fname);    }    break;       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));    errors++;    }    else {    successes++;    }    break;       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));    errors++;    }    else {    successes++;    }    break;       default:    werror(sprintf("\n%s: Unknown test type (%O).\n", fname, type));    errors++;    }    }    -  +  if (errors > prev_errors) werror ("\n"); +     if(check > 2) _verify_internals();       if(fail && errors)    exit(1);       if(successes+errors > end)    {    break testloop;    }       a=b=0;    }       if(istty())    { -  werror(" \r"); +  werror(" \r");    }    else if(quiet) {    if(!qskipp && !qmadep);    else if(!qskipp) werror("Made all tests\n");    else if(!qmadep) werror("Skipped all tests\n");    else if(qmade) werror(" Made %d test%s.\n", qmade, qmade==1?"":"s");    else if(qskipped) werror(" Skipped %d test%s.\n", qskipped, qskipped==1?"":"s");    }    else {    werror("\n");