summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-18 12:37:58 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-18 12:37:58 (GMT)
commitbff9eb8b3bb8989a9c9ea329127dcf06fc794eee (patch)
treeaf7ab56fc09fd0430e32dbf8b0e7eab9ca96124f
parent842fb667f5a79b8f11cac96c4a029b509ed5ed22 (diff)
parent3d27e0eb5ceee2d55276e190e53123aaaea99960 (diff)
downloadtcl-bff9eb8b3bb8989a9c9ea329127dcf06fc794eee.zip
tcl-bff9eb8b3bb8989a9c9ea329127dcf06fc794eee.tar.gz
tcl-bff9eb8b3bb8989a9c9ea329127dcf06fc794eee.tar.bz2
TIP #579 implementation: Improved auto_path for Safe Base interpreters
-rw-r--r--doc/safe.n169
-rw-r--r--library/safe.tcl229
-rw-r--r--library/tclIndex1
-rw-r--r--tests/safe-stock.test206
-rw-r--r--tests/safe-zipfs.test406
-rw-r--r--tests/safe.test1952
6 files changed, 2756 insertions, 207 deletions
diff --git a/doc/safe.n b/doc/safe.n
index 819287d..6dd4033 100644
--- a/doc/safe.n
+++ b/doc/safe.n
@@ -23,10 +23,13 @@ safe \- Creating and manipulating safe interpreters
.sp
\fB::safe::interpFindInAccessPath\fR \fIchild\fR \fIdirectory\fR
.sp
+\fB::safe::setSyncMode\fR ?\fInewValue\fR?
+.sp
\fB::safe::setLogCmd\fR ?\fIcmd arg...\fR?
.SS OPTIONS
.PP
?\fB\-accessPath\fR \fIpathList\fR?
+?\fB\-autoPath\fR \fIpathList\fR?
?\fB\-statics\fR \fIboolean\fR? ?\fB\-noStatics\fR?
?\fB\-nested\fR \fIboolean\fR? ?\fB\-nestedLoadOk\fR?
?\fB\-deleteHook\fR \fIscript\fR?
@@ -148,6 +151,15 @@ $child eval [list set tk_library \e
.CE
.RE
.TP
+\fB::safe::setSyncMode\fR ?\fInewValue\fR?
+This command is used to get or set the "Sync Mode" of the Safe Base.
+When an argument is supplied, the command returns an error if the argument
+is not a boolean value, or if any Safe Base interpreters exist. Typically
+the value will be set as part of initialization - boolean true for
+"Sync Mode" on (the default), false for "Sync Mode" off. With "Sync Mode"
+on, the Safe Base keeps each child interpreter's ::auto_path synchronized
+with its access path. See the section \fBSYNC MODE\fR below for details.
+.TP
\fB::safe::setLogCmd\fR ?\fIcmd arg...\fR?
This command installs a script that will be called when interesting
life cycle events occur for a safe interpreter.
@@ -199,6 +211,13 @@ parent for auto-loading.
See the section \fBSECURITY\fR below for more detail about virtual paths,
tokens and access control.
.TP
+\fB\-autoPath\fR \fIdirectoryList\fR
+This option sets the list of directories in the safe interpreter's
+::auto_path. The option is undefined if the Safe Base has "Sync Mode" on
+- in that case the safe interpreter's ::auto_path is managed by the Safe
+Base and is a tokenized form of its access path.
+See the section \fBSYNC MODE\fR below for details.
+.TP
\fB\-statics\fR \fIboolean\fR
This option specifies if the safe interpreter will be allowed
to load statically linked packages (like \fBload {} Tk\fR).
@@ -331,7 +350,8 @@ list will be assigned a token that will be set in
the child \fBauto_path\fR and the first element of that list will be set as
the \fBtcl_library\fR for that child.
.PP
-If the access path argument is not given or is the empty list,
+If the access path argument is not given to \fB::safe::interpCreate\fR or
+\fB::safe::interpInit\fR or is the empty list,
the default behavior is to let the child access the same packages
as the parent has access to (Or to be more precise:
only packages written in Tcl (which by definition cannot be dangerous
@@ -357,8 +377,153 @@ When the \fIaccessPath\fR is changed after the first creation or
initialization (i.e. through \fBinterpConfigure -accessPath \fR\fIlist\fR),
an \fBauto_reset\fR is automatically evaluated in the safe interpreter
to synchronize its \fBauto_index\fR with the new token list.
+.SH TYPICAL USE
+In many cases, the properties of a Safe Base interpreter can be specified
+when the interpreter is created, and then left unchanged for the lifetime
+of the interpreter.
+.PP
+If you wish to use Safe Base interpreters with "Sync Mode" off, evaluate
+the command
+.RS
+.PP
+.CS
+ safe::setSyncMode 0
+.CE
+.RE
+.PP
+Use \fB::safe::interpCreate\fR or \fB::safe::interpInit\fR to create an
+interpreter with the properties that you require. The simplest way is not
+to specify \fB\-accessPath\fR or \fB\-autoPath\fR, which means the safe
+interpreter will use the same paths as the parent interpreter. However,
+if \fB\-accessPath\fR is specified, then \fB\-autoPath\fR must also be
+specified, or else it will be set to {}.
+.PP
+The value of \fB\-autoPath\fR will be that required to access tclIndex
+and pkgIndex.tcl files according to the same rules as an unsafe
+interpreter (see pkg_mkIndex(n) and library(n)).
+.PP
+With "Sync Mode" on, the option \fB\-autoPath\fR is undefined, and
+the Safe Base sets the child's ::auto_path to a tokenized form of the
+access path. In addition to the directories present if "Safe Mode" is off,
+the ::auto_path includes the numerous subdirectories and module paths
+that belong to the access path.
+.SH SYNC MODE
+Before Tcl version 8.7, the Safe Base kept each safe interpreter's
+::auto_path synchronized with a tokenized form of its access path.
+Limitations of Tcl 8.4 and earlier made this feature necessary. This
+definition of ::auto_path did not conform its specification in library(n)
+and pkg_mkIndex(n), but nevertheless worked perfectly well for the discovery
+and loading of packages. The introduction of Tcl modules in Tcl 8.5 added a
+large number of directories to the access path, and it is inconvenient to
+have these additional directories unnecessarily appended to the ::auto_path.
+.PP
+In order to preserve compatibility with existing code, this synchronization
+of the ::auto_path and access path ("Sync Mode" on) is still the default.
+However, the Safe Base offers the option of limiting the safe interpreter's
+::auto_path to the much shorter list of directories that is necessary for
+it to perform its function ("Sync Mode" off). Use the command
+\fB::safe::setSyncMode\fR to choose the mode before creating any Safe
+Base interpreters.
+.PP
+In either mode, the most convenient way to initialize a safe interpreter is
+to call \fB::safe::interpCreate\fR or \fB::safe::interpInit\fR without the
+\fB\-accessPath\fR or \fB\-autoPath\fR options (or with the \fB\-accessPath\fR
+option set to the
+empty list), which will give the safe interpreter the same access as the
+parent interpreter to packages, modules, and autoloader files. With
+"Sync Mode" off, the Safe Base will set the value of \fB\-autoPath\fR to the
+parent's ::auto_path, and will set the child's ::auto_path to a tokenized form
+of the parent's ::auto_path.
+.PP
+With "Sync Mode" off, if a value is specified for \fB\-autoPath\fR, even the empty
+list, in a call to \fB::safe::interpCreate\fR, \fB::safe::interpInit\fR, or
+\fB::safe::interpConfigure\fR, it will be tokenized and used as the safe
+interpreter's ::auto_path. Any directories that do not also belong to the
+access path cannot be tokenized and will be silently ignored. However, the
+value of \fB\-autoPath\fR will remain as specified, and will be used to
+re-tokenize the child's ::auto_path if \fB::safe::interpConfigure\fR is called
+to change the value of \fB\-accessPath\fR.
+.PP
+With "Sync Mode" off, if the access path is reset to the values in the
+parent interpreter by calling \fB::safe::interpConfigure\fR with arguments
+\fB\-accessPath\fR {}, then the ::auto_path will also be reset unless the argument
+\fB\-autoPath\fR is supplied to specify a different value.
+.PP
+With "Sync Mode" off, if a non-empty value of \fB\-accessPath\fR is supplied, the
+safe interpreter's ::auto_path will be set to {} (by
+\fB::safe::interpCreate\fR, \fB::safe::interpInit\fR) or left unchanged
+(by \fB::safe::interpConfigure\fR). If the same command specifies a new
+value for \fB\-autoPath\fR, it will be applied after the \fB\-accessPath\fR argument has
+been processed.
+
+Examples of use with "Sync Mode" off: any of these commands will set the
+::auto_path to a tokenized form of its value in the parent interpreter:
+.RS
+.PP
+.CS
+ safe::interpCreate foo
+ safe::interpCreate foo -accessPath {}
+ safe::interpInit bar
+ safe::interpInit bar -accessPath {}
+ safe::interpConfigure foo -accessPath {}
+.CE
+.RE
+.TP
+Example of use with "Sync Mode" off: when initializing a safe interpreter
+with a non-empty access path, the ::auto_path will be set to {} unless its
+own value is also specified:
+.RS
+.PP
+.CS
+ safe::interpCreate foo -accessPath {
+ /usr/local/TclHome/lib/tcl8.6
+ /usr/local/TclHome/lib/tcl8.6/http1.0
+ /usr/local/TclHome/lib/tcl8.6/opt0.4
+ /usr/local/TclHome/lib/tcl8.6/msgs
+ /usr/local/TclHome/lib/tcl8.6/encoding
+ /usr/local/TclHome/lib
+ }
+
+ # The child's ::auto_path must be given a suitable value:
+
+ safe::interpConfigure foo -autoPath {
+ /usr/local/TclHome/lib/tcl8.6
+ /usr/local/TclHome/lib
+ }
+
+ # The two commands can be combined:
+
+ safe::interpCreate foo -accessPath {
+ /usr/local/TclHome/lib/tcl8.6
+ /usr/local/TclHome/lib/tcl8.6/http1.0
+ /usr/local/TclHome/lib/tcl8.6/opt0.4
+ /usr/local/TclHome/lib/tcl8.6/msgs
+ /usr/local/TclHome/lib/tcl8.6/encoding
+ /usr/local/TclHome/lib
+ } -autoPath {
+ /usr/local/TclHome/lib/tcl8.6
+ /usr/local/TclHome/lib
+ }
+.CE
+.RE
+.TP
+Example of use with "Sync Mode" off: the command
+\fBsafe::interpAddToAccessPath\fR does not change the safe interpreter's
+::auto_path, and so any necessary change must be made by the script:
+.RS
+.PP
+.CS
+ safe::interpAddToAccessPath foo /usr/local/TclHome/lib/extras/Img1.4.11
+
+ lassign [safe::interpConfigure foo -autoPath] DUM childAutoPath
+ lappend childAutoPath /usr/local/TclHome/lib/extras/Img1.4.11
+ safe::interpConfigure foo -autoPath $childAutoPath
+.CE
+.RE
+.TP
.SH "SEE ALSO"
-interp(n), library(n), load(n), package(n), source(n), unknown(n)
+interp(n), library(n), load(n), package(n), pkg_mkIndex(n), source(n),
+tm(n), unknown(n)
.SH KEYWORDS
alias, auto\-loading, auto_mkindex, load, parent interpreter, safe
interpreter, child interpreter, source
diff --git a/library/safe.tcl b/library/safe.tcl
index 9050880..7fc2b5c 100644
--- a/library/safe.tcl
+++ b/library/safe.tcl
@@ -78,20 +78,32 @@ proc ::safe::InterpNested {} {
# Interface/entry point function and front end for "Create"
proc ::safe::interpCreate {args} {
+ variable AutoPathSync
+ if {$AutoPathSync} {
+ set autoPath {}
+ }
set Args [::tcl::OptKeyParse ::safe::interpCreate $args]
RejectExcessColons $child
+
+ set withAutoPath [::tcl::OptProcArgGiven -autoPath]
InterpCreate $child $accessPath \
- [InterpStatics] [InterpNested] $deleteHook
+ [InterpStatics] [InterpNested] $deleteHook $autoPath $withAutoPath
}
proc ::safe::interpInit {args} {
+ variable AutoPathSync
+ if {$AutoPathSync} {
+ set autoPath {}
+ }
set Args [::tcl::OptKeyParse ::safe::interpIC $args]
if {![::interp exists $child]} {
return -code error "\"$child\" is not an interpreter"
}
RejectExcessColons $child
+
+ set withAutoPath [::tcl::OptProcArgGiven -autoPath]
InterpInit $child $accessPath \
- [InterpStatics] [InterpNested] $deleteHook
+ [InterpStatics] [InterpNested] $deleteHook $autoPath $withAutoPath
}
# Check that the given child is "one of us"
@@ -117,6 +129,7 @@ proc ::safe::CheckInterp {child} {
# So this will be hopefully written and some integrated with opt1.0
# (hopefully for tcl8.1 ?)
proc ::safe::interpConfigure {args} {
+ variable AutoPathSync
switch [llength $args] {
1 {
# If we have exactly 1 argument the semantic is to return all
@@ -127,11 +140,16 @@ proc ::safe::interpConfigure {args} {
CheckInterp $child
namespace upvar ::safe [VarName $child] state
- return [join [list \
+ set TMP [list \
[list -accessPath $state(access_path)] \
[list -statics $state(staticsok)] \
[list -nested $state(nestedok)] \
- [list -deleteHook $state(cleanupHook)]]]
+ [list -deleteHook $state(cleanupHook)] \
+ ]
+ if {!$AutoPathSync} {
+ lappend TMP [list -autoPath $state(auto_path)]
+ }
+ return [join $TMP]
}
2 {
# If we have exactly 2 arguments the semantic is a "configure
@@ -156,6 +174,13 @@ proc ::safe::interpConfigure {args} {
-accessPath {
return [list -accessPath $state(access_path)]
}
+ -autoPath {
+ if {$AutoPathSync} {
+ return -code error "unknown flag $name (bug)"
+ } else {
+ return [list -autoPath $state(auto_path)]
+ }
+ }
-statics {
return [list -statics $state(staticsok)]
}
@@ -199,6 +224,12 @@ proc ::safe::interpConfigure {args} {
} else {
set doreset 1
}
+ if {(!$AutoPathSync) && (![::tcl::OptProcArgGiven -autoPath])} {
+ set autoPath $state(auto_path)
+ } elseif {$AutoPathSync} {
+ set autoPath {}
+ } else {
+ }
if {
![::tcl::OptProcArgGiven -statics]
&& ![::tcl::OptProcArgGiven -noStatics]
@@ -219,8 +250,10 @@ proc ::safe::interpConfigure {args} {
set deleteHook $state(cleanupHook)
}
# we can now reconfigure :
- InterpSetConfig $child $accessPath $statics $nested $deleteHook
- # auto_reset the child (to completly synch the new access_path)
+ set withAutoPath [::tcl::OptProcArgGiven -autoPath]
+ InterpSetConfig $child $accessPath $statics $nested $deleteHook $autoPath $withAutoPath
+
+ # auto_reset the child (to completely synch the new access_path) tests safe-9.8 safe-9.9
if {$doreset} {
if {[catch {::interp eval $child {auto_reset}} msg]} {
Log $child "auto_reset failed: $msg"
@@ -270,10 +303,11 @@ proc ::safe::interpConfigure {args} {
# Optional Arguments :
# + child name : if empty, generated name will be used
# + access_path: path list controlling where load/source can occur,
-# if empty: the parent auto_path will be used.
+# if empty: the parent auto_path and its subdirectories will be
+# used.
# + staticsok : flag, if 0 :no static package can be loaded (load {} Xxx)
# if 1 :static packages are ok.
-# + nestedok: flag, if 0 :no loading to sub-sub interps (load xx xx sub)
+# + nestedok : flag, if 0 :no loading to sub-sub interps (load xx xx sub)
# if 1 : multiple levels are ok.
# use the full name and no indent so auto_mkIndex can find us
@@ -283,6 +317,8 @@ proc ::safe::InterpCreate {
staticsok
nestedok
deletehook
+ autoPath
+ withAutoPath
} {
# Create the child.
# If evaluated in ::safe, the interpreter command for foo is ::foo;
@@ -296,20 +332,25 @@ proc ::safe::InterpCreate {
Log $child "Created" NOTICE
# Initialize it. (returns child name)
- InterpInit $child $access_path $staticsok $nestedok $deletehook
+ InterpInit $child $access_path $staticsok $nestedok $deletehook $autoPath $withAutoPath
}
#
# InterpSetConfig (was setAccessPath) :
-# Sets up child virtual auto_path and corresponding structure within
+# Sets up child virtual access path and corresponding structure within
# the parent. Also sets the tcl_library in the child to be the first
# directory in the path.
# NB: If you change the path after the child has been initialized you
# probably need to call "auto_reset" in the child in order that it gets
# the right auto_index() array values.
+#
+# It is the caller's responsibility, if it supplies a non-empty value for
+# access_path, to make the first directory in the path suitable for use as
+# tcl_library, and (if ![setSyncMode]), to set the child's ::auto_path.
-proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} {
+proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook autoPath withAutoPath} {
global auto_path
+ variable AutoPathSync
# determine and store the access path if empty
if {$access_path eq ""} {
@@ -332,14 +373,25 @@ proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} {
moved it to front of child's access_path" NOTICE
}
+ set raw_auto_path $access_path
+
# Add 1st level sub dirs (will searched by auto loading from tcl
# code in the child using glob and thus fail, so we add them here
# so by default it works the same).
set access_path [AddSubDirs $access_path]
+ } else {
+ set raw_auto_path $autoPath
+ }
+
+ if {$withAutoPath} {
+ set raw_auto_path $autoPath
}
Log $child "Setting accessPath=($access_path) staticsok=$staticsok\
nestedok=$nestedok deletehook=($deletehook)" NOTICE
+ if {!$AutoPathSync} {
+ Log $child "Setting auto_path=($raw_auto_path)" NOTICE
+ }
namespace upvar ::safe [VarName $child] state
@@ -349,7 +401,6 @@ proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} {
# We save the virtual form separately as well, as syncing it with the
# child has to be defered until the necessary commands are present for
# setup.
-
set norm_access_path {}
set child_access_path {}
set map_access_path {}
@@ -366,6 +417,20 @@ proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} {
incr i
}
+ # Set the child auto_path to a tokenized raw_auto_path.
+ # Silently ignore any directories that are not in the access path.
+ # If [setSyncMode], SyncAccessPath will overwrite this value with the
+ # full access path.
+ # If ![setSyncMode], Safe Base code will not change this value.
+ set tokens_auto_path {}
+ foreach dir $raw_auto_path {
+ if {[dict exists $remap_access_path $dir]} {
+ lappend tokens_auto_path [dict get $remap_access_path $dir]
+ }
+ }
+ ::interp eval $child [list set auto_path $tokens_auto_path]
+
+ # Add the tcl::tm directories to the access path.
set morepaths [::tcl::tm::list]
set firstpass 1
while {[llength $morepaths]} {
@@ -420,15 +485,42 @@ proc ::safe::InterpSetConfig {child access_path staticsok nestedok deletehook} {
set state(nestedok) $nestedok
set state(cleanupHook) $deletehook
+ if {!$AutoPathSync} {
+ set state(auto_path) $raw_auto_path
+ }
+
SyncAccessPath $child
return
}
+
+#
+# DetokPath:
+# Convert tokens to directories where possible.
+# Leave undefined tokens unconverted. They are
+# nonsense in both the child and the parent.
+#
+proc ::safe::DetokPath {child tokenPath} {
+ namespace upvar ::safe [VarName $child] state
+
+ set childPath {}
+ foreach token $tokenPath {
+ if {[dict exists $state(access_path,map) $token]} {
+ lappend childPath [dict get $state(access_path,map) $token]
+ } else {
+ lappend childPath $token
+ }
+ }
+ return $childPath
+}
+
#
#
-# FindInAccessPath:
+# interpFindInAccessPath:
# Search for a real directory and returns its virtual Id (including the
# "$")
+#
+# When debugging, use TranslatePath for the inverse operation.
proc ::safe::interpFindInAccessPath {child path} {
CheckInterp $child
namespace upvar ::safe [VarName $child] state
@@ -440,6 +532,7 @@ proc ::safe::interpFindInAccessPath {child path} {
return [dict get $state(access_path,remap) $path]
}
+
#
# addToAccessPath:
# add (if needed) a real directory to access path and return its
@@ -476,9 +569,11 @@ proc ::safe::InterpInit {
staticsok
nestedok
deletehook
+ autoPath
+ withAutoPath
} {
# Configure will generate an access_path when access_path is empty.
- InterpSetConfig $child $access_path $staticsok $nestedok $deletehook
+ InterpSetConfig $child $access_path $staticsok $nestedok $deletehook $autoPath $withAutoPath
# NB we need to add [namespace current], aliases are always absolute
# paths.
@@ -665,24 +760,28 @@ proc ::safe::setLogCmd {args} {
# ------------------- END OF PUBLIC METHODS ------------
#
-# Sets the child auto_path to the parent recorded value. Also sets
-# tcl_library to the first token of the virtual path.
+# Sets the child auto_path to its recorded access path. Also sets
+# tcl_library to the first token of the access path.
#
proc ::safe::SyncAccessPath {child} {
+ variable AutoPathSync
namespace upvar ::safe [VarName $child] state
set child_access_path $state(access_path,child)
- ::interp eval $child [list set auto_path $child_access_path]
+ if {$AutoPathSync} {
+ ::interp eval $child [list set auto_path $child_access_path]
- Log $child "auto_path in $child has been set to $child_access_path"\
- NOTICE
+ Log $child "auto_path in $child has been set to $child_access_path"\
+ NOTICE
+ }
# This code assumes that info library is the first element in the
- # list of auto_path's. See -> InterpSetConfig for the code which
+ # list of access path's. See -> InterpSetConfig for the code which
# ensures this condition.
::interp eval $child [list \
set tcl_library [lindex $child_access_path 0]]
+ return
}
# Returns the virtual token for directory number N.
@@ -742,6 +841,7 @@ proc ::safe::AliasFileSubcommand {child subcommand name} {
# AliasGlob is the target of the "glob" alias in safe interpreters.
proc ::safe::AliasGlob {child args} {
+ variable AutoPathSync
Log $child "GLOB ! $args" NOTICE
set cmd {}
set at 0
@@ -789,6 +889,7 @@ proc ::safe::AliasGlob {child args} {
-* {
Log $child "Safe base rejecting glob option '$opt'"
return -code error "Safe base rejecting glob option '$opt'"
+ # unsafe/unnecessary options rejected: -path
}
default {
break
@@ -823,7 +924,7 @@ proc ::safe::AliasGlob {child args} {
return -code error "permission denied"
}
- # Apply the -join semantics ourselves.
+ # Apply the -join semantics ourselves (hence -join not copied to $cmd)
if {$got(-join)} {
set args [lreplace $args $at end [join [lrange $args $at end] "/"]]
}
@@ -1207,16 +1308,21 @@ proc ::safe::Setup {} {
# Setup the arguments parsing
#
####
+ variable AutoPathSync
# Share the descriptions
- set temp [::tcl::OptKeyRegister {
+ set OptList {
{-accessPath -list {} "access path for the child"}
{-noStatics "prevent loading of statically linked pkgs"}
{-statics true "loading of statically linked pkgs"}
{-nestedLoadOk "allow nested loading"}
{-nested false "nested loading"}
{-deleteHook -script {} "delete hook"}
- }]
+ }
+ if {!$AutoPathSync} {
+ lappend OptList {-autoPath -list {} "::auto_path for the child"}
+ }
+ set temp [::tcl::OptKeyRegister $OptList]
# create case (child is optional)
::tcl::OptKeyRegister {
@@ -1253,8 +1359,72 @@ proc ::safe::Setup {} {
return
}
+# Accessor method for ::safe::AutoPathSync
+# Usage: ::safe::setSyncMode ?newValue?
+# Respond to changes by calling Setup again, preserving any
+# caller-defined logging. This allows complete equivalence with
+# prior Safe Base behavior if AutoPathSync is true.
+#
+# >>> WARNING <<<
+#
+# DO NOT CHANGE AutoPathSync EXCEPT BY THIS COMMAND - IT IS VITAL THAT WHENEVER
+# THE VALUE CHANGES, THE EXISTING PARSE TOKENS ARE DELETED AND Setup IS CALLED
+# AGAIN.
+# (The initialization of AutoPathSync at the end of this file is acceptable
+# because Setup has not yet been called.)
+
+proc ::safe::setSyncMode {args} {
+ variable AutoPathSync
+
+ if {[llength $args] == 0} {
+ } elseif {[llength $args] == 1} {
+ set newValue [lindex $args 0]
+ if {![string is boolean -strict $newValue]} {
+ return -code error "new value must be a valid boolean"
+ }
+ set args [expr {$newValue && $newValue}]
+ if {([info vars ::safe::S*] ne {}) && ($args != $AutoPathSync)} {
+ return -code error \
+ "cannot set new value while Safe Base child interpreters exist"
+ }
+ if {($args != $AutoPathSync)} {
+ set AutoPathSync {*}$args
+ ::tcl::OptKeyDelete ::safe::interpCreate
+ ::tcl::OptKeyDelete ::safe::interpIC
+ set TmpLog [setLogCmd]
+ Setup
+ setLogCmd $TmpLog
+ }
+ } else {
+ set msg {wrong # args: should be "safe::setSyncMode ?newValue?"}
+ return -code error $msg
+ }
+
+ return $AutoPathSync
+}
+
namespace eval ::safe {
- # internal variables
+ # internal variables (must not begin with "S")
+
+ # AutoPathSync
+ #
+ # Set AutoPathSync to 0 to give a child's ::auto_path the same meaning as
+ # for an unsafe interpreter: the package command will search its directories
+ # and first-level subdirectories for pkgIndex.tcl files; the auto-loader
+ # will search its directories for tclIndex files. The access path and
+ # module path will be maintained as separate values, and ::auto_path will
+ # not be updated when the user calls ::safe::interpAddToAccessPath to add to
+ # the access path. If the user specifies an access path when calling
+ # interpCreate, interpInit or interpConfigure, it is the user's
+ # responsibility to define the child's auto_path. If these commands are
+ # called with no (or empty) access path, the child's auto_path will be set
+ # to a tokenized form of the parent's auto_path, and these directories and
+ # their first-level subdirectories will be added to the access path.
+ #
+ # Set to 1 for "traditional" behavior: a child's entire access path and
+ # module path are copied to its ::auto_path, which is updated whenever
+ # the user calls ::safe::interpAddToAccessPath to add to the access path.
+ variable AutoPathSync 1
# Log command, set via 'setLogCmd'. Logging is disabled when empty.
variable Log {}
@@ -1272,10 +1442,21 @@ namespace eval ::safe {
# access_path,child : Ditto, as the path tokens as seen by the child.
# access_path,map : dict ( token -> path )
# access_path,remap : dict ( path -> token )
+ # auto_path : List of paths requested by the caller as child's ::auto_path.
# tm_path_child : List of TM root directories, as tokens seen by the child.
# staticsok : Value of option -statics
# nestedok : Value of option -nested
# cleanupHook : Value of option -deleteHook
+ #
+ # In principle, the child can change its value of ::auto_path -
+ # - a package might add a path (that is already in the access path) for
+ # access to tclIndex files;
+ # - the script might remove some elements of the auto_path.
+ # However, this is really the business of the parent, and the auto_path will
+ # be reset whenever the token mapping changes (i.e. when option -accessPath is
+ # used to change the access path).
+ # -autoPath is now stored in the array and is no longer obtained from
+ # the child.
}
::safe::Setup
diff --git a/library/tclIndex b/library/tclIndex
index 5f7fbfb..a8db3cb 100644
--- a/library/tclIndex
+++ b/library/tclIndex
@@ -61,6 +61,7 @@ set auto_index(::safe::DirInAccessPath) [list ::tcl::Pkg::source [file join $dir
set auto_index(::safe::Subset) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
set auto_index(::safe::AliasSubset) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
set auto_index(::safe::AliasEncoding) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
+set auto_index(::safe::setSyncMode) [list ::tcl::Pkg::source [file join $dir safe.tcl]]
set auto_index(tcl_wordBreakAfter) [list ::tcl::Pkg::source [file join $dir word.tcl]]
set auto_index(tcl_wordBreakBefore) [list ::tcl::Pkg::source [file join $dir word.tcl]]
set auto_index(tcl_endOfWord) [list ::tcl::Pkg::source [file join $dir word.tcl]]
diff --git a/tests/safe-stock.test b/tests/safe-stock.test
index bfea85c..d23d86e 100644
--- a/tests/safe-stock.test
+++ b/tests/safe-stock.test
@@ -101,8 +101,15 @@ proc mapAndSortList {map listIn} {
# thus un-autoindexed) APIs in this test result arguments:
catch {safe::interpConfigure}
+testConstraint AutoSyncDefined 1
+
# high level general test
-test safe-stock-7.1 {tests that everything works at high level, uses pkg opt} -setup {
+test safe-stock-7.1 {tests that everything works at high level with conventional AutoPathSync, use pkg opt} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set i [safe::interpCreate]
} -body {
# no error shall occur:
@@ -114,8 +121,18 @@ test safe-stock-7.1 {tests that everything works at high level, uses pkg opt} -s
set v
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result 0.4.*
-test safe-stock-7.2 {tests specific path and interpFind/AddToAccessPath, uses pkg opt} -setup {
+test safe-stock-7.2 {tests specific path and interpFind/AddToAccessPath with conventional AutoPathSync, use pkg opt} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ } else {
+ set SyncVal_TMP 1
+ }
} -body {
set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
# should not add anything (p0)
@@ -130,9 +147,19 @@ test safe-stock-7.2 {tests specific path and interpFind/AddToAccessPath, uses pk
[catch {interp eval $i {package require opt}} msg] $msg -- \
$mappA -- [safe::interpDelete $i]
} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result "{\$p(:0:)} {\$p(:*:)} -- 1 {$pkgOptErrMsg} --\
{TCLLIB */dummy/unixlike/test/path} -- {}"
-test safe-stock-7.4 {tests specific path and positive search, uses pkg opt} -setup {
+test safe-stock-7.4 {tests specific path and positive search with conventional AutoPathSync, use pkg opt} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ } else {
+ set SyncVal_TMP 1
+ }
} -body {
set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
# should not add anything (p0)
@@ -148,8 +175,35 @@ test safe-stock-7.4 {tests specific path and positive search, uses pkg opt} -set
# Note that the glob match elides directories (those from the module path)
# other than the first and last in the access path.
} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 0.4.* --\
{TCLLIB * TCLLIB/OPTDIR} -- {}}
+test safe-stock-7.5 {tests positive and negative module loading with conventional AutoPathSync} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
+ set i [safe::interpCreate]
+ interp eval $i {
+ package forget platform::shell
+ package forget platform
+ catch {namespace delete ::platform}
+ }
+} -body {
+ # Should raise an error (module ancestor directory issue)
+ set code1 [catch {interp eval $i {package require shell}} msg1]
+ # Should not raise an error
+ set code2 [catch {interp eval $i {package require platform::shell}} msg2]
+ return [list $code1 $msg1 $code2]
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {1 {can't find package shell} 0}
# The following test checks whether the definition of tcl_endOfWord can be
# obtained from auto_loading. It was previously test "safe-5.1".
@@ -161,7 +215,12 @@ test safe-stock-9.8 {test auto-loading in safe interpreters, was safe-5.1} -setu
} -cleanup {
safe::interpDelete a
} -result -1
-test safe-stock-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, uses pkg opt and tcl::idna} -setup {
+test safe-stock-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement with conventional AutoPathSync, uses pkg opt and tcl::idna} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $tcl_library $pkgOptDir] \
@@ -196,11 +255,19 @@ test safe-stock-9.11 {interpConfigure change the access path; pkgIndex.tcl packa
$mappA -- $mappB -- $code5 $msg5 $code6 $msg6
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 1.* 0 0.4.* --\
{TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} --\
{TCLLIB TCLLIB/JARDIR TCLLIB/OPTDIR*} --\
0 0 0 example.com}
-test safe-stock-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, uses pkg opt and tcl::idna} -setup {
+test safe-stock-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed with conventional AutoPathSync, uses pkg opt and tcl::idna} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $tcl_library $pkgOptDir] \
@@ -231,9 +298,138 @@ test safe-stock-9.13 {interpConfigure change the access path; pkgIndex.tcl packa
$mappA -- $mappB
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} --\
1 {* not found in access path} -- 1 1 --\
{TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} -- {TCLLIB*}}
+
+test safe-stock-18.1 {cf. safe-stock-7.1opt - tests that everything works at high level without conventional AutoPathSync, use pkg opt} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ # Without AutoPathSync, we need a more complete auto_path,
+ # because the child will use the same value.
+ set lib1 [info library]
+ set lib2 [file dirname $lib1]
+ set ::auto_TMP $::auto_path
+ set ::auto_path [list $lib1 $lib2]
+
+ set i [safe::interpCreate]
+ set ::auto_path $::auto_TMP
+} -body {
+ # no error shall occur:
+ # (because the default access_path shall include 1st level sub dirs so
+ # package require in a child works like in the parent)
+ set v [interp eval $i {package require opt}]
+ # no error shall occur:
+ interp eval $i {::tcl::Lempty {a list}}
+ set v
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result 0.4.*
+test safe-stock-18.2 {cf. safe-stock-7.2opt - tests specific path and interpFind/AddToAccessPath without conventional AutoPathSync, use pkg opt} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
+ set auto1 [interp eval $i {set ::auto_path}]
+ # This will differ from the value -autoPath {}
+ interp eval $i {set ::auto_path [list {$p(:0:)}]}
+ # should not add anything (p0)
+ set token1 [safe::interpAddToAccessPath $i [info library]]
+ # should add as p* (not p1 if parent has a module path)
+ set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"]
+ # an error shall occur (opt is not anymore in the secure 0-level
+ # provided deep path)
+ list $auto1 $token1 $token2 \
+ [catch {interp eval $i {package require opt}} msg] $msg \
+ [safe::interpConfigure $i]\
+ [safe::interpDelete $i]
+} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result "{} {\$p(:0:)} {\$p(:*:)} 1 {$pkgOptErrMsg}\
+ {-accessPath {[list $tcl_library */dummy/unixlike/test/path]}\
+ -statics 0 -nested 1 -deleteHook {} -autoPath {}} {}"
+test safe-stock-18.4 {cf. safe-stock-7.4opt - tests specific path and positive search and auto_path without conventional AutoPathSync, use pkg opt} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
+
+ # should not have been set by Safe Base:
+ set auto1 [interp eval $i {set ::auto_path}]
+
+ # This will differ from the value -autoPath {}
+ interp eval $i {set ::auto_path [list {$p(:0:)}]}
+
+ # should not add anything (p0)
+ set token1 [safe::interpAddToAccessPath $i [info library]]
+
+ # should add as p* (not p1 if parent has a module path)
+ set token2 [safe::interpAddToAccessPath $i [file join [info library] $pkgOptDir]]
+
+ # should not have been changed by Safe Base:
+ set auto2 [interp eval $i {set ::auto_path}]
+
+ # This time, unlike test safe-stock-18.2opt and the try above, opt should be found:
+ list $auto1 $auto2 $token1 $token2 \
+ [catch {interp eval $i {package require opt}} msg] $msg \
+ [safe::interpConfigure $i]\
+ [safe::interpDelete $i]
+} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result "{} {{\$p(:0:)}} {\$p(:0:)} {\$p(:*:)} 0 0.4.*\
+ {-accessPath {[list $tcl_library *$tcl_library/$pkgOptDir]}\
+ -statics 0 -nested 1 -deleteHook {} -autoPath {}} {}"
+test safe-stock-18.5 {cf. safe-stock-7.5 - tests positive and negative module loading without conventional AutoPathSync} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate]
+ interp eval $i {
+ package forget platform::shell
+ package forget platform
+ catch {namespace delete ::platform}
+ }
+} -body {
+ # Should raise an error (tests module ancestor directory rule)
+ set code1 [catch {interp eval $i {package require shell}} msg1]
+ # Should not raise an error
+ set code2 [catch {interp eval $i {package require platform::shell}} msg2]
+ return [list $code1 $msg1 $code2]
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {1 {can't find package shell} 0}
set ::auto_path $SaveAutoPath
unset pkgOptErrMsg pkgOptDir pkgJarDir SaveAutoPath TestsDir PathMapp
diff --git a/tests/safe-zipfs.test b/tests/safe-zipfs.test
index a6088c4..41c4b78 100644
--- a/tests/safe-zipfs.test
+++ b/tests/safe-zipfs.test
@@ -55,6 +55,8 @@ apply [list {} {
# thus un-autoindexed) APIs in this test result arguments:
catch {safe::interpConfigure}
+ testConstraint AutoSyncDefined 1
+
# Tests 5.* test the example files before using them to test safe interpreters.
test safe-zipfs-5.1 {example tclIndex commands, test in parent interpreter; zipfs} -setup {
@@ -104,8 +106,7 @@ apply [list {} {
} -match glob -result {0 1.2.3 0 2.3.4 0 OK1 0 OK2}
test safe-zipfs-5.4 {example pkgIndex.tcl packages, test in parent interpreter, main directories; zipfs} -setup {
set tmpAutoPath $::auto_path
- lappend ::auto_path [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]
+ lappend ::auto_path [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]
} -body {
# Try to load the packages and run a command from each one.
set code3 [catch {package require SafeTestPackage1} msg3]
@@ -168,7 +169,12 @@ apply [list {} {
# high level general test
# Use zipped example packages not http1.0 etc
- test safe-zipfs-7.1 {tests that everything works at high level; zipfs} -setup {
+ test safe-zipfs-7.1 {tests that everything works at high level with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set tmpAutoPath $::auto_path
lappend ::auto_path [file join $ZipMountPoint auto0]
set i [safe::interpCreate]
@@ -183,8 +189,18 @@ apply [list {} {
set v
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result 1.2.3
- test safe-zipfs-7.2 {tests specific path and interpFind/AddToAccessPath; zipfs} -setup {
+ test safe-zipfs-7.2 {tests specific path and interpFind/AddToAccessPath with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ } else {
+ set SyncVal_TMP 1
+ }
} -body {
set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
# should not add anything (p0)
@@ -197,14 +213,20 @@ apply [list {} {
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 -- \
- $mappA -- [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} --\
- {TCLLIB */dummy/unixlike/test/path ZIPDIR/auto0} -- {}}
- test safe-zipfs-7.4 {tests specific path and positive search; zipfs} -setup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} -- 1 {can't find package SafeTestPackage1} -- {TCLLIB */dummy/unixlike/test/path ZIPDIR/auto0} -- {}}
+ test safe-zipfs-7.4 {tests specific path and positive search with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ } else {
+ set SyncVal_TMP 1
+ }
} -body {
set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
# should not add anything (p0)
@@ -214,20 +236,23 @@ apply [list {} {
set confA [safe::interpConfigure $i]
set mappA [mapList $PathMapp [dict get $confA -accessPath]]
# this time, unlike test safe-zipfs-7.2, SafeTestPackage1 should be found
- list $token1 $token2 -- \
- [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \
- $mappA -- [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 --\
- {TCLLIB * ZIPDIR/auto0/auto1} -- {}}
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 -- {TCLLIB * ZIPDIR/auto0/auto1} -- {}}
- test safe-zipfs-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset); zipfs} -setup {
+ test safe-zipfs-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset) with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
- set i [safe::interpCreate -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]]
+ set i [safe::interpCreate -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]]
# Inspect.
set confA [safe::interpConfigure $i]
set mappA [mapList $PathMapp [dict get $confA -accessPath]]
@@ -243,9 +268,7 @@ apply [list {} {
set code2 [catch {interp eval $i {report2}} msg2]
# Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}.
- safe::interpConfigure $i -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto2] \
- [file join $ZipMountPoint auto0 auto1]]
+ safe::interpConfigure $i -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto2] [file join $ZipMountPoint auto0 auto1]]
# Inspect.
set confB [safe::interpConfigure $i]
set mappB [mapList $PathMapp [dict get $confB -accessPath]]
@@ -259,14 +282,18 @@ apply [list {} {
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 --\
- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\
- {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}}
- test safe-zipfs-9.10 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset); zipfs} -setup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 -- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}}
+ test safe-zipfs-9.10 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset) with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
- set i [safe::interpCreate -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]]
+ set i [safe::interpCreate -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]]
# Inspect.
set confA [safe::interpConfigure $i]
set mappA [mapList $PathMapp [dict get $confA -accessPath]]
@@ -280,9 +307,7 @@ apply [list {} {
# will pass only if the Safe Base has called auto_reset.
# Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}.
- safe::interpConfigure $i -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto2] \
- [file join $ZipMountPoint auto0 auto1]]
+ safe::interpConfigure $i -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto2] [file join $ZipMountPoint auto0 auto1]]
# Inspect.
set confB [safe::interpConfigure $i]
set mappB [mapList $PathMapp [dict get $confB -accessPath]]
@@ -296,17 +321,19 @@ apply [list {} {
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 --\
- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\
- {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}}
- test safe-zipfs-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement; zipfs} -setup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 ok1 0 ok2 -- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*}}
+ test safe-zipfs-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
- # For complete correspondence to safe-stock87-9.11, include auto0 in access path.
- set i [safe::interpCreate -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0] \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]]
+ # For complete correspondence to safe-stock-9.11, include auto0 in access path.
+ set i [safe::interpCreate -accessPath [list $tcl_library [file join $ZipMountPoint auto0] [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]]
# Inspect.
set confA [safe::interpConfigure $i]
set mappA [mapList $PathMapp [dict get $confA -accessPath]]
@@ -320,10 +347,7 @@ apply [list {} {
# Rearrange access path. Swap tokens {$p(:2:)} and {$p(:3:)}.
# This would have no effect because the records in Pkg of these directories
# were from access as children of {$p(:1:)}.
- safe::interpConfigure $i -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0] \
- [file join $ZipMountPoint auto0 auto2] \
- [file join $ZipMountPoint auto0 auto1]]
+ safe::interpConfigure $i -accessPath [list $tcl_library [file join $ZipMountPoint auto0] [file join $ZipMountPoint auto0 auto2] [file join $ZipMountPoint auto0 auto1]]
# Inspect.
set confB [safe::interpConfigure $i]
set mappB [mapList $PathMapp [dict get $confB -accessPath]]
@@ -336,19 +360,21 @@ apply [list {} {
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 -- \
- $mappA -- $mappB -- $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 --\
- {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\
- {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} --\
- 0 OK1 0 OK2}
- test safe-zipfs-9.12 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0; zipfs} -setup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result {{$p(:2:)} {$p(:3:)} -- {$p(:3:)} {$p(:2:)} -- 0 1.2.3 0 2.3.4 -- {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB ZIPDIR/auto0 ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} -- 0 OK1 0 OK2}
+ test safe-zipfs-9.12 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0 with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
- set i [safe::interpCreate -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]]
+ set i [safe::interpCreate -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]]
# Inspect.
set confA [safe::interpConfigure $i]
set mappA [mapList $PathMapp [dict get $confA -accessPath]]
@@ -359,9 +385,7 @@ apply [list {} {
catch {interp eval $i {package require NOEXIST}}
# Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}.
- safe::interpConfigure $i -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto2] \
- [file join $ZipMountPoint auto0 auto1]]
+ safe::interpConfigure $i -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto2] [file join $ZipMountPoint auto0 auto1]]
# Inspect.
set confB [safe::interpConfigure $i]
set mappB [mapList $PathMapp [dict get $confB -accessPath]]
@@ -374,20 +398,21 @@ apply [list {} {
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 -- \
- $mappA -- $mappB -- $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(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} --\
- 0 1.2.3 0 2.3.4 --\
- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} --\
- {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} --\
- 0 OK1 0 OK2}
- test safe-zipfs-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed; zipfs} -setup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:2:)} {$p(:1:)} -- 0 1.2.3 0 2.3.4 -- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB ZIPDIR/auto0/auto2 ZIPDIR/auto0/auto1*} -- 0 OK1 0 OK2}
+ test safe-zipfs-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
- set i [safe::interpCreate -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]]
+ set i [safe::interpCreate -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]]
# Inspect.
set confA [safe::interpConfigure $i]
set mappA [mapList $PathMapp [dict get $confA -accessPath]]
@@ -410,14 +435,19 @@ apply [list {} {
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 $code6 -- \
- $mappA -- $mappB
+ 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 --\
- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB*}}
- test safe-zipfs-9.20 {check module loading; zipfs} -setup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result {{$p(:1:)} {$p(:2:)} -- 1 {* not found in access path} -- 1 {* not found in access path} -- 1 1 -- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2*} -- {TCLLIB*}}
+ test safe-zipfs-9.20 {check module loading, with conventional AutoPathSync; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -442,18 +472,17 @@ apply [list {} {
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list [lsort [list $path0 $path1 $path2]] -- $modsA -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $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 $ZipMountPoint 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:)}} --\
- 0 0.5 0 1.0 0 2.0 --\
- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\
- ZIPDIR/auto0/modules/mod2} -- res0 res1 res2}
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} -- 0 0.5 0 1.0 0 2.0 -- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- res0 res1 res2}
# - The command safe::InterpSetConfig adds the parent's [tcl::tm::list] in
# tokenized form to the child's access path, and then adds all the
# descendants, discovered recursively by using glob.
@@ -463,7 +492,12 @@ apply [list {} {
# 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-zipfs-9.21 {interpConfigure change the access path; check module loading; stale data case 1; zipfs} -setup {
+ test safe-zipfs-9.21 {interpConfigure change the access path; check module loading, with conventional AutoPathSync; stale data case 1; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -482,9 +516,7 @@ apply [list {} {
# Add to access path.
# This injects more tokens, pushing modules to higher token numbers.
- safe::interpConfigure $i -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]
+ safe::interpConfigure $i -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]
# Inspect.
set confB [safe::interpConfigure $i]
set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]]
@@ -506,26 +538,24 @@ apply [list {} {
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list [lsort [list $path0 $path1 $path2]] -- $modsA -- \
- [lsort [list $path3 $path4 $path5]] -- $modsB -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \
- $out0 $out1 $out2
+ 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 $ZipMountPoint 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:)}} --\
- {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\
- 0 0.5 0 1.0 0 2.0 --\
- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\
- ZIPDIR/auto0/modules/mod2} --\
- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\
- ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\
- res0 res1 res2}
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -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 -- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- res0 res1 res2}
# See comments on lsort after test safe-zipfs-9.20.
- test safe-zipfs-9.22 {interpConfigure change the access path; check module loading; stale data case 0; zipfs} -setup {
+ test safe-zipfs-9.22 {interpConfigure change the access path; check module loading, with conventional AutoPathSync; stale data case 0; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -544,9 +574,7 @@ apply [list {} {
# Add to access path.
# This injects more tokens, pushing modules to higher token numbers.
- safe::interpConfigure $i -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]
+ safe::interpConfigure $i -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]
# Inspect.
set confB [safe::interpConfigure $i]
set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]]
@@ -563,26 +591,24 @@ apply [list {} {
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list [lsort [list $path0 $path1 $path2]] -- $modsA -- \
- [lsort [list $path3 $path4 $path5]] -- $modsB -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \
- $out0 $out1 $out2
+ 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 $ZipMountPoint 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:)}} --\
- {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\
- 0 0.5 0 1.0 0 2.0 --\
- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\
- ZIPDIR/auto0/modules/mod2} --\
- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\
- ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\
- res0 res1 res2}
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -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 -- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- res0 res1 res2}
# See comments on lsort after test safe-zipfs-9.20.
- test safe-zipfs-9.23 {interpConfigure change the access path; check module loading; stale data case 3; zipfs} -setup {
+ test safe-zipfs-9.23 {interpConfigure change the access path; check module loading, with conventional AutoPathSync; stale data case 3; zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -606,9 +632,7 @@ apply [list {} {
# Add to access path.
# This injects more tokens, pushing modules to higher token numbers.
- safe::interpConfigure $i -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]
+ safe::interpConfigure $i -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]
# Inspect.
set confB [safe::interpConfigure $i]
set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]]
@@ -630,26 +654,24 @@ apply [list {} {
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list [lsort [list $path0 $path1 $path2]] -- $modsA -- \
- [lsort [list $path3 $path4 $path5]] -- $modsB -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \
- $out0 $out1 $out2
+ 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 $ZipMountPoint 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:)}} --\
- {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\
- 0 0.5 0 1.0 0 2.0 --\
- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\
- ZIPDIR/auto0/modules/mod2} --\
- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\
- ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\
- res0 res1 res2}
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -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 -- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- res0 res1 res2}
# See comments on lsort after test safe-zipfs-9.20.
- test safe-zipfs-9.24 {interpConfigure change the access path; check module loading; stale data case 2 (worst case); zipfs} -setup {
+ test safe-zipfs-9.24 {interpConfigure change the access path; check module loading, with conventional AutoPathSync; stale data case 2 (worst case); zipfs} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -673,9 +695,7 @@ apply [list {} {
# Add to access path.
# This injects more tokens, pushing modules to higher token numbers.
- safe::interpConfigure $i -accessPath [list $tcl_library \
- [file join $ZipMountPoint auto0 auto1] \
- [file join $ZipMountPoint auto0 auto2]]
+ safe::interpConfigure $i -accessPath [list $tcl_library [file join $ZipMountPoint auto0 auto1] [file join $ZipMountPoint auto0 auto2]]
# Inspect.
set confB [safe::interpConfigure $i]
set sortB [mapAndSortList $PathMapp [dict get $confB -accessPath]]
@@ -692,26 +712,116 @@ apply [list {} {
set out1 [interp eval $i {mod1::test1::try1}]
set out2 [interp eval $i {mod2::test2::try2}]
- list [lsort [list $path0 $path1 $path2]] -- $modsA -- \
- [lsort [list $path3 $path4 $path5]] -- $modsB -- \
- $code0 $msg0 $code1 $msg1 $code2 $msg2 -- $sortA -- $sortB -- \
- $out0 $out1 $out2
+ 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 $ZipMountPoint 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:)}} --\
- {{$p(:3:)} {$p(:4:)} {$p(:5:)}} -- {{$p(:3:)}} --\
- 0 0.5 0 1.0 0 2.0 --\
- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1\
- ZIPDIR/auto0/modules/mod2} --\
- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules\
- ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} --\
- res0 res1 res2}
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -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 -- {TCLLIB ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- {TCLLIB ZIPDIR/auto0/auto1 ZIPDIR/auto0/auto2 ZIPDIR/auto0/modules ZIPDIR/auto0/modules/mod1 ZIPDIR/auto0/modules/mod2} -- res0 res1 res2}
# See comments on lsort after test safe-zipfs-9.20.
-
+
+ test safe-zipfs-18.1 {cf. safe-zipfs-7.1 - tests that everything works at high level without conventional AutoPathSync; zipfs} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ # Without AutoPathSync, we need a more complete auto_path,
+ # because the child will use the same value.
+ set lib1 [info library]
+ set lib2 [file join $ZipMountPoint auto0]
+ set ::auto_TMP $::auto_path
+ set ::auto_path [list $lib1 $lib2]
+
+ set i [safe::interpCreate]
+ set ::auto_path $::auto_TMP
+ } -body {
+ # no error shall occur:
+ # (because the default access_path shall include 1st level sub dirs so
+ # package require in a child works like in the parent)
+ set v [interp eval $i {package require SafeTestPackage1}]
+ # no error shall occur:
+ interp eval $i HeresPackage1
+ set v
+ } -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result 1.2.3
+ test safe-zipfs-18.2 {cf. safe-zipfs-7.2 - tests specific path and interpFind/AddToAccessPath without conventional AutoPathSync; zipfs} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ } -body {
+ set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
+ set auto1 [interp eval $i {set ::auto_path}]
+ interp eval $i {set ::auto_path [list {$p(:0:)}]}
+ # should not add anything (p0)
+ set token1 [safe::interpAddToAccessPath $i [info library]]
+ # should add as p* (not p1 if parent has a module path)
+ set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"]
+ # should add as p* (not p2 if parent has a module path)
+ set token3 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0]]
+ # an error shall occur (SafeTestPackage1 is not anymore in the secure 0-level
+ # provided deep path)
+ list $auto1 $token1 $token2 $token3 [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg [safe::interpConfigure $i] [safe::interpDelete $i]
+ } -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result "{} {\$p(:0:)} {\$p(:*:)} {\$p(:*:)} 1 {can't find package SafeTestPackage1} {-accessPath {[list $tcl_library */dummy/unixlike/test/path $ZipMountPoint/auto0]} -statics 0 -nested 1 -deleteHook {} -autoPath {}} {}"
+ test safe-zipfs-18.4 {cf. safe-zipfs-7.4 - tests specific path and positive search and auto_path without conventional AutoPathSync; zipfs} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ } -body {
+ set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
+
+ # should not have been set by Safe Base:
+ set auto1 [interp eval $i {set ::auto_path}]
+
+ # This will differ from the value -autoPath {}
+ interp eval $i {set ::auto_path [list {$p(:0:)}]}
+
+ # should not add anything (p0)
+ set token1 [safe::interpAddToAccessPath $i [info library]]
+
+ # should add as p* (not p1 if parent has a module path)
+ set token2 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0]]
+
+ # should add as p* (not p2 if parent has a module path)
+ set token3 [safe::interpAddToAccessPath $i [file join $ZipMountPoint auto0 auto1]]
+
+ # should not have been changed by Safe Base:
+ set auto2 [interp eval $i {set ::auto_path}]
+
+ # This will differ from the value -autoPath {}
+ set auto3 [interp eval $i [list set ::auto_path [list {$p(:0:)} $token2]]]
+
+ # This time, unlike test safe-zipfs-18.2 and the try above, SafeTestPackage1 should be found:
+ list $auto1 $auto2 $token1 $token2 $token3 [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg [safe::interpConfigure $i] [safe::interpDelete $i]
+ } -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+ } -match glob -result "{} {{\$p(:0:)}} {\$p(:0:)} {\$p(:*:)} {\$p(:*:)} 0 1.2.3 {-accessPath {[list $tcl_library *$ZipMountPoint/auto0 $ZipMountPoint/auto0/auto1]} -statics 0 -nested 1 -deleteHook {} -autoPath {}} {}"
+
# cleanup
set ::auto_path $SaveAutoPath
zipfs unmount ${ZipMountPoint}
diff --git a/tests/safe.test b/tests/safe.test
index 148215a..e5d4d18 100644
--- a/tests/safe.test
+++ b/tests/safe.test
@@ -8,7 +8,7 @@
# - Tests that used http are replaced here with tests that use example packages
# provided in subdirectory auto0 of the tests directory, which are independent
# of any changes made to the packages provided with Tcl itself.
-# - These are tests 7.1 7.2 7.4 9.11 9.13
+# - These are tests 7.1 7.2 7.4 9.11 9.13 17.1 17.2 17.4
# - Tests 5.* test the example packages themselves before they
# are used to test Safe Base interpreters.
# - Alternative tests using stock packages of Tcl 8.7 are in file
@@ -36,6 +36,11 @@ set ::auto_path [info library]
set TestsDir [file normalize [file dirname [info script]]]
set PathMapp [list $tcl_library TCLLIB $TestsDir TESTSDIR]
+proc getAutoPath {child} {
+ set ap1 [lrange [lindex [safe::interpConfigure $child -autoPath] 1] 0 end]
+ set ap2 [::safe::DetokPath $child [interp eval $child set ::auto_path]]
+ list $ap1 -- $ap2
+}
proc mapList {map listIn} {
set listOut {}
foreach element $listIn {
@@ -59,13 +64,28 @@ catch {safe::interpConfigure}
# package - tcl::test - but it might be absent if we're in standard tclsh)
testConstraint tcl::test [expr {![catch {package require tcl::test}]}]
+testConstraint AutoSyncDefined 1
+### 1. Basic help/error messages.
+
test safe-1.1 {safe::interpConfigure syntax} -returnCodes error -body {
safe::interpConfigure
} -result {no value given for parameter "child" (use -help for full usage) :
child name () name of the child}
-test safe-1.2 {safe::interpCreate syntax} -returnCodes error -body {
+test safe-1.2 {safe::interpCreate syntax, Sync Mode on} -returnCodes error -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ } else {
+ set SyncVal_TMP 1
+ }
+} -body {
safe::interpCreate -help
+} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -result {Usage information:
Var/FlagName Type Value Help
------------ ---- ----- ----
@@ -77,11 +97,39 @@ test safe-1.2 {safe::interpCreate syntax} -returnCodes error -body {
-nestedLoadOk boolflag (false) allow nested loading
-nested boolean (false) nested loading
-deleteHook script () delete hook}
+test safe-1.2.1 {safe::interpCreate syntax, Sync Mode off} -returnCodes error -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ safe::interpCreate -help
+} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {Usage information:
+ Var/FlagName Type Value Help
+ ------------ ---- ----- ----
+ (-help gives this help)
+ ?child? name () name of the child (optional)
+ -accessPath list () access path for the child
+ -noStatics boolflag (false) prevent loading of statically linked pkgs
+ -statics boolean (true) loading of statically linked pkgs
+ -nestedLoadOk boolflag (false) allow nested loading
+ -nested boolean (false) nested loading
+ -deleteHook script () delete hook
+ -autoPath list () ::auto_path for the child}
test safe-1.3 {safe::interpInit syntax} -returnCodes error -body {
safe::interpInit -noStatics
} -result {bad value "-noStatics" for parameter
child name () name of the child}
+### 2. Aliases in a new "interp create" interpreter.
+
test safe-2.1 {creating interpreters, should have no aliases} emptyTest {
# Disabled this test. It tests nothing sensible. [Bug 999612]
# interp aliases
@@ -105,6 +153,9 @@ test safe-2.3 {creating safe interpreters, should have no unexpected aliases} -s
interp delete a
} -result {clock}
+### 3. Simple use of interpCreate, interpInit.
+### Aliases in a new "interpCreate/interpInit" interpreter.
+
test safe-3.1 {calling safe::interpInit is safe} -setup {
catch {safe::interpDelete a}
interp create a -safe
@@ -139,6 +190,8 @@ test safe-3.4 {calling safe::interpCreate on trusted interp} -setup {
safe::interpDelete a
} -result {}
+### 4. Testing safe::interpDelete, double interpCreate.
+
test safe-4.1 {safe::interpDelete} -setup {
catch {safe::interpDelete a}
} -body {
@@ -171,9 +224,9 @@ test safe-4.6 {safe::interpDelete, indirectly} -setup {
a eval exit
} -result ""
-# The old test "safe-5.1" has been moved to "safe-stock-9.8".
-# A replacement test using example files is "safe-9.8".
-# Tests 5.* test the example files before using them to test safe interpreters.
+### 5. Test the example files before using them to test safe interpreters.
+### The old test "safe-5.1" has been moved to "safe-stock-9.8".
+### A replacement test using example files is "safe-9.8".
unset -nocomplain path
@@ -286,7 +339,8 @@ test safe-5.6 {example modules packages, test in parent interpreter, append to p
catch {namespace delete ::mod1}
} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2}
-# test safe interps 'information leak'
+### 6. Test safe interps 'information leak'.
+
proc SafeEval {script} {
# Helper procedure that ensures the safe interp is cleaned up even if
# there is a failure in the script.
@@ -316,9 +370,16 @@ rename SafeEval {}
# More test should be added to check that hostname, nameofexecutable, aren't
# leaking infos, but they still do...
-# high level general test
-# Use example packages not http1.0 etc
-test safe-7.1 {tests that everything works at high level} -setup {
+### 7. Test the use of ::auto_path for loading commands (via tclIndex files)
+### and non-module packages (via pkgIndex.tcl files).
+### Corresponding tests with Sync Mode off are 17.*
+
+test safe-7.1 {positive non-module package require, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set tmpAutoPath $::auto_path
lappend ::auto_path [file join $TestsDir auto0]
set i [safe::interpCreate]
@@ -333,8 +394,18 @@ test safe-7.1 {tests that everything works at high level} -setup {
set v
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result 1.2.3
-test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup {
+test safe-7.2 {negative non-module package require with specific path and interpAddToAccessPath, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ } else {
+ set SyncVal_TMP 1
+ }
} -body {
set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
# should not add anything (p0)
@@ -345,12 +416,14 @@ test safe-7.2 {tests specific path and interpFind/AddToAccessPath} -setup {
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)
+ # an error shall occur (SafeTestPackage1 is not in auto0 but a subdirectory)
list $token1 $token2 $token3 -- \
[catch {interp eval $i {package require SafeTestPackage1}} msg] $msg -- \
$mappA -- [safe::interpDelete $i]
} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result {{$p(:0:)} {$p(:*:)} {$p(:*:)} --\
1 {can't find package SafeTestPackage1} --\
{TCLLIB */dummy/unixlike/test/path TESTSDIR/auto0} -- {}}
@@ -385,7 +458,14 @@ test safe-7.3.1 {check that safe subinterpreters work with namespace names} -set
[safe::interpDelete $i] \
[interp exists $j] [info vars ::safe::S*]
} -match glob -result {{} {} ok ok {} 0 {}}
-test safe-7.4 {tests specific path and positive search} -setup {
+test safe-7.4 {positive non-module package require with specific path and interpAddToAccessPath, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ } else {
+ set SyncVal_TMP 1
+ }
} -body {
set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
# should not add anything (p0)
@@ -401,10 +481,39 @@ test safe-7.4 {tests specific path and positive search} -setup {
# Note that the glob match elides directories (those from the module path)
# other than the first and last in the access path.
} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\
{TCLLIB * TESTSDIR/auto0/auto1} -- {}}
+test safe-7.5 {positive and negative module package require, including ancestor directory issue, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
+ tcl::tm::path add [file join $TestsDir auto0 modules]
+ set i [safe::interpCreate]
+ tcl::tm::path remove [file join $TestsDir auto0 modules]
+ interp eval $i {
+ package forget mod1::test1
+ catch {namespace delete ::mod1}
+ }
+} -body {
+ # Should raise an error (module ancestor directory issue)
+ set code1 [catch {interp eval $i {package require test1}} msg1]
+ # Should not raise an error
+ set code2 [catch {interp eval $i {package require mod1::test1}} msg2]
+ return [list $code1 $msg1 $code2]
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {1 {can't find package test1} 0}
+
+### 8. Test source control on file name.
-# test source control on file name
test safe-8.1 {safe source control on file} -setup {
set i "a"
catch {safe::interpDelete $i}
@@ -549,6 +658,9 @@ test safe-8.10 {safe source and return} -setup {
unset i
} -result ok
+### 9. Assorted options, including changes to option values.
+### If Sync Mode is on, a corresponding test with Sync Mode off is 19.*
+
test safe-9.1 {safe interps' deleteHook} -setup {
set i "a"
catch {safe::interpDelete $i}
@@ -651,7 +763,12 @@ test safe-9.7 {interpConfigure widget like behaviour (demystified)} -body {
{-accessPath *} {-nested 1} {-statics 0} {-deleteHook {foo bar}}\
{-accessPath * -statics 1 -nested 1 -deleteHook {foo bar}}\
{-accessPath * -statics 0 -nested 0 -deleteHook toto}}
-test safe-9.8 {test autoloading commands indexed in tclIndex files} -setup {
+test safe-9.8 {autoloading commands indexed in tclIndex files, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $TestsDir auto0 auto1] \
@@ -669,9 +786,17 @@ test safe-9.8 {test autoloading commands indexed in tclIndex files} -setup {
list $path1 $path2 -- $code1 $msg1 $code2 $msg2 -- $mappA
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result {{$p(:1:)} {$p(:2:)} -- 0 ok1 0 ok2 --\
{TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*}}
-test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset)} -setup {
+test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset), Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $TestsDir auto0 auto1] \
@@ -707,10 +832,18 @@ test safe-9.9 {interpConfigure change the access path; tclIndex commands unaffec
list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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; tclIndex commands unaffected by token rearrangement (actual test of doreset)} -setup {
+test safe-9.10 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset), Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $TestsDir auto0 auto1] \
@@ -744,11 +877,19 @@ test safe-9.10 {interpConfigure change the access path; tclIndex commands unaffe
list $path1 $path2 -- $path3 $path4 -- $code3 $msg3 $code4 $msg4 -- $mappA -- $mappB
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement} -setup {
+test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
# For complete correspondence to safe-9.10opt, include auto0 in access path.
set i [safe::interpCreate -accessPath [list $tcl_library \
@@ -788,11 +929,19 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un
$mappA -- $mappB -- $code5 $msg5 $code6 $msg6
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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.12 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, 9.10 without path auto0} -setup {
+test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, safe-9.11 without path auto0, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $TestsDir auto0 auto1] \
@@ -827,12 +976,20 @@ test safe-9.12 {interpConfigure change the access path; pkgIndex.tcl packages un
$code5 $msg5 $code6 $msg6
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed} -setup {
+test safe-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
} -body {
set i [safe::interpCreate -accessPath [list $tcl_library \
[file join $TestsDir auto0 auto1] \
@@ -863,10 +1020,18 @@ test safe-9.13 {interpConfigure change the access path; pkgIndex.tcl packages fa
$mappA -- $mappB
} -cleanup {
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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 {
+test safe-9.20 {check module loading, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -899,6 +1064,9 @@ test safe-9.20 {check module loading} -setup {
tcl::tm::path add $path
}
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\
0 0.5 0 1.0 0 2.0 --\
{TCLLIB TESTSDIR/auto0/modules TESTSDIR/auto0/modules/mod1\
@@ -912,7 +1080,12 @@ test safe-9.20 {check module loading} -setup {
# 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 {
+test safe-9.21 {interpConfigure change the access path; check module loading, Sync Mode on; stale data case 1} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -965,6 +1138,9 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st
tcl::tm::path add $path
}
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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 --\
@@ -974,7 +1150,12 @@ test safe-9.21 {interpConfigure change the access path; check module loading; st
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 {
+test safe-9.22 {interpConfigure change the access path; check module loading, Sync Mode on; stale data case 0} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -1022,6 +1203,9 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st
tcl::tm::path add $path
}
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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 --\
@@ -1031,7 +1215,12 @@ test safe-9.22 {interpConfigure change the access path; check module loading; st
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 {
+test safe-9.23 {interpConfigure change the access path; check module loading, Sync Mode on; stale data case 3} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -1089,6 +1278,9 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st
tcl::tm::path add $path
}
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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 --\
@@ -1098,7 +1290,12 @@ test safe-9.23 {interpConfigure change the access path; check module loading; st
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 {
+test safe-9.24 {interpConfigure change the access path; check module loading, Sync Mode on; stale data case 2 (worst case)} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
set oldTm [tcl::tm::path list]
foreach path $oldTm {
tcl::tm::path remove $path
@@ -1151,6 +1348,9 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st
tcl::tm::path add $path
}
safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
} -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 --\
@@ -1161,6 +1361,8 @@ test safe-9.24 {interpConfigure change the access path; check module loading; st
res0 res1 res2}
# See comments on lsort after test safe-9.20.
+### 10. Test options -statics -nostatics -nested -nestedloadok
+
catch {teststaticlibrary Safepfx1 0 0}
test safe-10.1 {testing statics loading} -constraints tcl::test -setup {
set i [safe::interpCreate]
@@ -1214,6 +1416,8 @@ test safe-10.4.1 {testing nested statics loading / -nestedloadok} -constraints t
invoked from within
"interp eval $i {interp create x; load {} Safepfx1 x}"}
+### 11. Safe encoding.
+
test safe-11.1 {testing safe encoding} -setup {
set i [safe::interpCreate]
} -body {
@@ -1308,6 +1512,9 @@ test safe-11.8.1 {testing safe encoding} -setup {
invoked from within
"interp eval $i encoding convertto"}
+### 12. Safe glob.
+### More tests of glob in sections 13, 16.
+
test safe-12.1 {glob is restricted [Bug 2906841]} -setup {
set i [safe::interpCreate]
} -body {
@@ -1358,6 +1565,9 @@ test safe-12.7 {glob is restricted} -setup {
safe::interpDelete $i
} -result {permission denied}
+### 13. More tests for Safe base glob, with patches @ Bug 2964715
+### More tests of glob in sections 12, 16.
+
proc buildEnvironment {filename} {
upvar 1 testdir testdir testdir2 testdir2 testfile testfile
set testdir [makeDirectory deletethisdir]
@@ -1373,7 +1583,7 @@ proc buildEnvironment2 {filename} {
set testdir3 [makeDirectory deleteme $testdir]
set testfile2 [makeFile {} $filename $testdir3]
}
-#### New tests for Safe base glob, with patches @ Bug 2964715
+
test safe-13.1 {glob is restricted [Bug 2964715]} -setup {
set i [safe::interpCreate]
} -body {
@@ -1510,7 +1720,8 @@ test safe-13.10 {as 13.8 but test silent failure when result is outside access_p
rename buildEnvironment {}
rename buildEnvironment2 {}
-#### Test for the module path
+### 14. Sanity checks on paths - module path, access path, auto_path.
+
test safe-14.1 {Check that module path is the same as in the parent interpreter [Bug 2964715]} -setup {
set i [safe::interpCreate]
} -body {
@@ -1522,6 +1733,122 @@ test safe-14.1 {Check that module path is the same as in the parent interpreter
} -cleanup {
safe::interpDelete $i
} -result [::tcl::tm::path list]
+test safe-14.2 {Check that first element of child auto_path (and access path) is Tcl Library, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
+
+ set lib1 [info library]
+ set lib2 [file dirname $lib1]
+ set ::auto_TMP $::auto_path
+ set ::auto_path [list $lib1 $lib2]
+
+ set i [safe::interpCreate]
+} -body {
+ set autoList {}
+ set token [lindex [$i eval set ::auto_path] 0]
+ set auto0 [dict get [set ::safe::S${i}(access_path,map)] $token]
+ set accessList [lindex [safe::interpConfigure $i -accessPath] 1]
+ return [list [lindex $accessList 0] $auto0]
+} -cleanup {
+ set ::auto_path $::auto_TMP
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [info library] [info library]]
+test safe-14.2.1 {Check that first element of child auto_path (and access path) is Tcl Library, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+
+ set lib1 [info library]
+ set lib2 [file dirname $lib1]
+ set ::auto_TMP $::auto_path
+ set ::auto_path [list $lib1 $lib2]
+
+ set i [safe::interpCreate]
+} -body {
+ set autoList {}
+ set token [lindex [$i eval set ::auto_path] 0]
+ set auto0 [dict get [set ::safe::S${i}(access_path,map)] $token]
+ set accessList [lindex [safe::interpConfigure $i -accessPath] 1]
+ set autoList [lindex [safe::interpConfigure $i -autoPath] 1]
+ return [list [lindex $accessList 0] [lindex $autoList 0] $auto0]
+} -cleanup {
+ set ::auto_path $::auto_TMP
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [info library] [info library] [info library]]
+test safe-14.3 {Check that first element of child auto_path (and access path) is Tcl Library, even if not true for parent, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
+
+ set lib1 [info library]
+ set lib2 [file dirname $lib1]
+ set ::auto_TMP $::auto_path
+ set ::auto_path [list $lib2 $lib1]
+ # Unexpected order, should be reversed in the child
+
+ set i [safe::interpCreate]
+} -body {
+ set autoList {}
+ set token [lindex [$i eval set ::auto_path] 0]
+ set auto0 [dict get [set ::safe::S${i}(access_path,map)] $token]
+ set accessList [lindex [safe::interpConfigure $i -accessPath] 1]
+
+ return [list [lindex $accessList 0] $auto0]
+} -cleanup {
+ set ::auto_path $::auto_TMP
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [info library] [info library]]
+test safe-14.3.1 {Check that first element of child auto_path (and access path) is Tcl Library, even if not true for parent, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+
+ set lib1 [info library]
+ set lib2 [file dirname $lib1]
+ set ::auto_TMP $::auto_path
+ set ::auto_path [list $lib2 $lib1]
+ # Unexpected order, should be reversed in the child
+
+ set i [safe::interpCreate]
+} -body {
+ set autoList {}
+ set token [lindex [$i eval set ::auto_path] 0]
+ set auto0 [dict get [set ::safe::S${i}(access_path,map)] $token]
+ set accessList [lindex [safe::interpConfigure $i -accessPath] 1]
+ set autoList [lindex [safe::interpConfigure $i -autoPath] 1]
+
+ return [list [lindex $accessList 0] [lindex $autoList 0] $auto0]
+} -cleanup {
+ set ::auto_path $::auto_TMP
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [info library] [info library] [info library]]
+
+### 15. Safe file ensemble.
test safe-15.1 {safe file ensemble does not surprise code} -setup {
set i [interp create -safe]
@@ -1560,7 +1887,10 @@ test safe-15.2 {safe file ensemble does not surprise code} -setup {
invoked from within
"interp eval $i {file isdirectory .}"}}
-### ~ should have no special meaning in paths in safe interpreters
+### 16. ~ should have no special meaning in paths in safe interpreters.
+### Defang it in glob.
+### More tests of glob in sections 12, 13.
+
test safe-16.1 {Bug 3529949: defang ~ in paths} -setup {
set savedHOME $env(HOME)
set env(HOME) /foo/bar
@@ -1654,10 +1984,1576 @@ test safe-16.8 {Bug 3529949: defang ~user in paths used by AliasGlob (2)} -setup
safe::interpDelete $i
unset user
} -result {~USER}
+
+### 17. Test the use of ::auto_path for loading commands (via tclIndex files)
+### and non-module packages (via pkgIndex.tcl files).
+### Corresponding tests with Sync Mode on are 7.*
+
+test safe-17.1 {cf. safe-7.1 - positive non-module package require, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ # Without AutoPathSync, we need a more complete auto_path,
+ # because the child will use the same value.
+ set lib1 [info library]
+ set lib2 [file join $TestsDir auto0]
+ set ::auto_TMP $::auto_path
+ set ::auto_path [list $lib1 $lib2]
+
+ set i [safe::interpCreate]
+ set ::auto_path $::auto_TMP
+} -body {
+ # no error shall occur:
+ # (because the default access_path shall include 1st level sub dirs so
+ # package require in a child works like in the parent)
+ set v [interp eval $i {package require SafeTestPackage1}]
+ # no error shall occur:
+ interp eval $i HeresPackage1
+ set v
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result 1.2.3
+test safe-17.2 {cf. safe-7.2 - negative non-module package require with specific path and interpAddToAccessPath, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
+ # should not have been set by Safe Base:
+ set auto1 [interp eval $i {set ::auto_path}]
+ # This does not change the value of option -autoPath:
+ interp eval $i {set ::auto_path [list {$p(:0:)}]}
+ # should not add anything (p0)
+ set token1 [safe::interpAddToAccessPath $i [info library]]
+ # should add as p* (not p1 if parent has a module path)
+ set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"]
+ # should add as p* (not p2 if parent has a module path)
+ set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]]
+ # an error shall occur (SafeTestPackage1 is not in auto0 but a subdirectory)
+ list $auto1 $token1 $token2 $token3 \
+ [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \
+ [safe::interpConfigure $i]\
+ [safe::interpDelete $i]
+} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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 {} -autoPath {}} {}"
+# (not a counterpart of safe-7.3)
+test safe-17.3 {Check that default auto_path is the same as in the parent interpreter, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate]
+} -body {
+ # This file's header sets auto_path to a single directory [info library],
+ # which is the one required by Safe Base to be present & first in the list.
+ set ap {}
+ foreach token [$i eval set ::auto_path] {
+ lappend ap [dict get [set ::safe::S${i}(access_path,map)] $token]
+ }
+ return [list $ap [lindex [::safe::interpConfigure $i -autoPath] 1]]
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list $::auto_path $::auto_path]
+test safe-17.4 {cf. safe-7.4 - positive non-module package require with specific path and interpAddToAccessPath, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]]
+
+ # should not have been set by Safe Base:
+ set auto1 [interp eval $i {set ::auto_path}]
+
+ # This does not change the value of option -autoPath.
+ interp eval $i {set ::auto_path [list {$p(:0:)}]}
+
+ # should not add anything (p0)
+ set token1 [safe::interpAddToAccessPath $i [info library]]
+
+ # should add as p* (not p1 if parent has a module path)
+ set token2 [safe::interpAddToAccessPath $i [file join $TestsDir auto0]]
+
+ # should add as p* (not p2 if parent has a module path)
+ set token3 [safe::interpAddToAccessPath $i [file join $TestsDir auto0 auto1]]
+
+ # should not have been changed by Safe Base:
+ set auto2 [interp eval $i {set ::auto_path}]
+
+ set auto3 [interp eval $i [list set ::auto_path [list {$p(:0:)} $token2]]]
+
+ # This time, unlike test safe-17.2 and the try above, SafeTestPackage1 should be found:
+ list $auto1 $auto2 $token1 $token2 $token3 \
+ [catch {interp eval $i {package require SafeTestPackage1}} msg] $msg \
+ [safe::interpConfigure $i]\
+ [safe::interpDelete $i]
+} -cleanup {
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result "{} {{\$p(:0:)}} {\$p(:0:)} {\$p(:*:)} {\$p(:*:)} 0 1.2.3\
+ {-accessPath {[list $tcl_library *$TestsDir/auto0 $TestsDir/auto0/auto1]}\
+ -statics 0 -nested 1 -deleteHook {}\
+ -autoPath {}} {}"
+test safe-17.5 {cf. safe-7.5 - positive and negative module package require, including ancestor directory issue, Sync Mode off} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ tcl::tm::path add [file join $TestsDir auto0 modules]
+ set i [safe::interpCreate]
+ tcl::tm::path remove [file join $TestsDir auto0 modules]
+ interp eval $i {
+ package forget mod1::test1
+ catch {namespace delete ::mod1}
+ }
+} -body {
+ # Should raise an error (tests module ancestor directory rule)
+ set code1 [catch {interp eval $i {package require test1}} msg1]
+ # Should not raise an error
+ set code2 [catch {interp eval $i {package require mod1::test1}} msg2]
+ return [list $code1 $msg1 $code2]
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {1 {can't find package test1} 0}
+
+### 18. Test tokenization of directories available to a child.
+
+test safe-18.1 {Check that each directory of the default auto_path is a valid token, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
+ set i [safe::interpCreate]
+} -body {
+ set badTokens {}
+ foreach dir [$i eval {set ::auto_path}] {
+ if {[regexp {^\$p\(:[0-9]+:\)$} $dir]} {
+ # Match - OK - token has expected form
+ } else {
+ # No match - possibly an ordinary path has not been tokenized
+ lappend badTokens $dir
+ }
+ }
+ set badTokens
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {}
+test safe-18.1.1 {Check that each directory of the default auto_path is a valid token, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate]
+} -body {
+ set badTokens {}
+ foreach dir [$i eval {set ::auto_path}] {
+ if {[regexp {^\$p\(:[0-9]+:\)$} $dir]} {
+ # Match - OK - token has expected form
+ } else {
+ # No match - possibly an ordinary path has not been tokenized
+ lappend badTokens $dir
+ }
+ }
+ set badTokens
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {}
+test safe-18.2 {Check that each directory of the module path is a valid token, Sync Mode on} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 1
+ }
+ set i [safe::interpCreate]
+} -body {
+ set badTokens {}
+ foreach dir [$i eval {::tcl::tm::path list}] {
+ if {[regexp {^\$p\(:[0-9]+:\)$} $dir]} {
+ # Match - OK - token has expected form
+ } else {
+ # No match - possibly an ordinary path has not been tokenized
+ lappend badTokens $dir
+ }
+ }
+ set badTokens
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {}
+test safe-18.2.1 {Check that each directory of the module path is a valid token, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate]
+} -body {
+ set badTokens {}
+ foreach dir [$i eval {::tcl::tm::path list}] {
+ if {[regexp {^\$p\(:[0-9]+:\)$} $dir]} {
+ # Match - OK - token has expected form
+ } else {
+ # No match - possibly an ordinary path has not been tokenized
+ lappend badTokens $dir
+ }
+ }
+ set badTokens
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {}
+
+### 19. Assorted options, including changes to option values.
+### Mostly these are changes to access path, auto_path, module path.
+### If Sync Mode is on, a corresponding test with Sync Mode off is 9.*
+
+test safe-19.8 {autoloading commands indexed in tclIndex files, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]] \
+ -autoPath [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]]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load and run the commands.
+ set code1 [catch {interp eval $i {report1}} msg1]
+ set code2 [catch {interp eval $i {report2}} msg2]
+
+ list $path1 $path2 -- $code1 $msg1 $code2 $msg2 -- $mappA -- $mappC -- $toksC
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result {{$p(:1:)} {$p(:2:)} -- 0 ok1 0 ok2 --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {{$p(:0:)} {$p(:1:)} {$p(:2:)}}}
+test safe-19.9 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (dummy test of doreset), Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]] \
+ -autoPath [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]]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load auto_load data.
+ interp eval $i {catch nonExistentCommand}
+
+ # Load and run the commands.
+ # This guarantees the test will pass even if the tokens are swapped.
+ set code1 [catch {interp eval $i {report1}} msg1]
+ set code2 [catch {interp eval $i {report2}} msg2]
+
+ # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto2] \
+ [file join $TestsDir auto0 auto1]] \
+ -autoPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]]
+ # 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]]
+ set mappD [mapList $PathMapp [dict get $confB -autoPath]]
+ set toksD [interp eval $i set ::auto_path]
+
+ # Run the commands.
+ 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 -- \
+ $mappA -- $mappB -- $mappC -- $mappD -- $toksC -- $toksD
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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*} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {{$p(:0:)} {$p(:1:)} {$p(:2:)}} -- {{$p(:0:)} {$p(:2:)} {$p(:1:)}}}
+test safe-19.10 {interpConfigure change the access path; tclIndex commands unaffected by token rearrangement (actual test of doreset), Sync Mode off} -constraints {AutoSyncDefined} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]] \
+ -autoPath [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]]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load auto_load data.
+ interp eval $i {catch nonExistentCommand}
+
+ # Do not load the commands. With the tokens swapped, the test
+ # will pass only if the Safe Base has called auto_reset.
+
+ # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:2:)}.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto2] \
+ [file join $TestsDir auto0 auto1]] \
+ -autoPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]]
+ # 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]]
+ set mappD [mapList $PathMapp [dict get $confB -autoPath]]
+ set toksD [interp eval $i set ::auto_path]
+
+ # Load and run the commands.
+ 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 -- \
+ $mappA -- $mappB -- $mappC -- $mappD -- $toksC -- $toksD
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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*} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2} --\
+ {{$p(:0:)} {$p(:1:)} {$p(:2:)}} -- {{$p(:0:)} {$p(:2:)} {$p(:1:)}}}
+test safe-19.11 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement (1), Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library \
+ [file join $TestsDir auto0] \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]] \
+ -autoPath [list $tcl_library \
+ [file join $TestsDir auto0]]]
+ # 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]]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load pkgIndex.tcl data.
+ catch {interp eval $i {package require NOEXIST}}
+
+ # Rearrange access path. Swap tokens {$p(:2:)} and {$p(:3:)}.
+ # This would have no effect because the records in Pkg of these directories
+ # were from access as children of {$p(:1:)}.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0] \
+ [file join $TestsDir auto0 auto2] \
+ [file join $TestsDir auto0 auto1]] \
+ -autoPath [list $tcl_library \
+ [file join $TestsDir auto0]]
+ # 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]]
+ set mappD [mapList $PathMapp [dict get $confB -autoPath]]
+ set toksD [interp eval $i set ::auto_path]
+
+ # Try to load the packages and run a command from each one.
+ set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3]
+ set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4]
+ 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 -- \
+ $mappA -- $mappB -- $mappC -- $mappD -- $toksC -- $toksD -- \
+ $code5 $msg5 $code6 $msg6
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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*} --\
+ {TCLLIB TESTSDIR/auto0} -- {TCLLIB TESTSDIR/auto0} --\
+ {{$p(:0:)} {$p(:1:)}} -- {{$p(:0:)} {$p(:1:)}} --\
+ 0 OK1 0 OK2}
+test safe-19.12 {interpConfigure change the access path; pkgIndex.tcl packages unaffected by token rearrangement, safe-19.11 without path auto0, Sync Mode off} -constraints {AutoSyncDefined} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ # To manage without path auto0, use an auto_path that is unusual for
+ # package discovery.
+ set i [safe::interpCreate -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]] \
+ -autoPath [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]]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load pkgIndex.tcl data.
+ catch {interp eval $i {package require NOEXIST}}
+
+ # Rearrange access path. Swap tokens {$p(:2:)} and {$p(:3:)}.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto2] \
+ [file join $TestsDir auto0 auto1]] \
+ -autoPath [list $tcl_library \
+ [file join $TestsDir auto0 auto2] \
+ [file join $TestsDir auto0 auto1]]
+ # 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]]
+ set mappD [mapList $PathMapp [dict get $confB -autoPath]]
+ set toksD [interp eval $i set ::auto_path]
+
+ # Try to load the packages and run a command from each one.
+ set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3]
+ set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4]
+ 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 -- \
+ $mappA -- $mappB -- $mappC -- $mappD -- $toksC -- $toksD -- \
+ $code5 $msg5 $code6 $msg6
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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*} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2} --\
+ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1} --\
+ {{$p(:0:)} {$p(:1:)} {$p(:2:)}} -- {{$p(:0:)} {$p(:1:)} {$p(:2:)}} --\
+ 0 OK1 0 OK2}
+test safe-19.13 {interpConfigure change the access path; pkgIndex.tcl packages fail if directory de-listed, Sync Mode off} -constraints {AutoSyncDefined} -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ # Path auto0 added (cf. safe-9.3) because it is needed for auto_path.
+ set i [safe::interpCreate -accessPath [list $tcl_library \
+ [file join $TestsDir auto0] \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]] \
+ -autoPath [list $tcl_library \
+ [file join $TestsDir auto0]]]
+ # 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]]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load pkgIndex.tcl data.
+ catch {interp eval $i {package require NOEXIST}}
+
+ # Limit access path. Remove tokens {$p(:2:)} and {$p(:3:)}.
+ safe::interpConfigure $i -accessPath [list $tcl_library]
+
+ # 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]
+ set mappD [mapList $PathMapp [dict get $confB -autoPath]]
+ set toksD [interp eval $i set ::auto_path]
+
+ # Try to load the packages.
+ 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 $code6 -- \
+ $mappA -- $mappB -- $mappC -- $mappD -- $toksC -- $toksD
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result {{$p(:2:)} {$p(:3:)} -- 1 {* not found in access path} --\
+ 1 {* not found in access path} -- 1 1 --\
+ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB*} -- {TCLLIB TESTSDIR/auto0} -- {TCLLIB TESTSDIR/auto0} --\
+ {{$p(:0:)} {$p(:1:)}} -- {{$p(:0:)}}}
+# (no counterpart safe-9.14)
+test safe-19.14 {when interpConfigure changes the access path, ::auto_path uses -autoPath value and new tokens, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ # Test that although -autoPath is unchanged, the child's ::auto_path changes to
+ # reflect the changes in token mappings.
+ set i [safe::interpCreate -accessPath [list $tcl_library \
+ [file join $TestsDir auto0] \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]] \
+ -autoPath [list $tcl_library \
+ [file join $TestsDir auto0]]]
+ # 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]]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load pkgIndex.tcl data.
+ catch {interp eval $i {package require NOEXIST}}
+
+ # Rearrange access path. Swap tokens {$p(:1:)} and {$p(:3:)}.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto2] \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0]]
+ # Inspect.
+ set confB [safe::interpConfigure $i]
+ set mappB [mapList $PathMapp [dict get $confB -accessPath]]
+ set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0]]
+ set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
+ set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
+ set mappD [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksD [interp eval $i set ::auto_path]
+
+ # Try to load the packages and run a command from each one.
+ set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3]
+ set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4]
+ set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5]
+ set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6]
+
+ list $path0 $path1 $path2 -- $path5 $path3 $path4 -- $toksC -- $toksD -- \
+ $code3 $msg3 $code4 $msg4 -- \
+ $mappA -- $mappB -- $mappC -- $mappD -- $code5 $msg5 $code6 $msg6
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result {{$p(:1:)} {$p(:2:)} {$p(:3:)} -- {$p(:3:)} {$p(:2:)} {$p(:1:)} -- {{$p(:0:)} {$p(:1:)}} -- {{$p(:0:)} {$p(:3:)}} -- 0 1.2.3 0 2.3.4 --\
+ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB TESTSDIR/auto0/auto2 TESTSDIR/auto0/auto1 TESTSDIR/auto0*} --\
+ {TCLLIB TESTSDIR/auto0} --\
+ {TCLLIB TESTSDIR/auto0} --\
+ 0 OK1 0 OK2}
+# (no counterpart safe-9.15)
+test safe-19.15 {when interpConfigure changes the access path, ::auto_path uses -autoPath value and new tokens, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ # Test that although -autoPath is unchanged, the child's ::auto_path changes to
+ # reflect the changes in token mappings; and that it is based on the -autoPath
+ # value, not the previously restricted child ::auto_path.
+ set i [safe::interpCreate -accessPath [list $tcl_library \
+ [file join $TestsDir auto0]] \
+ -autoPath [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 path0 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0]]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load pkgIndex.tcl data.
+ catch {interp eval $i {package require NOEXIST}}
+
+ # Rearrange access path. Add more directories.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0] \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]]
+ # Inspect.
+ set confB [safe::interpConfigure $i]
+ set mappB [mapList $PathMapp [dict get $confB -accessPath]]
+ set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0]]
+ set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
+ set path4 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto2]]
+ set mappD [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksD [interp eval $i set ::auto_path]
+
+ # Try to load the packages and run a command from each one.
+ set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3 opts3]
+ set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4 opts4]
+ set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5]
+ set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6]
+
+ list $path0 -- $path5 $path3 $path4 -- $toksC -- $toksD -- \
+ $code3 $msg3 $code4 $msg4 -- \
+ $mappA -- $mappB -- $mappC -- $mappD -- $code5 $msg5 $code6 $msg6
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result {{$p(:1:)} -- {$p(:1:)} {$p(:2:)} {$p(:3:)} -- {{$p(:0:)}} -- {{$p(:0:)} {$p(:2:)} {$p(:3:)}} -- 0 1.2.3 0 2.3.4 --\
+ {TCLLIB TESTSDIR/auto0*} --\
+ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2*} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2} --\
+ {TCLLIB TESTSDIR/auto0/auto1 TESTSDIR/auto0/auto2} --\
+ 0 OK1 0 OK2}
+# (no counterpart safe-9.16)
+test safe-19.16 {default value for -accessPath and -autoPath on creation; -autoPath preserved when -accessPath changes, ::auto_path using changed tokens, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set tmpAutoPath $::auto_path
+ set ::auto_path [list $tcl_library [file join $TestsDir auto0]]
+ set i [safe::interpCreate]
+ set ::auto_path $tmpAutoPath
+} -body {
+ # Test that the -autoPath acquires and keeps the parent's value unless otherwise specified.
+
+ # Inspect.
+ set confA [safe::interpConfigure $i]
+ set mappC [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksC [interp eval $i set ::auto_path]
+
+ # Load pkgIndex.tcl data.
+ catch {interp eval $i {package require NOEXIST}}
+
+ # Rearrange access path. Remove a directory.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0] \
+ [file join $TestsDir auto0 auto1]]
+ # Inspect.
+ set confB [safe::interpConfigure $i]
+ set mappB [mapList $PathMapp [dict get $confB -accessPath]]
+ set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0]]
+ set path3 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 auto1]]
+ set mappD [mapList $PathMapp [dict get $confA -autoPath]]
+ set toksD [interp eval $i set ::auto_path]
+
+ # Try to load the packages and run a command from each one.
+ set code3 [catch {interp eval $i {package require SafeTestPackage1}} msg3]
+ set code4 [catch {interp eval $i {package require SafeTestPackage2}} msg4]
+ set code5 [catch {interp eval $i {HeresPackage1}} msg5 opts5]
+ set code6 [catch {interp eval $i {HeresPackage2}} msg6 opts6]
+
+ list $path5 $path3 -- [lindex $toksC 0] [llength $toksC] -- \
+ $toksD -- $code3 $msg3 $code4 $msg4 -- \
+ $mappB -- $mappC -- $mappD -- $code5 $msg5 $code6 $msg6
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result {{$p(:1:)} {$p(:2:)} -- {$p(:0:)} 2 --\
+ {{$p(:0:)} {$p(:1:)}} -- 0 1.2.3 1 {can't find package SafeTestPackage2} --\
+ {TCLLIB TESTSDIR/auto0 TESTSDIR/auto0/auto1*} --\
+ {TCLLIB TESTSDIR/auto0} -- {TCLLIB TESTSDIR/auto0} --\
+ 0 OK1 1 {invalid command name "HeresPackage2"}}
+test safe-19.20 {check module loading, Sync Mode off} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set oldTm [tcl::tm::path list]
+ foreach path $oldTm {
+ tcl::tm::path remove $path
+ }
+ tcl::tm::path add [file join $TestsDir auto0 modules]
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library]]
+
+ # 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]]
+ set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Try to load the packages and run a command from each one.
+ set code0 [catch {interp eval $i {package require test0}} msg0]
+ set code1 [catch {interp eval $i {package require mod1::test1}} msg1]
+ set code2 [catch {interp eval $i {package require mod2::test2}} msg2]
+ set out0 [interp eval $i {test0::try0}]
+ set out1 [interp eval $i {mod1::test1::try1}]
+ set out2 [interp eval $i {mod2::test2::try2}]
+
+ 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
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -match glob -result {{{$p(:1:)} {$p(:2:)} {$p(:3:)}} -- {{$p(:1:)}} --\
+ 0 0.5 0 1.0 0 2.0 --\
+ {TCLLIB 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-19.21 {interpConfigure change the access path; check module loading, Sync Mode off; stale data case 1} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set oldTm [tcl::tm::path list]
+ foreach path $oldTm {
+ tcl::tm::path remove $path
+ }
+ tcl::tm::path add [file join $TestsDir auto0 modules]
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library]]
+
+ # 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]]
+ set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Add to access path.
+ # This injects more tokens, pushing modules to higher token numbers.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]]
+ # 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]]
+ set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Load pkg data.
+ catch {interp eval $i {package require NOEXIST}}
+ catch {interp eval $i {package require mod1::NOEXIST}}
+ catch {interp eval $i {package require mod2::NOEXIST}}
+
+ # Try to load the packages and run a command from each one.
+ set code0 [catch {interp eval $i {package require test0}} msg0]
+ set code1 [catch {interp eval $i {package require mod1::test1}} msg1]
+ set code2 [catch {interp eval $i {package require mod2::test2}} msg2]
+ set out0 [interp eval $i {test0::try0}]
+ set out1 [interp eval $i {mod1::test1::try1}]
+ set out2 [interp eval $i {mod2::test2::try2}]
+
+ 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]
+ foreach path [lreverse $oldTm] {
+ tcl::tm::path add $path
+ }
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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 --\
+ {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-19.22 {interpConfigure change the access path; check module loading, Sync Mode off; stale data case 0} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set oldTm [tcl::tm::path list]
+ foreach path $oldTm {
+ tcl::tm::path remove $path
+ }
+ tcl::tm::path add [file join $TestsDir auto0 modules]
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library]]
+
+ # 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]]
+ set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Add to access path.
+ # This injects more tokens, pushing modules to higher token numbers.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]]
+ # 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]]
+ set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Try to load the packages and run a command from each one.
+ set code0 [catch {interp eval $i {package require test0}} msg0]
+ set code1 [catch {interp eval $i {package require mod1::test1}} msg1]
+ set code2 [catch {interp eval $i {package require mod2::test2}} msg2]
+ set out0 [interp eval $i {test0::try0}]
+ set out1 [interp eval $i {mod1::test1::try1}]
+ set out2 [interp eval $i {mod2::test2::try2}]
+
+ 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]
+ foreach path [lreverse $oldTm] {
+ tcl::tm::path add $path
+ }
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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 --\
+ {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-19.23 {interpConfigure change the access path; check module loading, Sync Mode off; stale data case 3} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set oldTm [tcl::tm::path list]
+ foreach path $oldTm {
+ tcl::tm::path remove $path
+ }
+ tcl::tm::path add [file join $TestsDir auto0 modules]
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library]]
+
+ # 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]]
+ set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Force the interpreter to acquire pkg data which will soon become stale.
+ catch {interp eval $i {package require NOEXIST}}
+ catch {interp eval $i {package require mod1::NOEXIST}}
+ catch {interp eval $i {package require mod2::NOEXIST}}
+
+ # Add to access path.
+ # This injects more tokens, pushing modules to higher token numbers.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]]
+ # 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]]
+ set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Refresh stale pkg data.
+ catch {interp eval $i {package require NOEXIST}}
+ catch {interp eval $i {package require mod1::NOEXIST}}
+ catch {interp eval $i {package require mod2::NOEXIST}}
+
+ # Try to load the packages and run a command from each one.
+ set code0 [catch {interp eval $i {package require test0}} msg0]
+ set code1 [catch {interp eval $i {package require mod1::test1}} msg1]
+ set code2 [catch {interp eval $i {package require mod2::test2}} msg2]
+ set out0 [interp eval $i {test0::try0}]
+ set out1 [interp eval $i {mod1::test1::try1}]
+ set out2 [interp eval $i {mod2::test2::try2}]
+
+ 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]
+ foreach path [lreverse $oldTm] {
+ tcl::tm::path add $path
+ }
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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 --\
+ {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-19.24 {interpConfigure change the access path; check module loading, Sync Mode off; stale data case 2 (worst case)} -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set oldTm [tcl::tm::path list]
+ foreach path $oldTm {
+ tcl::tm::path remove $path
+ }
+ tcl::tm::path add [file join $TestsDir auto0 modules]
+} -body {
+ set i [safe::interpCreate -accessPath [list $tcl_library]]
+
+ # 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]]
+ set path2 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Force the interpreter to acquire pkg data which will soon become stale.
+ catch {interp eval $i {package require NOEXIST}}
+ catch {interp eval $i {package require mod1::NOEXIST}}
+ catch {interp eval $i {package require mod2::NOEXIST}}
+
+ # Add to access path.
+ # This injects more tokens, pushing modules to higher token numbers.
+ safe::interpConfigure $i -accessPath [list $tcl_library \
+ [file join $TestsDir auto0 auto1] \
+ [file join $TestsDir auto0 auto2]]
+ # 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]]
+ set path5 [::safe::interpFindInAccessPath $i [file join $TestsDir auto0 modules mod2]]
+
+ # Try to load the packages and run a command from each one.
+ set code0 [catch {interp eval $i {package require test0}} msg0]
+ set code1 [catch {interp eval $i {package require mod1::test1}} msg1]
+ set code2 [catch {interp eval $i {package require mod2::test2}} msg2]
+ set out0 [interp eval $i {test0::try0}]
+ set out1 [interp eval $i {mod1::test1::try1}]
+ set out2 [interp eval $i {mod2::test2::try2}]
+
+ 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]
+ foreach path [lreverse $oldTm] {
+ tcl::tm::path add $path
+ }
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -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 --\
+ {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.
+
+
+### 20. safe::interpCreate with different cases of -accessPath, -autoPath.
+
+set ::auto_path [list $tcl_library [file dirname $tcl_library] [file join $TestsDir auto0]]
+
+test safe-20.1 "create -accessPath NULL -autoPath NULL -> parent's ::auto_path" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list $::auto_path -- $::auto_path]
+test safe-20.2 "create -accessPath {} -autoPath NULL -> parent's ::auto_path" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath {}]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list $::auto_path -- $::auto_path]
+test safe-20.3 "create -accessPath path1 -autoPath NULL -> {}" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1]]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {{} -- {}}
+test safe-20.4 "create -accessPath NULL -autoPath {} -> {}" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -autoPath {}]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {{} -- {}}
+test safe-20.5 "create -accessPath {} -autoPath {} -> {}" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath {} -autoPath {}]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {{} -- {}}
+test safe-20.6 "create -accessPath path1 -autoPath {} -> {}" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath {}]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {{} -- {}}
+test safe-20.7 "create -accessPath NULL -autoPath path2 -> path2" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -autoPath [lrange $::auto_path 0 0]]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [lrange $::auto_path 0 0] -- [lrange $::auto_path 0 0]]
+test safe-20.8 "create -accessPath {} -autoPath path2 -> path2" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath {} -autoPath [lrange $::auto_path 0 0]]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [lrange $::auto_path 0 0] -- [lrange $::auto_path 0 0]]
+test safe-20.9 "create -accessPath path1 -autoPath path2 -> path2" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [lrange $::auto_path 0 0] -- [lrange $::auto_path 0 0]]
+test safe-20.10 "create -accessPath NULL -autoPath pathX -> pathX" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -autoPath /not/in/access/path]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {/not/in/access/path -- {}}
+test safe-20.11 "create -accessPath {} -autoPath pathX -> pathX" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath {} -autoPath /not/in/access/path]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {/not/in/access/path -- {}}
+test safe-20.12 "create -accessPath path1 -autoPath pathX -> {pathX}" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+} -body {
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath /not/in/access/path]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {/not/in/access/path -- {}}
+
+### 21. safe::interpConfigure with different cases of -accessPath, -autoPath.
+
+test safe-21.1 "interpConfigure -accessPath NULL -autoPath NULL -> no change" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -deleteHook {}
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [lrange $::auto_path 0 0] -- [lrange $::auto_path 0 0]]
+test safe-21.2 "interpConfigure -accessPath {} -autoPath NULL -> parent's ::auto_path" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -accessPath {}
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list $::auto_path -- $::auto_path]
+test safe-21.3 "interpConfigure -accessPath path1 -autoPath NULL -> no change" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -accessPath [lrange $::auto_path 0 1]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [lrange $::auto_path 0 0] -- [lrange $::auto_path 0 0]]
+test safe-21.4 "interpConfigure -accessPath NULL -autoPath {} -> {}" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -autoPath {}
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {{} -- {}}
+test safe-21.5 "interpConfigure -accessPath {} -autoPath {} -> {}" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -accessPath {} -autoPath {}
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {{} -- {}}
+test safe-21.6 "interpConfigure -accessPath {path1} -autoPath {} -> {}" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -accessPath [lrange $::auto_path 1 1] -autoPath {}
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {{} -- {}}
+test safe-21.7 "interpConfigure -accessPath NULL -autoPath path2 -> path2" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -autoPath [lrange $::auto_path 1 1]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [lrange $::auto_path 1 1] -- [lrange $::auto_path 1 1]]
+test safe-21.8 "interpConfigure -accessPath {} -autoPath path2 -> path2" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -accessPath {} -autoPath [lrange $::auto_path 1 1]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [lrange $::auto_path 1 1] -- [lrange $::auto_path 1 1]]
+test safe-21.9 "interpConfigure -accessPath path1 -autoPath path2 -> path2" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -accessPath [lrange $::auto_path 0 2] -autoPath [lrange $::auto_path 1 1]
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result [list [lrange $::auto_path 1 1] -- [lrange $::auto_path 1 1]]
+test safe-21.10 "interpConfigure -accessPath NULL -autoPath pathX -> pathX" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -autoPath /not/in/access/path
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {/not/in/access/path -- {}}
+test safe-21.11 "interpConfigure -accessPath {} -autoPath pathX -> pathX" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -accessPath {} -autoPath /not/in/access/path
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {/not/in/access/path -- {}}
+test safe-21.12 "interpConfigure -accessPath path1 -autoPath pathX -> pathX" -constraints AutoSyncDefined -setup {
+ set SyncExists [expr {[info commands ::safe::setSyncMode] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setSyncMode]
+ safe::setSyncMode 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setSyncMode is defined}
+ }
+ set i [safe::interpCreate -accessPath [lrange $::auto_path 0 1] -autoPath [lrange $::auto_path 0 0]]
+} -body {
+ safe::interpConfigure $i -accessPath [lrange $::auto_path 0 2] -autoPath /not/in/access/path
+ getAutoPath $i
+} -cleanup {
+ safe::interpDelete $i
+ if {$SyncExists} {
+ safe::setSyncMode $SyncVal_TMP
+ }
+} -result {/not/in/access/path -- {}}
# cleanup
set ::auto_path $SaveAutoPath
unset SaveAutoPath TestsDir PathMapp
+rename getAutoPath {}
unset -nocomplain path
rename mapList {}
rename mapAndSortList {}