diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-06-08 10:36:14 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2016-08-26 14:31:55 +1000 |
commit | 040b3e203807dffc429e1f0f4bbb2af8c2d4f7b3 (patch) | |
tree | 8c51d8051d3453faf86f4ca240745734e8a65247 /tests | |
parent | 19834c06937b342995de4186cc9733fdc958a463 (diff) | |
download | jimtcl-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')
-rw-r--r-- | tests/Makefile | 6 | ||||
-rw-r--r-- | tests/alias.test | 1 | ||||
-rw-r--r-- | tests/runall.tcl | 52 |
3 files changed, 58 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile index 5e59617..979d081 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,11 @@ jimsh ?= ../jimsh +tclsh ?= tclsh test: - @rc=0; for i in *.test; do LD_LIBRARY_PATH=..:$(LD_LIBRARY_PATH) $(jimsh) $$i || rc=$$?; done; exit $$rc + @LD_LIBRARY_PATH=..:$(LD_LIBRARY_PATH) $(jimsh) runall.tcl + +tcl: + @rc=0; for i in *.test; do LD_LIBRARY_PATH=..:$(LD_LIBRARY_PATH) $(tclsh) -encoding utf-8 $$i || rc=$?; done; exit $$rc clean: rm -f gorp.file2 gorp.file sleepx test1 exec.tmp1 diff --git a/tests/alias.test b/tests/alias.test index b1774fd..c539920 100644 --- a/tests/alias.test +++ b/tests/alias.test @@ -62,6 +62,7 @@ test curry-1.4 "Two word curry" { list [$two x] [$two y] } {1 0} +collect test curry-1.5 "Delete curry" { unset one two collect 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 + } +} |