Branch: Tag:

2003-06-26

2003-06-26 17:36:16 by Martin Nilsson <mani@lysator.liu.se>

Added option to specify directories to search. Renamed bzot. Removed Stdio import.

Rev: bin/test_pike.pike:1.87

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
26:   #define HAVE_DEBUG   #endif    - void bzot(string test) + void print_code(string test)   {    array lines = test/"\n";    foreach(lines; int r; string line) {
55:    foreach(s, string file)    {    string name=combine_path(dir||"",file); -  if(file_size(name)==-2) +  if(Stdio.is_dir(name))    ret+=find_testsuites(name);    }    }
63:   }      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());
253:    ({"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"})}),
291:    case "mem": mem=1; break;       case "auto": +  if(stringp(opt[1])) +  testsuites=find_testsuites(opt[1]); +  else    testsuites=find_testsuites(".");    break;   
448:    }       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);
514:    {    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();
565:       // _optimizer_debug(5);    -  if(verbose>9) bzot(to_compile); +  if(verbose>9) print_code(to_compile);    switch(type)    {    mixed at,bt;
576:    {    _dmalloc_set_name();    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(test);    errors++;    }    else {
596:    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);
610:    {    _dmalloc_set_name();    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(test);    errors++;    }    else {
619:    successes++;    else {    werror(pad_on_error + fname + " failed (expected compile warning).\n"); -  bzot(test); +  print_code(test);    errors++;    }    }
646:    _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);
683:    }) {    // 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));    }
698:    ( 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)
715:    if(a)    {    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(test);    werror(sprintf("o->a(): %O\n",a));    errors++;    }
728:    if(!a)    {    werror(pad_on_error + fname + " failed.\n"); -  bzot(test); +  print_code(test);    werror(sprintf("o->a(): %O\n",a));    errors++;    }
744:    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++;    }
763:    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++;
787:    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++;
828:    a=b=0;    }    -  if(maybe_tty && Terminfo.is_tty()) +  if(maybe_tty && Stdio.Terminfo.is_tty())    {    werror(" \r");    }
945:    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.   ";