summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkjnash <k.j.nash@usa.net>2020-07-15 23:11:46 (GMT)
committerkjnash <k.j.nash@usa.net>2020-07-15 23:11:46 (GMT)
commit79214905a2153e60fdf993173f37afcc2b2e80d8 (patch)
treebbe53b765e8c1fd24b2520449531d4006cc51b9c
parent69fdd85b744c7f463d6731dff11db373df7e33f6 (diff)
downloadtcl-79214905a2153e60fdf993173f37afcc2b2e80d8.zip
tcl-79214905a2153e60fdf993173f37afcc2b2e80d8.tar.gz
tcl-79214905a2153e60fdf993173f37afcc2b2e80d8.tar.bz2
Bugfix tests/safe.test. Harden tests safe-9.20 to safe-9.24 against indeterminate order of glob matches. Audit use of glob and tcl::tm in modified tests for cases with multiple matches. Simplify test comparison patterns.
-rw-r--r--library/safe.tcl5
-rw-r--r--tests/safe.test307
2 files changed, 154 insertions, 158 deletions
diff --git a/library/safe.tcl b/library/safe.tcl
index 82a2780..74aee87 100644
--- a/library/safe.tcl
+++ b/library/safe.tcl
@@ -406,8 +406,9 @@ proc ::safe::InterpSetConfig {slave access_path staticsok nestedok deletehook} {
# 'platform::shell', which translate into
# 'platform/shell-X.tm', i.e arbitrarily deep
# subdirectories.
- lappend morepaths {*}[glob -nocomplain -directory $dir -type d *]
- foreach sub [glob -nocomplain -directory $dir -type d *] {
+ set next [glob -nocomplain -directory $dir -type d *]
+ lappend morepaths {*}$next
+ foreach sub $next {
lappend slave_tm_roots [file normalize $sub] [dict get $slave_tm_roots $dir]
set lenny [string length [dict get $slave_tm_roots $dir]]
set relpath [string range [file normalize $sub] $lenny+1 end]
diff --git a/tests/safe.test b/tests/safe.test
index c250400..69da9d2 100644
--- a/tests/safe.test
+++ b/tests/safe.test
@@ -25,8 +25,24 @@ set saveAutoPath $::auto_path
set ::auto_path [info library]
set TestsDir [file normalize [file dirname [info script]]]
+set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR]
-# Force actual loading of the safe package because we use un exported (and
+proc mapList {map listIn} {
+ set listOut {}
+ foreach element $listIn {
+ lappend listOut [string map $map $element]
+ }
+ return $listOut
+}
+proc mapAndSortList {map listIn} {
+ set listOut {}
+ foreach element $listIn {
+ lappend listOut [string map $map $element]
+ }
+ lsort $listOut
+}
+
+# Force actual loading of the safe package because we use un-exported (and
# thus un-autoindexed) APIs in this test result arguments:
catch {safe::interpConfigure}
@@ -340,30 +356,32 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup {
set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"]
# should add as p* (not p2 if master has a module path)
set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]]
+ set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
# an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level
# provided deep path)
- list $token1 $token2 $token3 \
- [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \
- [safe::interpConfigure $i]\
- [safe::interpDelete $i]
+ list $token1 $token2 $token3 -- \
+ [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \
+ $mappA -- [safe::interpDelete $i]
} -cleanup {
-} -match glob -result "{\$p(:0:)} {\$p(:*:)} {\$p(:*:)} 1\
- {can't find package SafeTestPackage1}\
- {-accessPath {[list $tcl_library */dummy/unixlike/test/path $TestsDir/auto0]}\
- -statics 0 -nested 1 -deleteHook {}} {}"
+} -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\
+ 1 {can't find package SafeTestPackage1} --\
+ {TCLLIB */dummy/unixlike/test/path TESTSDIR/auto0} -- {}}
test safe-7.2http {tests specific path and interpFind/AddToAccessPath, uses http1.0} -body {
set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
# should not add anything (p0)
set token1 [safe::interpAddToAccessPath $i [info library]]
# should add as p1
set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"]
+ set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
# an error shall occur (http is not anymore in the secure 0-level
# provided deep path)
- list $token1 $token2 \
- [catch {interp eval $i {package require http 1}} msg] $msg \
- [safe::interpConfigure $i]\
- [safe::interpDelete $i]
-} -match glob -result "{\$p(:0:)} {\$p(:*:)} 1 {can't find package http 1} {-accessPath {[list $tcl_library */dummy/unixlike/test/path]} -statics 0 -nested 1 -deleteHook {}} {}"
+ list $token1 $token2 -- \
+ [catch {interp eval $i {package require http 1}} msg] $msg -- \
+ $mappA -- [safe::interpDelete $i]
+} -match glob -result {{$p(:0:)} {$p(:*:)} -- 1 {can't find package http 1} --\
+ {TCLLIB */dummy/unixlike/test/path} -- {}}
test safe-7.3 {check that safe subinterpreters work} {
set g [interp slaves]
if {$g ne {}} {
@@ -384,29 +402,30 @@ test safe-7.4 {tests specific path and positive search} -setup {
set token1 [safe::interpAddToAccessPath $i [info library]]
# should add as p* (not p1 if master has a module path)
set token2 [safe::interpAddToAccessPath $i [file join $TestsDir auto0 auto1]]
+ set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
# this time, unlike test safe-7.2, SafeTestPackage1 should be found
- list $token1 $token2 \
- [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \
- [safe::interpConfigure $i]\
- [safe::interpDelete $i]
+ list $token1 $token2 -- \
+ [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \
+ $mappA -- [safe::interpDelete $i]
# Note that the glob match elides directories (those from the module path)
# other than the first and last in the access path.
} -cleanup {
-} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.2.3\
- {-accessPath {[list $tcl_library * $TestsDir/auto0/auto1]}\
- -statics 0 -nested 1 -deleteHook {}} {}"
+} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\
+ {TCLLIB * TESTSDIR/auto0/auto1} -- {}}
test safe-7.4http {tests specific path and positive search, uses http1.0} -body {
set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
# should not add anything (p0)
set token1 [safe::interpAddToAccessPath $i [info library]]
# should add as p1
set token2 [safe::interpAddToAccessPath $i [file join [info library] http1.0]]
+ set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
# this time, unlike test safe-7.2, http should be found
- list $token1 $token2 \
- [catch {interp eval $i {package require http 1}} msg] $msg \
- [safe::interpConfigure $i]\
- [safe::interpDelete $i]
-} -match glob -result "{\$p(:0:)} {\$p(:*:)} 0 1.0 {-accessPath {[list $tcl_library *$tcl_library/http1.0]} -statics 0 -nested 1 -deleteHook {}} {}"
+ list $token1 $token2 -- \
+ [catch {interp eval $i {package require http 1}} msg] $msg -- \
+ $mappA -- [safe::interpDelete $i]
+} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.0 -- {TCLLIB *TCLLIB/http1.0} -- {}}
# test source control on file name
set i "a"
@@ -632,9 +651,9 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $TestsDir auto0 auto1] \
[file join $TestsDir auto0 auto2]]]
-
# Inspect.
set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -653,6 +672,7 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec
# Inspect.
set confB [safe::interpConfigure $i]
+ set mappB [mapList $PathMapp [dict get $confB -accessPath]]
set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -660,23 +680,21 @@ test safe-9.8 {interpConfigure change the access path; tclIndex commands unaffec
set code3 [catch {interp eval $i {report1}} msg3]
set code4 [catch {interp eval $i {report2}} msg4]
- list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB
+ list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB
} -cleanup {
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\
- {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\
- -statics 1 -nested 0 -deleteHook {}}\
- {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\
- -statics 1 -nested 0 -deleteHook {}}"
+} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}}
test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup {
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $TestsDir auto0 auto1] \
[file join $TestsDir auto0 auto2]]]
-
# Inspect.
set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -693,6 +711,7 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec
# Inspect.
set confB [safe::interpConfigure $i]
+ set mappB [mapList $PathMapp [dict get $confB -accessPath]]
set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -700,14 +719,13 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec
set code3 [catch {interp eval $i {report1}} msg3]
set code4 [catch {interp eval $i {report2}} msg4]
- list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB
+ list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB
} -cleanup {
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 ok1 0 ok2\
- {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\
- -statics 1 -nested 0 -deleteHook {}}\
- {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\
- -statics 1 -nested 0 -deleteHook {}}"
+} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\
+ 0 ok1 0 ok2 --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*}}
test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup {
} -body {
@@ -719,6 +737,7 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un
# Inspect.
set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -736,6 +755,7 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un
# Inspect.
set confB [safe::interpConfigure $i]
+ set mappB [mapList $PathMapp [dict get $confB -accessPath]]
set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -745,17 +765,14 @@ test safe-9.10 {interpConfigure change the access path; pkgIndex.tcl packages un
set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5]
set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6]
- list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \
- $code5 $msg5 $code6 $msg6
-
+ list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- \
+ $mappA -- $mappB -- $code5 $msg5 $code6 $msg6
} -cleanup {
safe::interpDelete $i
-} -match glob -result "{\$p(:2:)} {\$p(:3:)} {\$p(:3:)} {\$p(:2:)} 0 1.2.3 0 2.3.4\
- {-accessPath {[list $tcl_library $TestsDir/auto0 $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\
- -statics 1 -nested 0 -deleteHook {}}\
- {-accessPath {[list $tcl_library $TestsDir/auto0 $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\
- -statics 1 -nested 0 -deleteHook {}}\
- 0 OK1 0 OK2"
+} -match glob -result {{$p(:2:)} {$p(:3:)} -- {$p(:3:)} {$p(:2:)} -- 0 1.2.3 0 2.3.4 --\
+ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\
+ 0 OK1 0 OK2}
test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup {
} -body {
@@ -765,6 +782,7 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un
# Inspect.
set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -778,6 +796,7 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un
# Inspect.
set confB [safe::interpConfigure $i]
+ set mappB [mapList $PathMapp [dict get $confB -accessPath]]
set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -787,25 +806,23 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un
set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5]
set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6]
- list $path1 $path2 $path3 $path4 $code3 $msg3 $code4 $msg4 $confA $confB \
+ list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB -- \
$code5 $msg5 $code6 $msg6
} -cleanup {
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:2:)} {\$p(:1:)} 0 1.2.3 0 2.3.4\
- {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\
- -statics 1 -nested 0 -deleteHook {}}\
- {-accessPath {[list $tcl_library $TestsDir/auto0/auto2 $TestsDir/auto0/auto1]*}\
- -statics 1 -nested 0 -deleteHook {}}\
- 0 OK1 0 OK2"
-
+} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\
+ 0 1.2.3 0 2.3.4 --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1*} --\
+ 0 OK1 0 OK2}
test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup {
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $TestsDir auto0 auto1] \
[file join $TestsDir auto0 auto2]]]
-
# Inspect.
set confA [safe::interpConfigure $i]
+ set mappA [mapList $PathMapp [dict get $confA -accessPath]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
@@ -817,6 +834,7 @@ test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fa
# Inspect.
set confB [safe::interpConfigure $i]
+ set mappB [mapList $PathMapp [dict get $confB -accessPath]]
set code4 [catch {::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]} path4]
set code5 [catch {::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]} path5]
@@ -824,15 +842,12 @@ test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages fa
set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3]
set code6 [catch {interp eval $i {package require SafeTestPackage2}} msg6]
- list $path1 $path2 $code4 $path4 $code5 $path5 $code3 $msg3 $code6 $msg6 $confA $confB
+ list $path1 $path2 -- $code4 $path4 -- $code5 $path5 -- $code3 $code6 -- $mappA -- $mappB
} -cleanup {
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} 1 {* not found in access path}\
- 1 {* not found in access path} 1 {*} 1 {*}\
- {-accessPath {[list $tcl_library $TestsDir/auto0/auto1 $TestsDir/auto0/auto2]*}\
- -statics 1 -nested 0 -deleteHook {}}\
- {-accessPath {[list $tcl_library]*} -statics 1 -nested 0 -deleteHook {}}"
-
+} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\
+ 1 {* not found in access path} -- 1 1 --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} -- {TCLLIB*}}
test safe-9.20 {check module loading} -setup {
set oldTm [tcl::tm::path list]
foreach path $oldTm {
@@ -844,6 +859,7 @@ test safe-9.20 {check module loading} -setup {
# Inspect.
set confA [safe::interpConfigure $i]
+ set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]]
set modsA [interp eval $i {tcl::tm::path list}]
set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -857,22 +873,27 @@ test safe-9.20 {check module loading} -setup {
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list $path0 $path1 $path2 -- $modsA -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $out0 $out1 $out2
+ list [lsort [list $path0 $path1 $path2]] -- $modsA -- \
+ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $out0 $out1 $out2
} -cleanup {
tcl::tm::path remove [file join $TestsDir auto0 modules]
foreach path [lreverse $oldTm] {
tcl::tm::path add $path
}
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\
+} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\
0 0.5 0 1.0 0 2.0 --\
- {-accessPath {[list $tcl_library $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]*}\
- -statics 1 -nested 0 -deleteHook {}} --\
- res0 res1 res2"
-
+ {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\
+ TESTSDIR/auto0/modules/mod2} -- res0 res1 res2}
+# - The command safe::InterpSetConfig adds the master's [tcl::tm::list] in
+# tokenized form to the slave's access path, and then adds all the
+# descendants, discovered recursively by using glob.
+# - The order of the directories in the list returned by glob is system-dependent,
+# and therefore this is true also for (a) the order of token assignment to
+# descendants of the [tcl::tm::list] roots; and (b) the order of those same
+# directories in the access path. Both those things must be sorted before
+# comparing with expected results. The test is therefore not totally strict,
+# but will notice missing or surplus directories.
test safe-9.21 {interpConfigure change the access path; check module loading; stale data case 1} -setup {
set oldTm [tcl::tm::path list]
foreach path $oldTm {
@@ -884,6 +905,7 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st
# Inspect.
set confA [safe::interpConfigure $i]
+ set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]]
set modsA [interp eval $i {tcl::tm::path list}]
set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -897,6 +919,7 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st
# Inspect.
set confB [safe::interpConfigure $i]
+ set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]]
set modsB [interp eval $i {tcl::tm::path list}]
set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -915,8 +938,8 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \
+ list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \
+ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \
$out0 $out1 $out2
} -cleanup {
tcl::tm::path remove [file join $TestsDir auto0 modules]
@@ -924,23 +947,15 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st
tcl::tm::path add $path
}
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\
- {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\
+} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\
+ {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\
0 0.5 0 1.0 0 2.0 --\
- {-accessPath {[list $tcl_library \
- $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]}\
- -statics 1 -nested 0 -deleteHook {}} --\
- {-accessPath {[list $tcl_library \
- $TestsDir/auto0/auto1 \
- $TestsDir/auto0/auto2 \
- $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]}\
- -statics 1 -nested 0 -deleteHook {}} --\
- res0 res1 res2"
-
+ {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\
+ TESTSDIR/auto0/modules/mod2} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\
+ TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\
+ res0 res1 res2}
+# See comments on lsort after test safe-9.20.
test safe-9.22 {interpConfigure change the access path; check module loading; stale data case 0} -setup {
set oldTm [tcl::tm::path list]
foreach path $oldTm {
@@ -952,6 +967,7 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st
# Inspect.
set confA [safe::interpConfigure $i]
+ set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]]
set modsA [interp eval $i {tcl::tm::path list}]
set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -965,6 +981,7 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st
# Inspect.
set confB [safe::interpConfigure $i]
+ set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]]
set modsB [interp eval $i {tcl::tm::path list}]
set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -978,8 +995,8 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \
+ list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \
+ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \
$out0 $out1 $out2
} -cleanup {
tcl::tm::path remove [file join $TestsDir auto0 modules]
@@ -987,23 +1004,15 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st
tcl::tm::path add $path
}
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\
- {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\
+} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\
+ {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\
0 0.5 0 1.0 0 2.0 --\
- {-accessPath {[list $tcl_library \
- $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]}\
- -statics 1 -nested 0 -deleteHook {}} --\
- {-accessPath {[list $tcl_library \
- $TestsDir/auto0/auto1 \
- $TestsDir/auto0/auto2 \
- $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]}\
- -statics 1 -nested 0 -deleteHook {}} --\
- res0 res1 res2"
-
+ {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\
+ TESTSDIR/auto0/modules/mod2} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\
+ TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\
+ res0 res1 res2}
+# See comments on lsort after test safe-9.20.
test safe-9.23 {interpConfigure change the access path; check module loading; stale data case 3} -setup {
set oldTm [tcl::tm::path list]
foreach path $oldTm {
@@ -1015,6 +1024,7 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st
# Inspect.
set confA [safe::interpConfigure $i]
+ set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]]
set modsA [interp eval $i {tcl::tm::path list}]
set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -1033,6 +1043,7 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st
# Inspect.
set confB [safe::interpConfigure $i]
+ set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]]
set modsB [interp eval $i {tcl::tm::path list}]
set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -1051,8 +1062,8 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \
+ list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \
+ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \
$out0 $out1 $out2
} -cleanup {
@@ -1061,23 +1072,15 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st
tcl::tm::path add $path
}
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\
- {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\
+} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\
+ {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\
0 0.5 0 1.0 0 2.0 --\
- {-accessPath {[list $tcl_library \
- $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]}\
- -statics 1 -nested 0 -deleteHook {}} --\
- {-accessPath {[list $tcl_library \
- $TestsDir/auto0/auto1 \
- $TestsDir/auto0/auto2 \
- $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]}\
- -statics 1 -nested 0 -deleteHook {}} --\
- res0 res1 res2"
-
+ {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\
+ TESTSDIR/auto0/modules/mod2} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\
+ TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\
+ res0 res1 res2}
+# See comments on lsort after test safe-9.20.
test safe-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case)} -setup {
set oldTm [tcl::tm::path list]
foreach path $oldTm {
@@ -1089,6 +1092,7 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st
# Inspect.
set confA [safe::interpConfigure $i]
+ set sortA [mapAndSortList $PathMapp [dict get $confA -accessPath]]
set modsA [interp eval $i {tcl::tm::path list}]
set path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path1 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -1107,6 +1111,7 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st
# Inspect.
set confB [safe::interpConfigure $i]
+ set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]]
set modsB [interp eval $i {tcl::tm::path list}]
set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules]]
set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod1]]
@@ -1120,8 +1125,8 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list $path0 $path1 $path2 -- $modsA -- $path3 $path4 $path5 -- $modsB -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $confA -- $confB -- \
+ list [lsort [list $path0 $path1 $path2]] -- $modsA -- [lsort [list $path3 $path4 $path5]] -- $modsB -- \
+ $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \
$out0 $out1 $out2
} -cleanup {
tcl::tm::path remove [file join $TestsDir auto0 modules]
@@ -1129,23 +1134,15 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st
tcl::tm::path add $path
}
safe::interpDelete $i
-} -match glob -result "{\$p(:1:)} {\$p(:2:)} {\$p(:3:)} -- {{\$p(:1:)}} --\
- {\$p(:3:)} {\$p(:4:)} {\$p(:5:)} -- {{\$p(:3:)}} --\
+} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\
+ {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\
0 0.5 0 1.0 0 2.0 --\
- {-accessPath {[list $tcl_library \
- $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]}\
- -statics 1 -nested 0 -deleteHook {}} --\
- {-accessPath {[list $tcl_library \
- $TestsDir/auto0/auto1 \
- $TestsDir/auto0/auto2 \
- $TestsDir/auto0/modules \
- $TestsDir/auto0/modules/mod1 \
- $TestsDir/auto0/modules/mod2]}\
- -statics 1 -nested 0 -deleteHook {}} --\
- res0 res1 res2"
-
+ {TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\
+ TESTSDIR/auto0/modules/mod2} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2 TESTSDIR/auto0/modules\
+ TESTSDIR/auto0/modules/mod1 TESTSDIR/auto0/modules/mod2} --\
+ res0 res1 res2}
+# See comments on lsort after test safe-9.20.
catch {teststaticpkg Safepkg1 0 0}
test safe-10.1 {testing statics loading} -constraints TcltestPackage -setup {
@@ -1440,15 +1437,12 @@ test safe-13.7 {mimic the glob call by tclPkgUnknown in a safe interpreter [Bug
} -body {
set safeTD [::safe::interpAddToAccessPath $i $testdir]
::safe::interpAddToAccessPath $i $testdir2
- string map [list $safeTD EXPECTED] [$i eval [list \
+ mapList [list $safeTD EXPECTED] [$i eval [list \
glob -directory $safeTD -join * pkgIndex.tcl]]
} -cleanup {
safe::interpDelete $i
removeDirectory $testdir
-} -result {{EXPECTED/deletemetoo/pkgIndex.tcl}}
-# Note the extra {} around the result above; that's *expected* because the
-# tokenized paths require delimitation in the list returned by glob; the
-# braces remain after the token is replaced by EXPECTED.
+} -result {EXPECTED/deletemetoo/pkgIndex.tcl}
test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with multiple subdirectories} -setup {
set i [safe::interpCreate]
buildEnvironment2 pkgIndex.tcl
@@ -1456,14 +1450,12 @@ test safe-13.7a {mimic the glob call by tclPkgUnknown in a safe interpreter with
set safeTD [::safe::interpAddToAccessPath $i $testdir]
::safe::interpAddToAccessPath $i $testdir2
::safe::interpAddToAccessPath $i $testdir3
- lsort [string map [list $safeTD EXPECTED] [$i eval [list \
- glob -directory $safeTD -join * pkgIndex.tcl]]]
+ mapAndSortList [list $safeTD EXPECTED] [$i eval [list \
+ glob -directory $safeTD -join * pkgIndex.tcl]]
} -cleanup {
safe::interpDelete $i
removeDirectory $testdir
} -result {EXPECTED/deleteme/pkgIndex.tcl EXPECTED/deletemetoo/pkgIndex.tcl}
-# Cf safe-13.7 - this time there's no extra {} around the result; the list
-# operation lsort removed it.
test safe-13.8 {mimic the glob call by tclPkgUnknown without the special treatment that is specific to pkgIndex.tcl [Bug 2964715]} -setup {
set i [safe::interpCreate]
buildEnvironment notIndex.tcl
@@ -1601,7 +1593,10 @@ test safe-16.4 {Bug 3529949: defang ~user in globs} -setup {
} -result {}
set ::auto_path $saveAutoPath
-unset saveAutoPath TestsDir
+unset saveAutoPath TestsDir PathMapp
+rename mapList {}
+rename mapAndSortList {}
+
# cleanup
::tcltest::cleanupTests
return