aio tempname: Fix a crash when the template is invalid
[jimtcl.git] / tests / runall.tcl
blob2b1c15ac0776115f32e651919b59fdfbe2653ecf
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 if {$script eq "signal.test"} {
28 # special case, can't run this in a child interpeter
29 catch -exit {
30 source $script
32 foreach var {pass fail skip tests} {
33 incr total($var) $testinfo(num$var)
35 } else {
36 set i [interp]
38 foreach var {argv0 auto_path} {
39 $i eval [list set $var [set ::$var]]
42 # Run the test
43 catch -exit {$i eval source $script} msg opts
44 if {[info returncode $opts(-code)] eq "error"} {
45 puts [format "%16s: --- error ($msg)" $script]
46 incr total(fail)
49 # Extract the counts
50 foreach var {pass fail skip tests} {
51 incr total($var) [$i eval "set testinfo(num$var)"]
53 $i delete
56 stdout flush
58 puts [string repeat = 73]
59 puts [format "%16s: Total %5d Passed %5d Skipped %5d Failed %5d" \
60 Totals $total(tests) $total(pass) $total(skip) $total(fail)]
62 if {$total(fail)} {
63 exit 1