From a15ea81906fdac4ed3868e9866d07a8ca4c2354c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 20 Jul 2020 07:33:42 +0000 Subject: Backport changes in tcltest package from higher Tcl versions. Rename (internal, undocumented) tcltest::loadIntoSlaveInterpreter into tcltest::loadIntoChildInterpreter tcltest 2.5.1 -> 2.5.3 --- library/tcltest/pkgIndex.tcl | 2 +- library/tcltest/tcltest.tcl | 35 +++++++++++++++++++++++------------ tests/init.test | 10 +++++----- tests/pkg.test | 4 ++-- unix/Makefile.in | 4 ++-- win/Makefile.in | 4 ++-- 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/library/tcltest/pkgIndex.tcl b/library/tcltest/pkgIndex.tcl index ca93725..a56a0d6 100644 --- a/library/tcltest/pkgIndex.tcl +++ b/library/tcltest/pkgIndex.tcl @@ -9,4 +9,4 @@ # full path name of this file's directory. if {![package vsatisfies [package provide Tcl] 8.5-]} {return} -package ifneeded tcltest 2.5.1 [list source [file join $dir tcltest.tcl]] +package ifneeded tcltest 2.5.3 [list source [file join $dir tcltest.tcl]] diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 1394949..c894ff1 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -22,7 +22,7 @@ namespace eval tcltest { # When the version number changes, be sure to update the pkgIndex.tcl file, # and the install directory in the Makefiles. When the minor version # changes (new feature) be sure to update the man page as well. - variable Version 2.5.1 + variable Version 2.5.3 # Compatibility support for dumb variables defined in tcltest 1 # Do not use these. Call [package provide Tcl] and [info patchlevel] @@ -811,14 +811,14 @@ namespace eval tcltest { trace add variable Option(-errfile) write \ [namespace code {errorChannel $Option(-errfile) ;#}] - proc loadIntoSlaveInterpreter {slave args} { + proc loadIntoChildInterpreter {child args} { variable Version - interp eval $slave [package ifneeded tcltest $Version] - interp eval $slave "tcltest::configure {*}{$args}" - interp alias $slave ::tcltest::ReportToMaster \ - {} ::tcltest::ReportedFromSlave + interp eval $child [package ifneeded tcltest $Version] + interp eval $child "tcltest::configure {*}{$args}" + interp alias $child ::tcltest::ReportToParent \ + {} ::tcltest::ReportedFromChild } - proc ReportedFromSlave {total passed skipped failed because newfiles} { + proc ReportedFromChild {total passed skipped failed because newfiles} { variable numTests variable skippedBecause variable createdNewFiles @@ -1982,7 +1982,10 @@ proc tcltest::test {name description args} { } } - # First, run the setup script + # First, run the setup script (or a hook if it presents): + if {[set cmd [namespace which -command [namespace current]::SetupTest]] ne ""} { + set setup [list $cmd $setup] + } set processTest 1 set code [catch {uplevel 1 $setup} setupMsg] if {$code == 1} { @@ -2077,7 +2080,10 @@ proc tcltest::test {name description args} { set scriptFailure 1 } - # Always run the cleanup script + # Always run the cleanup script (or a hook if it presents): + if {[set cmd [namespace which -command [namespace current]::CleanupTest]] ne ""} { + set cleanup [list $cmd $cleanup] + } set code [catch {uplevel 1 $cleanup} cleanupMsg] if {$code == 1} { set errorInfo(cleanup) $::errorInfo @@ -2390,6 +2396,10 @@ proc tcltest::RunTest {name script} { memory tag $name } + # run the test script (or a hook if it presents): + if {[set cmd [namespace which -command [namespace current]::EvalTest]] ne ""} { + set script [list $cmd $script] + } set code [catch {uplevel 1 $script} actualAnswer] return [list $actualAnswer $code] @@ -2452,8 +2462,8 @@ proc tcltest::cleanupTests {{calledFromAllFile 0}} { set testFileName [file tail [info script]] # Hook to handle reporting to a parent interpreter - if {[llength [info commands [namespace current]::ReportToMaster]]} { - ReportToMaster $numTests(Total) $numTests(Passed) $numTests(Skipped) \ + if {[llength [info commands [namespace current]::ReportToParent]]} { + ReportToParent $numTests(Total) $numTests(Passed) $numTests(Skipped) \ $numTests(Failed) [array get skippedBecause] \ [array get createdNewFiles] set testSingleFile false @@ -3097,11 +3107,12 @@ proc tcltest::removeFile {name {directory ""}} { set fullName [file join $directory $name] DebugPuts 3 "[lindex [info level 0] 0]: removing $fullName" set idx [lsearch -exact $filesMade $fullName] - set filesMade [lreplace $filesMade $idx $idx] if {$idx == -1} { DebugDo 1 { Warn "removeFile removing \"$fullName\":\n not created by makeFile" } + } else { + set filesMade [lreplace $filesMade $idx $idx] } if {![file isfile $fullName]} { DebugDo 1 { diff --git a/tests/init.test b/tests/init.test index d56c72d..9c81694 100644 --- a/tests/init.test +++ b/tests/init.test @@ -19,16 +19,16 @@ if {[lsearch [namespace children] ::tcltest] == -1} { catch {namespace delete {*}[namespace children :: test_ns_*]} test init-0.1 {no error on initialization phase (init.tcl)} -setup { - interp create slave + interp create child } -body { - slave eval { + child eval { list [set v [info exists ::errorInfo]] \ [if {$v} {set ::errorInfo}] \ [set v [info exists ::errorCode]] \ [if {$v} {set ::errorCode}] } } -cleanup { - interp delete slave + interp delete child } -result {0 {} 0 {}} # Six cases - white box testing @@ -68,11 +68,11 @@ test init-1.8 {auto_qualify - multiple colons 2} { } foo -# we use a sub interp and auto_reset and double the tests because there is 2 +# we use a child interp and auto_reset and double the tests because there is 2 # places where auto_loading occur (before loading the indexes files and after) set testInterp [interp create] -tcltest::loadIntoSlaveInterpreter $testInterp {*}$argv +tcltest::loadIntoChildInterpreter $testInterp {*}$argv interp eval $testInterp { namespace import -force ::tcltest::* auto_reset diff --git a/tests/pkg.test b/tests/pkg.test index 10b4732..21f898c 100644 --- a/tests/pkg.test +++ b/tests/pkg.test @@ -16,10 +16,10 @@ if {[lsearch [namespace children] ::tcltest] == -1} { namespace import -force ::tcltest::* } -# Do all this in a slave interp to avoid garbaging the +# Do all this in a child interp to avoid garbaging the # package list set i [interp create] -tcltest::loadIntoSlaveInterpreter $i {*}$argv +tcltest::loadIntoChildInterpreter $i {*}$argv interp eval $i { namespace import -force ::tcltest::* diff --git a/unix/Makefile.in b/unix/Makefile.in index c20ba57..fd44f4e 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -788,8 +788,8 @@ install-libraries: libraries $(INSTALL_TZDATA) install-msgs done; @echo "Installing package msgcat 1.5.2 as a Tcl Module"; @$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.5.2.tm; - @echo "Installing package tcltest 2.5.1 as a Tcl Module"; - @$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.5.1.tm; + @echo "Installing package tcltest 2.5.3 as a Tcl Module"; + @$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.5.3.tm; @echo "Installing package platform 1.0.14 as a Tcl Module"; @$(INSTALL_DATA) $(TOP_DIR)/library/platform/platform.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/platform-1.0.14.tm; diff --git a/win/Makefile.in b/win/Makefile.in index 63f4c15..25a919a 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -671,8 +671,8 @@ install-libraries: libraries install-tzdata install-msgs done; @echo "Installing package msgcat 1.5.2 as a Tcl Module"; @$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/msgcat-1.5.2.tm; - @echo "Installing package tcltest 2.5.1 as a Tcl Module"; - @$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/tcltest-2.5.1.tm; + @echo "Installing package tcltest 2.5.3 as a Tcl Module"; + @$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/tcltest-2.5.3.tm; @echo "Installing package platform 1.0.14 as a Tcl Module"; @$(COPY) $(ROOT_DIR)/library/platform/platform.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.4/platform-1.0.14.tm; @echo "Installing package platform::shell 1.1.4 as a Tcl Module"; -- cgit v0.12