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.67 2002/05/27 12:04:54 jhs Exp $ */ + /* $Id: test_pike.pike,v 1.68 2002/07/29 17:19:24 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)   {    if(opt=="" || !opt) return 1;    return (int)opt;   }      int istty_cache;   int istty()   { - #ifdef __NT__ -  return 1; - #else +     if(!istty_cache)    { -  + #ifdef __NT__ +  istty_cache=1; + #else    istty_cache=!!Stdio.stdin->tcgetattr(); -  + #endif    if(!istty_cache)    {    istty_cache=-1;    }else{    switch(getenv("TERM"))    {    case "dumb":    case "emacs":    istty_cache=-1;    }    }    }    return istty_cache>0; - #endif +    }      mapping(string:int) cond_cache=([]);      #if constant(thread_create)   #define HAVE_DEBUG   #endif      void bzot(string test)   {
pike.git/bin/test_pike.pike:217:   #endif   }      //   // Main program   //      int main(int argc, array(string) argv)   {    int e, verbose, prompt, successes, errors, t, check; -  int skipped, quiet; +  int skipped;    array(string) tests;    program testprogram;    int start, fail, mem;    int loop=1;    int end=0x7fffffff;    string extra_info="";    int shift;      #if constant(signal) && constant(signum)    if(signum("SIGQUIT")>=0)
pike.git/bin/test_pike.pike:258:    array(string) testsuites=({});    args=args[..sizeof(args)-1-argc];    add_constant("RUNPIKE",Array.map(args,Process.sh_quote)*" ");       foreach(Getopt.find_all_options(argv,aggregate(    ({"no-watchdog",Getopt.NO_ARG,({"--no-watchdog"})}),    ({"watchdog",Getopt.HAS_ARG,({"--watchdog"})}),    ({"help",Getopt.NO_ARG,({"-h","--help"})}),    ({"verbose",Getopt.MAY_HAVE_ARG,({"-v","--verbose"})}),    ({"prompt",Getopt.NO_ARG,({"-p","--prompt"})}), -  ({"quiet",Getopt.NO_ARG,({"-q","--quiet"})}), +     ({"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"})}),    ({"mem",Getopt.NO_ARG,({"-m","--mem","--memory"})}),    ({"auto",Getopt.NO_ARG,({"-a","--auto"})}),    ({"notty",Getopt.NO_ARG,({"-T","--notty"})}),   #ifdef HAVE_DEBUG
pike.git/bin/test_pike.pike:294:    case "notty":    istty_cache=-1;    break;       case "help":    write(doc);    return 0;       case "verbose": verbose+=foo(opt[1]); break;    case "prompt": prompt+=foo(opt[1]); break; -  case "quiet": quiet=1; istty_cache=-1; break; +     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 "mem": mem=1; break;       case "auto":    testsuites=find_testsuites(".");
pike.git/bin/test_pike.pike:336: Inside #if defined(HAVE_DEBUG)
   destruct(o);    Tools.Hilfe.GenericHilfe(q,q);    }    }    },p);    }   #endif    }    }    +  add_constant("_verbose", verbose); +    #ifdef WATCHDOG    int watchdog_time=time();       if(use_watchdog)    {   #ifdef WATCHDOG_PIPE    object watchdog_tmp=Stdio.File();    watchdog_pipe=watchdog_tmp->pipe(Stdio.PROP_IPC);    watchdog=Process.create_process(    backtrace()[0][3] + ({ "--watchdog="+getpid() }),
pike.git/bin/test_pike.pike:422:    errors++;    tmp = -1;    }       if(!tmp) tmp=-1;    cond_cache[condition]=tmp;    }       if(tmp==-1)    { -  if(verbose) +  if(verbose>1)    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);
pike.git/bin/test_pike.pike:448:    }       string pad_on_error = "\n";    if(istty())    {    if(!verbose) {    werror("test %d, line %d\r", e+1, testline);    pad_on_error = " \r";    }    } -  else if(quiet){ +  else if(verbose){    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;    qmadep=1;
pike.git/bin/test_pike.pike:503:    }       if (prompt) {    if (Stdio.Readline()->    read(sprintf("About to run test: %d. [<RETURN>/'quit']: ",    testno)) == "quit") {    break testloop;    }    }    -  if(verbose) +  if(verbose>1)    {    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(verbose>2) bzot(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:632:       at = gauge {    err=catch {    clone(compile_string(to_compile, testsuite))->a();    };    };    if(err)    {    _dmalloc_set_name();    successes++; -  if(verbose>2) +  if(verbose>3)    werror("Time in a(): %f\n",at);    }    else {    _dmalloc_set_name();    werror(pad_on_error + fname + " failed (expected eval error).\n");    bzot(test);    errors++;    }    master()->set_inhibit_compile_errors(0);    break;
pike.git/bin/test_pike.pike:743:    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);    werror(sprintf("o->a(): %O\n",a));    errors++;    }    else {    successes += a[0];    errors += a[1]; -  if (verbose) +  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)    {
pike.git/bin/test_pike.pike:804:    break testloop;    }       a=b=0;    }       if(istty())    {    werror(" \r");    } -  else if(quiet) { +  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");    }    else {    werror("\n");    }    }
pike.git/bin/test_pike.pike:838:    foo+"s",    tmp["num_"+foo+"s"],    tmp[foo+"_bytes"]));    total+=tmp[foo+"_bytes"];    }    }    write( "%-10s: %6s %10d\n",    "Total", "", total );    }    } -  if(errors || verbose) +  if(errors || verbose>1)    {    werror("Failed tests: "+errors+".\n");    }       werror("Total tests: %d (%d tests skipped)\n",successes+errors,skipped);      #ifdef WATCHDOG_SIGNAL    if(use_watchdog)    {    watchdog->kill(signum("SIGKILL"));
pike.git/bin/test_pike.pike:878:   Usage: test_pike [args] [testfiles]      --no-watchdog Watchdog will not be used.   --watchdog=pid Run only the watchdog and monitor the process with the given    pid.   -h, --help Prints this message.   -v[level],   --verbose[=level] Select the level of verbosity. Every verbose level includes    the printouts from the levels below.    0 No extra printouts. -  1 Some extra information about test that will or won't be +  1 Some additional information printed out after every +  finished block of tests. +  2 Some extra information about test that will or won't be    run. -  2 Every test is printed out. -  3 Time spent in individual tests are printed out. +  3 Every test is printed out. +  4 Time spent in individual tests are printed out.    10 The actual pike code compiled, including wrappers, is    printed.   -p, --prompt The user will be asked before every test is run. - -q, --quiet Less outputs than normal. +    -sX, --start-test=X Where in the testsuite testing should start, e.g. ignores X    tests in every testsuite.   -eX, --end-after=X How many tests should be run.   -f, --fail If set, the testsuite always fails.   -lX, --loop=X The number of times the testsuite should be run. Default is    1.   -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.   -T, --notty Format output for non-tty.   -d, --debug Opens a debug port.   ";