From 3e4ac217aab55243d9096d19d611bfd368a4aa9b Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 18 Nov 2022 17:53:54 +0000 Subject: Bring back the common facilities of the tcltests "package", but use a less fragile method to gain access to them. --- tests/chanio.test | 1 + tests/env.test | 2 ++ tests/exec.test | 4 +--- tests/fileSystemEncoding.test | 15 +-------------- tests/io.test | 1 + tests/ioCmd.test | 1 + tests/platform.test | 1 + tests/tcltests.tcl | 3 +++ tests/thread.test | 2 +- 9 files changed, 12 insertions(+), 18 deletions(-) diff --git a/tests/chanio.test b/tests/chanio.test index 0f45819..1c689fb 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -34,6 +34,7 @@ namespace eval ::tcl::test::io { package require -exact Tcltest [info patchlevel] set ::tcltestlib [lindex [package ifneeded Tcltest [info patchlevel]] 1] } + source [file join [file dirname [info script]] tcltests.tcl] testConstraint testbytestring [llength [info commands testbytestring]] testConstraint testchannel [llength [info commands testchannel]] diff --git a/tests/env.test b/tests/env.test index 6c46532..bc1d7e9 100644 --- a/tests/env.test +++ b/tests/env.test @@ -16,6 +16,8 @@ if {"::tcltest" ni [namespace children]} { namespace import -force ::tcltest::* } +source [file join [file dirname [info script]] tcltests.tcl] + # [exec] is required here to see the actual environment received by child # processes. proc getenv {} { diff --git a/tests/exec.test b/tests/exec.test index 4cc4a05..3c445e8 100644 --- a/tests/exec.test +++ b/tests/exec.test @@ -18,10 +18,8 @@ if {"::tcltest" ni [namespace children]} { package require tcltest 2.5 namespace import -force ::tcltest::* } +source [file join [file dirname [info script]] tcltests.tcl] -# All tests require the "exec" command. -# Skip them if exec is not defined. -testConstraint exec [llength [info commands exec]] # Some skips when running in a macOS CI environment testConstraint noosxCI [expr {![info exists ::env(MAC_CI)]}] diff --git a/tests/fileSystemEncoding.test b/tests/fileSystemEncoding.test index 6561bef..24003b8 100644 --- a/tests/fileSystemEncoding.test +++ b/tests/fileSystemEncoding.test @@ -15,20 +15,7 @@ namespace eval ::tcl::test::fileSystemEncoding { variable fname1 \u767b\u9e1b\u9d72\u6a13 - proc autopath {} { - global auto_path - set scriptpath [info script] - set scriptpathnorm [file dirname [file normalize $scriptpath/...]] - set dirnorm [file dirname $scriptpathnorm] - set idx [lsearch -exact $auto_path $dirnorm] - if {$idx >= 0} { - set auto_path [lreplace $auto_path[set auto_path {}] $idx $idx {}] - } - set auto_path [linsert $auto_path[set auto_path {}] 0 0 $dirnorm] - } - autopath - - package require tcltests + source [file join [file dirname [info script]] tcltests.tcl] test filesystemEncoding-1.0 { issue bcd100410465 diff --git a/tests/io.test b/tests/io.test index cd4c954..ca7bd0c 100644 --- a/tests/io.test +++ b/tests/io.test @@ -34,6 +34,7 @@ namespace eval ::tcl::test::io { package require -exact Tcltest [info patchlevel] set ::tcltestlib [lindex [package ifneeded Tcltest [info patchlevel]] 1] } + source [file join [file dirname [info script]] tcltests.tcl] testConstraint testbytestring [llength [info commands testbytestring]] testConstraint testchannel [llength [info commands testchannel]] diff --git a/tests/ioCmd.test b/tests/ioCmd.test index 99bb464..d17dce3 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -17,6 +17,7 @@ if {"::tcltest" ni [namespace children]} { package require tcltest 2.5 namespace import -force ::tcltest::* } +source [file join [file dirname [info script]] tcltests.tcl] ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] diff --git a/tests/platform.test b/tests/platform.test index 6b775cf..faab6d9 100644 --- a/tests/platform.test +++ b/tests/platform.test @@ -10,6 +10,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. package require tcltest 2.5 +source [file join [file dirname [info script]] tcltests.tcl] namespace eval ::tcl::test::platform { namespace import ::tcltest::testConstraint diff --git a/tests/tcltests.tcl b/tests/tcltests.tcl index 58e6bfb..1a473e9 100644 --- a/tests/tcltests.tcl +++ b/tests/tcltests.tcl @@ -1,5 +1,8 @@ #! /usr/bin/env tclsh +# Don't overwrite tcltests facilities already present +if {[package provide tcltests] ne {}} return + package require tcltest 2.5 namespace import ::tcltest::* diff --git a/tests/thread.test b/tests/thread.test index 28934a2..92f3a06 100644 --- a/tests/thread.test +++ b/tests/thread.test @@ -16,7 +16,7 @@ # be fully finalized, which avoids valgrind "still reachable" reports. package require tcltest 2.5 -namespace import ::tcltest::* +source [file join [file dirname [info script]] tcltests.tcl] ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] -- cgit v0.12