aboutsummaryrefslogtreecommitdiff
path: root/tests/runall.tcl
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-06-08 10:36:14 +1000
committerSteve Bennett <steveb@workware.net.au>2016-08-26 14:31:55 +1000
commit040b3e203807dffc429e1f0f4bbb2af8c2d4f7b3 (patch)
tree8c51d8051d3453faf86f4ca240745734e8a65247 /tests/runall.tcl
parent19834c06937b342995de4186cc9733fdc958a463 (diff)
downloadjimtcl-040b3e203807dffc429e1f0f4bbb2af8c2d4f7b3.zip
jimtcl-040b3e203807dffc429e1f0f4bbb2af8c2d4f7b3.tar.gz
jimtcl-040b3e203807dffc429e1f0f4bbb2af8c2d4f7b3.tar.bz2
If possible, run tests within a sub-interpreter
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/runall.tcl')
-rw-r--r--tests/runall.tcl52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/runall.tcl b/tests/runall.tcl
new file mode 100644
index 0000000..059f4d2
--- /dev/null
+++ b/tests/runall.tcl
@@ -0,0 +1,52 @@
+# Run all tests in the current directory
+#
+# Tests are run in a sub-interpreter (if possible) to avoid
+# interactions between tests.
+
+lappend auto_path .
+
+if {[info commands interp] eq ""} {
+ set rc 0
+ foreach script [lsort [glob *.test]] {
+ if {[catch {
+ exec [info nameofexecutable] $script >@stdout 2>@stderr
+ set rc 1
+ } msg opts]} {
+ puts "Failed: $script"
+ }
+ }
+ exit $rc
+} else {
+ array set total {pass 0 fail 0 skip 0 tests 0}
+ foreach script [lsort [glob *.test]] {
+ set ::argv0 $script
+
+ set i [interp]
+
+ foreach var {argv0 auto_path} {
+ $i eval [list set $var [set ::$var]]
+ }
+
+ # Run the test
+ catch -exit {$i eval source $script} msg opts
+ if {[info returncode $opts(-code)] eq "error"} {
+ puts [format "%16s: --- error ($msg)" $script]
+ incr total(fail)
+ }
+
+ # Extract the counts
+ foreach var {pass fail skip tests} {
+ incr total($var) [$i eval "set testinfo(num$var)"]
+ }
+
+ $i delete
+ stdout flush
+ }
+ puts [string repeat = 73]
+ puts [format "%16s: Total %5d Passed %5d Skipped %5d Failed %5d" \
+ Totals $total(tests) $total(pass) $total(skip) $total(fail)]
+
+ if {$total(fail)} {
+ exit 1
+ }
+}