pike.git / bin / test_pike.pike

version» Context lines:

pike.git/bin/test_pike.pike:1:   #! /usr/bin/env pike    - /* $Id: test_pike.pike,v 1.86 2003/06/05 12:57:59 grubba Exp $ */ + /* $Id: test_pike.pike,v 1.87 2003/06/26 17:36:16 nilsson Exp $ */    - import Stdio; -  +    #if !constant(_verify_internals)   #define _verify_internals()   #endif      #if !constant(_dmalloc_set_name)   void _dmalloc_set_name(mixed ... args) {}   #endif      int foo(string opt)   {
pike.git/bin/test_pike.pike:19:   }      int maybe_tty = 1;      mapping(string:int) cond_cache=([]);      #if constant(thread_create)   #define HAVE_DEBUG   #endif    - void bzot(string test) + void print_code(string test)   {    array lines = test/"\n";    foreach(lines; int r; string line) {    line = sprintf("%O",line);    werror("%3d: %s\n", r+1, line[1..sizeof(line)-2]);    }    werror("\n");    return;   }   
pike.git/bin/test_pike.pike:48:    {    case "testsuite":    case "module_testsuite":    ret+=({ combine_path(dir||"",file) });    }    }       foreach(s, string file)    {    string name=combine_path(dir||"",file); -  if(file_size(name)==-2) +  if(Stdio.is_dir(name))    ret+=find_testsuites(name);    }    }    return ret;   }      array(string) read_tests( string fn ) { -  string|array(string) tests = read_bytes( fn ); +  string|array(string) tests = Stdio.read_file( fn );    if(!tests) {    werror("Failed to read test file %O, errno=%d.\n",    fn, errno());    exit(1);    }       tests = tests/"\n....\n";    return tests[0..sizeof(tests)-2];   }   
pike.git/bin/test_pike.pike:246:    ({"start",Getopt.HAS_ARG,({"-s","--start-test"})}),    ({"end",Getopt.HAS_ARG,({"-e","--end-after"})}),    ({"fail",Getopt.NO_ARG,({"-f","--fail"})}),    ({"loop",Getopt.HAS_ARG,({"-l","--loop"})}),    ({"trace",Getopt.HAS_ARG,({"-t","--trace"})}),    ({"check",Getopt.MAY_HAVE_ARG,({"-c","--check"})}),   #if constant(_assembler_debug)    ({"asm",Getopt.MAY_HAVE_ARG,({"--assembler-debug"})}),   #endif    ({"mem",Getopt.NO_ARG,({"-m","--mem","--memory"})}), -  ({"auto",Getopt.NO_ARG,({"-a","--auto"})}), +  ({"auto",Getopt.MAY_HAVE_ARG,({"-a","--auto"})}),    ({"notty",Getopt.NO_ARG,({"-T","--notty"})}),   #ifdef HAVE_DEBUG    ({"debug",Getopt.MAY_HAVE_ARG,({"-d","--debug"})}),   #endif    ({"regression",Getopt.NO_ARG,({"-r","--regression"})}),    )),array opt)    {    switch(opt[0])    {    case "no-watchdog":
pike.git/bin/test_pike.pike:284:    case "start": start=foo(opt[1]); start--; break;    case "end": end=foo(opt[1]); break;    case "fail": fail=1; break;    case "loop": loop=foo(opt[1]); break;    case "trace": t+=foo(opt[1]); break;    case "check": check+=foo(opt[1]); break;    case "asm": asmdebug+=foo(opt[1]); break;    case "mem": mem=1; break;       case "auto": +  if(stringp(opt[1])) +  testsuites=find_testsuites(opt[1]); +  else    testsuites=find_testsuites(".");    break;       case "regression":    add_constant("regression", 1);    break;      #ifdef HAVE_DEBUG    case "debug":    {
pike.git/bin/test_pike.pike:441:    string testfile;    sscanf(type, "%s: test %d, expected result: %s", testfile, testno, type);       if (testfile) {    array split = testfile / ":";    testline = (int) split[-1];    testfile = split[..sizeof (split) - 2] * ":";    }       string pad_on_error = "\n"; -  if(maybe_tty && Terminfo.is_tty()) +  if(maybe_tty && Stdio.Terminfo.is_tty())    {    if(verbose<2) {    werror("test %d, line %d\r", e+1, testline);    pad_on_error = " \r";    }    }    else if(verbose){    if(skip) {    if(qmade) werror(" Made %d test%s.\n", qmade, qmade==1?"":"s");    qmade=0;
pike.git/bin/test_pike.pike:507:    read(sprintf("About to run test: %d. [<RETURN>/'quit']: ",    testno)) == "quit") {    break testloop;    }    }       if(verbose>1)    {    werror("Doing test %d (%d total) at %s:%d%s\n",    testno, successes+errors+1, testfile, testline, extra_info); -  if(verbose>2) bzot(test); +  if(verbose>2) print_code(test);    }       if(check > 1) _verify_internals();       shift++;    string fname = testfile + ":" + testline + ": Test " + testno +    " (shift " + (shift%3) + ")";       string widener = ([ 0:"",    1:"\nint \x30c6\x30b9\x30c8=0;\n",
pike.git/bin/test_pike.pike:558:    }       if((shift/3)&1)    {    fname+=" (CRNL)";    to_compile=replace(to_compile,"\n","\r\n");    }       // _optimizer_debug(5);    -  if(verbose>9) bzot(to_compile); +  if(verbose>9) print_code(to_compile);    switch(type)    {    mixed at,bt;    mixed err;    case "COMPILE":    _dmalloc_set_name(fname,0);    if(catch(compile_string(to_compile, testsuite)))    {    _dmalloc_set_name();    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(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, testsuite)))    {    _dmalloc_set_name();    successes++;    }    else {    _dmalloc_set_name();    werror(pad_on_error + fname + " failed (expected compile error).\n"); -  bzot(test); +  print_code(test);    errors++;    }    master()->set_inhibit_compile_errors(0);    break;       case "COMPILE_WARNING":    WarningFlag wf = WarningFlag();    master()->set_inhibit_compile_errors(wf);    _dmalloc_set_name(fname,0);    if(catch(compile_string(to_compile, testsuite)))    {    _dmalloc_set_name();    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(test);    errors++;    }    else {    _dmalloc_set_name();    if( wf->warning )    successes++;    else {    werror(pad_on_error + fname + " failed (expected compile warning).\n"); -  bzot(test); +  print_code(test);    errors++;    }    }    master()->set_inhibit_compile_errors(0);    break;       case "EVAL_ERROR":    master()->set_inhibit_compile_errors(1);    _dmalloc_set_name(fname,0);   
pike.git/bin/test_pike.pike:639:    {    _dmalloc_set_name();    successes++;    if(verbose>3)    werror("Time in a(): %f\n",at);    }    else {    _dmalloc_set_name();    werror(pad_on_error + fname + " failed (expected eval error).\n");    werror("Got %O\n", a); -  bzot(test); +  print_code(test);    errors++;    }    master()->set_inhibit_compile_errors(0);    break;       default:    if (err = catch{    _dmalloc_set_name(fname,0);    o=compile_string(to_compile,testsuite)();    _dmalloc_set_name();
pike.git/bin/test_pike.pike:676:    }       _dmalloc_set_name();       if(t) trace(0);    if(check > 1) _verify_internals();       }) {    // trace(0);    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(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(pad_on_error + fname + " Line numbering failed.\n"); -  bzot(test + linetester); +  print_code(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(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(test);    werror(sprintf("o->a(): %O\n",a));    errors++;    }    else {    successes++;    }    break;       case "TRUE":    if(!a)    {    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(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(pad_on_error + fname + " failed to return proper results.\n"); -  bzot(test); +  print_code(test);    werror(sprintf("o->a(): %O\n",a));    errors++;    }    else {    successes += a[0];    errors += a[1];    if (verbose>1)    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(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(test);    werror(sprintf("o->a(): %O\n",a));    werror(sprintf("o->b(): %O\n",b));    errors++;    if (stringp(a) && stringp(b) && (sizeof(a) == sizeof(b)) &&    (sizeof(a) > 20)) {    werror("Differences at:\n");    int i;    for(i = 0; i < sizeof(a); i++) {    if (a[i] != b[i]) {    werror(" %4d: 0x%04x != 0x%04x\n", i, a[i], b[i]);
pike.git/bin/test_pike.pike:780:    }    else {    successes++;    }    break;       case "EQUAL":    if(!equal(a,b))    {    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(test);    werror(sprintf("o->a(): %O\n",a));    werror(sprintf("o->b(): %O\n",b));    errors++;    if (stringp(a) && stringp(b) && (sizeof(a) == sizeof(b)) &&    (sizeof(a) > 20)) {    werror("Differences at:\n");    int i;    for(i = 0; i < sizeof(a); i++) {    if (a[i] != b[i]) {    werror(" %4d: 0x%04x != 0x%04x\n", i, a[i], b[i]);
pike.git/bin/test_pike.pike:821:    exit(1);       if(successes+errors > end)    {    break testloop;    }       a=b=0;    }    -  if(maybe_tty && Terminfo.is_tty()) +  if(maybe_tty && Stdio.Terminfo.is_tty())    {    werror(" \r");    }    else if(verbose) {    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");    }
pike.git/bin/test_pike.pike:938:   -tX, --trace=X Run tests with trace level X.   -c[X], --check[=X] The level of extra Pike consistency checks performed.    1 _verify_internals is run before every test.    2 _verify_internals is run after every compilation.    3 _verify_internals is run after every test.    4 An extra gc and _verify_internals is run before    every test.    X<0 For values below zero, _verify_internals will be run    before every n:th test, where n=abs(X).   -m, --mem, --memory Print out memory allocations after the tests. - -a, --auto Let the test program find the testsuits self. + -a, --auto[=dir] Let the test program find the testsuits self.   -T, --notty Format output for non-tty.   -d, --debug Opens a debug port.   ";