summaryrefslogtreecommitdiffstats
path: root/tests/env.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/env.test')
-rw-r--r--tests/env.test40
1 files changed, 17 insertions, 23 deletions
diff --git a/tests/env.test b/tests/env.test
index 6c3c137..c42e49d 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 on the Mac). So put
@@ -50,15 +56,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]
}
@@ -108,23 +109,18 @@ proc getenv {} {
# Save the current environment variables at the start of the test.
+set env2 [array get env]
foreach name [array names env] {
- set env2([string toupper $name]) $env($name)
- unset 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 {
+ # 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
CommonProgramFiles ProgramFiles
- } {
- if {[info exists env2($name)]} {
- set env($name) $env2($name);
+ }} {
+ unset env($name)
}
}
@@ -243,7 +239,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}
@@ -261,9 +257,7 @@ test env-6.1 {corner cases - add lots of env variables} {} {
foreach name [array names env] {
unset env($name)
}
-foreach name [array names env2] {
- set env($name) $env2($name)
-}
+array set env $env2
# cleanup
removeFile $printenvScript