aboutsummaryrefslogtreecommitdiff
path: root/tcltest.tcl
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-11-08 09:31:26 +1000
committerSteve Bennett <steveb@workware.net.au>2020-11-08 10:17:57 +1000
commit4b865fed1ad29c97c1b21757d953886758b22796 (patch)
tree809c9f5f10713cc01d42e45f0269c53559948b5b /tcltest.tcl
parent8e1a22bac49a3acb1ee757ca34ed16b27bb7cd17 (diff)
downloadjimtcl-4b865fed1ad29c97c1b21757d953886758b22796.zip
jimtcl-4b865fed1ad29c97c1b21757d953886758b22796.tar.gz
jimtcl-4b865fed1ad29c97c1b21757d953886758b22796.tar.bz2
build: Fix build and tests for out-of-tree build
Loadable modules and tests Fixes #179 Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tcltest.tcl')
-rw-r--r--tcltest.tcl24
1 files changed, 20 insertions, 4 deletions
diff --git a/tcltest.tcl b/tcltest.tcl
index 3e14844..f93a35b 100644
--- a/tcltest.tcl
+++ b/tcltest.tcl
@@ -10,6 +10,7 @@ set testinfo(numskip) 0
set testinfo(numtests) 0
set testinfo(reported) 0
set testinfo(failed) {}
+set testinfo(source) [file tail $::argv0]
# -verbose or $testverbose show OK/ERR of individual tests
if {[lsearch $argv "-verbose"] >= 0 || [info exists env(testverbose)]} {
@@ -68,7 +69,7 @@ proc testCmdConstraints {args} {
}
proc skiptest {{msg {}}} {
- puts [format "%16s: --- skipped$msg" $::argv0]
+ puts [format "%16s: --- skipped$msg" $::testinfo(source)]
exit 0
}
@@ -168,7 +169,7 @@ proc package-or-skip {name} {
if {[catch {
package require $name
}]} {
- puts [format "%16s: --- skipped" $::argv0]
+ puts [format "%16s: --- skipped" $::testinfo(source)]
exit 0
}
}
@@ -194,6 +195,21 @@ proc bytestring {x} {
return $x
}
+# Takes a stacktrace and applies [file tail] to the filenames.
+# This allows stacktrace tests to be run from a directory other than the source directory.
+proc basename-stacktrace {stacktrace} {
+ set result {}
+ foreach {p f l} $stacktrace {
+ lappend result $p [file tail $f] $l
+ }
+ return $result
+}
+
+# Takes a list of {filename line} and returns {basename line}
+proc basename-source {list} {
+ list [file tail [lindex $list 0]] [lindex $list 1]
+}
+
# Note: We don't support -output or -errorOutput yet
proc test {id descr args} {
set default [dict create -returnCodes {ok return} -match exact -result {} -constraints {} -body {} -setup {} -cleanup {}]
@@ -311,9 +327,9 @@ proc testreport {} {
incr ::testinfo(reported)
if {$::testinfo(verbose)} {
- puts -nonewline "\n$::argv0"
+ puts -nonewline "\n$::testinfo(source)"
} else {
- puts -nonewline [format "%16s" $::argv0]
+ puts -nonewline [format "%16s" $::testinfo(source)]
}
puts [format ": Total %5d Passed %5d Skipped %5d Failed %5d" \
$::testinfo(numtests) $::testinfo(numpass) $::testinfo(numskip) $::testinfo(numfail)]