Trim bootstrap jimsh
[jimtcl.git] / tests / runall.tcl
blob5b5d2208742fa80cbf3e96227b898e4b87093c0d
1 # Run all tests in the current directory
2 #
3 # Tests are run in a sub-interpreter (if possible) to avoid
4 # interactions between tests.
6 lappend auto_path .
8 # In case interp is a module
9 catch {package require interp}
11 if {[info commands interp] eq ""} {
12 set rc 1
13 foreach script [lsort [glob *.test]] {
14 if {[catch {
15 exec [info nameofexecutable] $script >@stdout 2>@stderr
16 set rc 0
17 } msg opts]} {
18 puts "Failed: $script"
21 exit $rc
22 } else {
23 array set total {pass 0 fail 0 skip 0 tests 0}
24 foreach script [lsort [glob *.test]] {
25 set ::argv0 $script
27 set i [interp]
29 foreach var {argv0 auto_path} {
30 $i eval [list set $var [set ::$var]]
33 # Run the test
34 catch -exit {$i eval source $script} msg opts
35 if {[info returncode $opts(-code)] eq "error"} {
36 puts [format "%16s: --- error ($msg)" $script]
37 incr total(fail)
40 # Extract the counts
41 foreach var {pass fail skip tests} {
42 incr total($var) [$i eval "set testinfo(num$var)"]
45 $i delete
46 stdout flush
48 puts [string repeat = 73]
49 puts [format "%16s: Total %5d Passed %5d Skipped %5d Failed %5d" \
50 Totals $total(tests) $total(pass) $total(skip) $total(fail)]
52 if {$total(fail)} {
53 exit 1