diff options
Diffstat (limited to 'tests/env.test')
-rw-r--r-- | tests/env.test | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/tests/env.test b/tests/env.test index a4669d2..47ada47 100644 --- a/tests/env.test +++ b/tests/env.test @@ -11,8 +11,14 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -package require tcltest 2 -namespace import -force ::tcltest::* +if {[lsearch [namespace children] ::tcltest] == -1} { + package require tcltest 2 + namespace import -force ::tcltest::* +} + +# Some tests require the "exec" command. +# Skip them if exec is not defined. +testConstraint exec [llength [info commands exec]] # # These tests will run on any platform (and indeed crashed @@ -51,15 +57,10 @@ test env-1.3 {reflection of env by "array names"} { expr {$ix >= 0} } {1} - -# Some tests require the "exec" command. -# Skip them if exec is not defined. -testConstraint exec [llength [info commands exec]] - set printenvScript [makeFile { proc lrem {listname name} { upvar $listname list - set i [lsearch $list $name] + set i [lsearch -nocase $list $name] if {$i >= 0} { set list [lreplace $list $i $i] } @@ -77,7 +78,7 @@ set printenvScript [makeFile { TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH PURE_PROG_NAME DISPLAY SHLIB_PATH SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING - __CF_USER_TEXT_ENCODING SECURITYSESSIONID + __CF_USER_TEXT_ENCODING SECURITYSESSIONID LANG WINDIR TERM } { lrem names $name } @@ -101,20 +102,17 @@ proc getenv {} { # Save the current environment variables at the start of the test. foreach name [array names env] { - set env2([string toupper $name]) $env($name) - unset env($name) -} + set env2($name) $env($name) -# Added the following lines so that child tcltest can actually find its -# library if the initial tcltest is run from a non-standard place. -# ('saved' env vars) -foreach name { - TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH DISPLAY SHLIB_PATH - SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH - DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING - SECURITYSESSIONID} { - if {[info exists env2($name)]} { - set env($name) $env2($name); + # Keep some environment variables that support operation of the + # tcltest package. + if {[string toupper $name] ni { + TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH DISPLAY SHLIB_PATH + SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH + DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING + SECURITYSESSIONID LANG WINDIR TERM + }} { + unset env($name) } } @@ -233,7 +231,7 @@ test env-5.4 {corner cases - unset the env array} {} { interp delete i set result } {1 a 1} -test env-5.5 {corner cases - cannot have null entries on Windows} {pcOnly} { +test env-5.5 {corner cases - cannot have null entries on Windows} {win} { set env() a catch {set env()} } {1} |