configure: Use pkg-config if possible
[jimtcl.git] / tests / runall.tcl
blob059f4d278deb8109e1d0b339df31a74792b65f66
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 if {[info commands interp] eq ""} {
9 set rc 0
10 foreach script [lsort [glob *.test]] {
11 if {[catch {
12 exec [info nameofexecutable] $script >@stdout 2>@stderr
13 set rc 1
14 } msg opts]} {
15 puts "Failed: $script"
18 exit $rc
19 } else {
20 array set total {pass 0 fail 0 skip 0 tests 0}
21 foreach script [lsort [glob *.test]] {
22 set ::argv0 $script
24 set i [interp]
26 foreach var {argv0 auto_path} {
27 $i eval [list set $var [set ::$var]]
30 # Run the test
31 catch -exit {$i eval source $script} msg opts
32 if {[info returncode $opts(-code)] eq "error"} {
33 puts [format "%16s: --- error ($msg)" $script]
34 incr total(fail)
37 # Extract the counts
38 foreach var {pass fail skip tests} {
39 incr total($var) [$i eval "set testinfo(num$var)"]
42 $i delete
43 stdout flush
45 puts [string repeat = 73]
46 puts [format "%16s: Total %5d Passed %5d Skipped %5d Failed %5d" \
47 Totals $total(tests) $total(pass) $total(skip) $total(fail)]
49 if {$total(fail)} {
50 exit 1