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 | |
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>
-rw-r--r-- | tcltest.tcl | 6 | ||||
-rw-r--r-- | tests/Makefile | 6 | ||||
-rw-r--r-- | tests/alias.test | 1 | ||||
-rw-r--r-- | tests/runall.tcl | 52 |
4 files changed, 64 insertions, 1 deletions
diff --git a/tcltest.tcl b/tcltest.tcl index ce3cbf3..1542d85 100644 --- a/tcltest.tcl +++ b/tcltest.tcl @@ -7,6 +7,7 @@ set testinfo(stoponerror) 0 set testinfo(numfail) 0 set testinfo(numskip) 0 set testinfo(numtests) 0 +set testinfo(reported) 0 set testinfo(failed) {} if {[lsearch $argv "-verbose"] >= 0 || [info exists env(testverbose)]} { @@ -251,6 +252,11 @@ proc ::tcltest::cleanupTests {} { } proc testreport {} { + if {$::testinfo(reported)} { + return + } + incr ::testinfo(reported) + if {$::testinfo(verbose)} { puts -nonewline "\n$::argv0" } else { 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 + } +} |