summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorkjnash <k.j.nash@usa.net>2020-07-22 19:42:38 (GMT)
committerkjnash <k.j.nash@usa.net>2020-07-22 19:42:38 (GMT)
commit356b2f5829e52ff52c28cba8b5b6b5558a562c89 (patch)
tree3fe3fa32d4049168e3dd7d7130c923b1f9cdcdb5 /tests
parent9e0d60b4a2698a1f9d1e85b957c5e1c18df126a8 (diff)
downloadtcl-356b2f5829e52ff52c28cba8b5b6b5558a562c89.zip
tcl-356b2f5829e52ff52c28cba8b5b6b5558a562c89.tar.gz
tcl-356b2f5829e52ff52c28cba8b5b6b5558a562c89.tar.bz2
Move tests that depend on platform::shell from safe.test to safe-stock86.test, and replace with tests that use example packages.
Diffstat (limited to 'tests')
-rw-r--r--tests/safe-stock87.test65
-rw-r--r--tests/safe-zipfs.test13
-rw-r--r--tests/safe.test68
3 files changed, 71 insertions, 75 deletions
diff --git a/tests/safe-stock87.test b/tests/safe-stock87.test
index a8f5bd2..1a29018 100644
--- a/tests/safe-stock87.test
+++ b/tests/safe-stock87.test
@@ -107,19 +107,15 @@ catch {safe::interpConfigure}
# package - Tcltest - but it might be absent if we're in standard tclsh)
testConstraint TcltestPackage [expr {![catch {package require Tcltest}]}]
-
testConstraint AutoSyncDefined 1
# high level general test
test safe-stock87-7.1 {tests that everything works at high level with conventional AutoPathSync, use pkg opt} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 1
}
-
set i [safe::interpCreate]
} -body {
# no error shall occur:
@@ -136,9 +132,7 @@ test safe-stock87-7.1 {tests that everything works at high level with convention
}
} -match glob -result 0.4.*
test safe-stock87-7.2 {tests specific path and interpFind/AddToAccessPath with conventional AutoPathSync, use pkg opt} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 1
@@ -165,9 +159,7 @@ test safe-stock87-7.2 {tests specific path and interpFind/AddToAccessPath with c
} -match glob -result "{\$p(:0:)} {\$p(:*:)} -- 1 {$pkgOptErrMsg} --\
{TCLLIB */dummy/unixlike/test/path} -- {}"
test safe-stock87-7.4 {tests specific path and positive search with conventional AutoPathSync, use pkg opt} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 1
@@ -194,6 +186,30 @@ test safe-stock87-7.4 {tests specific path and positive search with conventional
}
} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 0.4.* --\
{TCLLIB * TCLLIB/OPTDIR} -- {}}
+test safe-stock87-7.5 {tests positive and negative module loading with conventional AutoPathSync} -setup {
+ set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setAutoPathSync]
+ safe::setAutoPathSync 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::setAutoPathSync $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".
@@ -296,16 +312,13 @@ test safe-stock87-9.13 {interpConfigure change the access path; pkgIndex.tcl pac
{TCLLIB TCLLIB/OPTDIR TCLLIB/JARDIR*} -- {TCLLIB*}}
test safe-stock87-18.1 {cf. safe-stock87-7.1opt - tests that everything works at high level without conventional AutoPathSync, use pkg opt} -constraints AutoSyncDefined -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
} else {
error {This test is meaningful only if the command ::safe::setAutoPathSync is defined}
}
-
# Without AutoPathSync, we need a more complete auto_path,
# because the slave will use the same value.
set lib1 [info library]
@@ -330,9 +343,7 @@ test safe-stock87-18.1 {cf. safe-stock87-7.1opt - tests that everything works at
}
} -match glob -result 0.4.*
test safe-stock87-18.2 {cf. safe-stock87-7.2opt - tests specific path and interpFind/AddToAccessPath without conventional AutoPathSync, use pkg opt} -constraints AutoSyncDefined -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
@@ -361,9 +372,7 @@ test safe-stock87-18.2 {cf. safe-stock87-7.2opt - tests specific path and interp
{-accessPath {[list $tcl_library */dummy/unixlike/test/path]}\
-statics 0 -nested 1 -deleteHook {} -autoPath [list $tcl_library]} {}"
test safe-stock87-18.4 {cf. safe-stock87-7.4opt - tests specific path and positive search and auto_path without conventional AutoPathSync, use pkg opt} -constraints AutoSyncDefined -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
@@ -399,6 +408,32 @@ test safe-stock87-18.4 {cf. safe-stock87-7.4opt - tests specific path and positi
} -match glob -result "{} {{\$p(:0:)}} {\$p(:0:)} {\$p(:*:)} 0 0.4.*\
{-accessPath {[list $tcl_library *$tcl_library/$pkgOptDir]}\
-statics 0 -nested 1 -deleteHook {} -autoPath [list $tcl_library]} {}"
+test safe-stock87-18.5 {cf. safe-stock87-7.5 - tests positive and negative module loading without conventional AutoPathSync} -setup {
+ set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
+ if {$SyncExists} {
+ set SyncVal_TMP [safe::setAutoPathSync]
+ safe::setAutoPathSync 0
+ } else {
+ error {This test is meaningful only if the command ::safe::setAutoPathSync 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::setAutoPathSync $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 4793bb2..4ec01d1 100644
--- a/tests/safe-zipfs.test
+++ b/tests/safe-zipfs.test
@@ -172,9 +172,8 @@ test safe-zipfs-5.6 {example modules packages, test in master interpreter, appen
} -match glob -result {0 0.5 0 1.0 0 2.0 -- res0 res1 res2}
# high level general test
-# Use zipped example packages not tcl8.x/opt
+# Use zipped example packages not http1.0 etc
test safe-zipfs-7.1 {tests that everything works at high level with conventional AutoPathSync; zipfs} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
@@ -199,7 +198,6 @@ test safe-zipfs-7.1 {tests that everything works at high level with conventional
}
} -match glob -result 1.2.3
test safe-zipfs-7.2 {tests specific path and interpFind/AddToAccessPath with conventional AutoPathSync; zipfs} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
@@ -230,7 +228,6 @@ test safe-zipfs-7.2 {tests specific path and interpFind/AddToAccessPath with con
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 {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
@@ -829,16 +826,13 @@ test safe-zipfs-9.24 {interpConfigure change the access path; check module loadi
# 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 {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
} else {
error {This test is meaningful only if the command ::safe::setAutoPathSync is defined}
}
-
# Without AutoPathSync, we need a more complete auto_path,
# because the slave will use the same value.
set lib1 [info library]
@@ -863,9 +857,7 @@ test safe-zipfs-18.1 {cf. safe-zipfs-7.1 - tests that everything works at high l
}
} -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 {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
@@ -899,7 +891,6 @@ test safe-zipfs-18.2 {cf. safe-zipfs-7.2 - tests specific path and interpFind/Ad
$ZipMountPoint/auto0]}\
-statics 0 -nested 1 -deleteHook {} -autoPath [list $tcl_library]} {}"
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 {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
@@ -943,12 +934,12 @@ test safe-zipfs-18.4 {cf. safe-zipfs-7.4 - tests specific path and positive sear
-statics 0 -nested 1 -deleteHook {}\
-autoPath {[list $tcl_library $ZipMountPoint/auto0]}} {}"
+# cleanup
set ::auto_path $SaveAutoPath
zipfs unmount ${ZipMountPoint}
unset SaveAutoPath TestsDir ZipMountPoint PathMapp
rename mapList {}
rename mapAndSortList {}
-# cleanup
::tcltest::cleanupTests
return
diff --git a/tests/safe.test b/tests/safe.test
index ae4af7c..1b118a9 100644
--- a/tests/safe.test
+++ b/tests/safe.test
@@ -286,7 +286,6 @@ test safe-5.6 {example modules packages, test in master 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'
proc SafeEval {script} {
# Helper procedure that ensures the safe interp is cleaned up even if
@@ -318,16 +317,13 @@ rename SafeEval {}
# leaking infos, but they still do...
# high level general test
-# Use example packages not tcl8.x/opt
+# Use example packages not http1.0 etc
test safe-7.1 {tests that everything works at high level with conventional AutoPathSync} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 1
}
-
set tmpAutoPath $::auto_path
lappend ::auto_path [file join $TestsDir auto0]
set i [safe::interpCreate]
@@ -347,9 +343,7 @@ test safe-7.1 {tests that everything works at high level with conventional AutoP
}
} -match glob -result 1.2.3
test safe-7.2 {tests specific path and interpFind/AddToAccessPath with conventional AutoPathSync} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 1
@@ -410,9 +404,7 @@ test safe-7.3.1 {check that safe subinterpreters work with namespace names} -set
[interp exists $j] [info vars ::safe::S*]
} -match glob -result {{} {} ok ok {} 0 {}}
test safe-7.4 {tests specific path and positive search with conventional AutoPathSync} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 1
@@ -440,33 +432,30 @@ test safe-7.4 {tests specific path and positive search with conventional AutoPat
} -match glob -result {{$p(:0:)} {$p(:*:)} -- 0 1.2.3 --\
{TCLLIB * TESTSDIR/auto0/auto1} -- {}}
test safe-7.5 {tests positive and negative module loading with conventional AutoPathSync} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 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 platform::shell
- package forget platform
- catch {namespace delete ::platform}
+ 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 shell}} msg1]
+ set code1 [catch {interp eval $i {package require test1}} msg1]
# Should not raise an error
- set code2 [catch {interp eval $i {package require platform::shell}} msg2]
+ set code2 [catch {interp eval $i {package require mod1::test1}} msg2]
return [list $code1 $msg1 $code2]
} -cleanup {
safe::interpDelete $i
if {$SyncExists} {
safe::setAutoPathSync $SyncVal_TMP
}
-} -result {1 {can't find package shell} 0}
+} -result {1 {can't find package test1} 0}
# test source control on file name
test safe-8.1 {safe source control on file} -setup {
@@ -857,7 +846,6 @@ test safe-9.11 {interpConfigure change the access path; pkgIndex.tcl packages un
[file join $TestsDir auto0] \
[file join $TestsDir auto0 auto2] \
[file join $TestsDir auto0 auto1]]
-
# Inspect.
set confB [safe::interpConfigure $i]
set mappB [mapList $PathMapp [dict get $confB -accessPath]]
@@ -1801,7 +1789,7 @@ test safe-16.8 {Bug 3529949: defang ~user in paths used by AliasGlob (2)} -setup
} -result {~USER}
### 17. The first element in a slave's ::auto_path and access path must be [info library].
-
+### Merge back to no-TIP safe.test
test safe-17.1 {Check that first element of slave auto_path (and access path) is Tcl Library} -setup {
set lib1 [info library]
set lib2 [file dirname $lib1]
@@ -1841,18 +1829,14 @@ test safe-17.2 {Check that first element of slave auto_path (and access path) is
} -result [list [info library] [info library]]
### 18. Tests for AutoSyncDefined without conventional AutoPathSync, i.e. with AutoPathSync off.
-
test safe-18.1 {cf. safe-7.1 - tests that everything works at high level without conventional AutoPathSync} -constraints AutoSyncDefined -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
} else {
error {This test is meaningful only if the command ::safe::setAutoPathSync is defined}
}
-
# Without AutoPathSync, we need a more complete auto_path,
# because the slave will use the same value.
set lib1 [info library]
@@ -1877,9 +1861,7 @@ test safe-18.1 {cf. safe-7.1 - tests that everything works at high level without
}
} -match glob -result 1.2.3
test safe-18.2 {cf. safe-7.2 - tests specific path and interpFind/AddToAccessPath without conventional AutoPathSync} -constraints AutoSyncDefined -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
@@ -1913,22 +1895,17 @@ test safe-18.2 {cf. safe-7.2 - tests specific path and interpFind/AddToAccessPat
$TestsDir/auto0]}\
-statics 0 -nested 1 -deleteHook {} -autoPath [list $tcl_library]} {}"
test safe-18.3 {Check that default auto_path is the same as in the master interpreter without conventional AutoPathSync} -constraints AutoSyncDefined -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
} else {
error {This test is meaningful only if the command ::safe::setAutoPathSync 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]
@@ -1941,9 +1918,7 @@ test safe-18.3 {Check that default auto_path is the same as in the master interp
}
} -result $::auto_path
test safe-18.4 {cf. safe-7.4 - tests specific path and positive search and auto_path without conventional AutoPathSync} -constraints AutoSyncDefined -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
@@ -1986,40 +1961,35 @@ test safe-18.4 {cf. safe-7.4 - tests specific path and positive search and auto_
-statics 0 -nested 1 -deleteHook {}\
-autoPath {[list $tcl_library $TestsDir/auto0]}} {}"
test safe-18.5 {cf. safe-7.5 - tests positive and negative module loading without conventional AutoPathSync} -setup {
- # All ::safe commands are loaded at start of file.
set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]
-
if {$SyncExists} {
set SyncVal_TMP [safe::setAutoPathSync]
safe::setAutoPathSync 0
} else {
error {This test is meaningful only if the command ::safe::setAutoPathSync 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 platform::shell
- package forget platform
- catch {namespace delete ::platform}
+ 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 shell}} msg1]
+ set code1 [catch {interp eval $i {package require test1}} msg1]
# Should not raise an error
- set code2 [catch {interp eval $i {package require platform::shell}} msg2]
+ set code2 [catch {interp eval $i {package require mod1::test1}} msg2]
return [list $code1 $msg1 $code2]
} -cleanup {
safe::interpDelete $i
if {$SyncExists} {
safe::setAutoPathSync $SyncVal_TMP
}
-} -result {1 {can't find package shell} 0}
-
-
+} -result {1 {can't find package test1} 0}
### 19. Test tokenization of directories available to a slave.
-
+### Merge back to no-TIP safe.test
test safe-19.1 {Check that each directory of the default auto_path is a valid token} -setup {
set i [safe::interpCreate]
} -body {
@@ -2053,12 +2023,12 @@ test safe-19.2 {Check that each directory of the module path is a valid token} -
} -cleanup {
safe::interpDelete $i
} -result {}
-
+
+# cleanup
set ::auto_path $SaveAutoPath
unset SaveAutoPath TestsDir PathMapp
rename mapList {}
rename mapAndSortList {}
-# cleanup
::tcltest::cleanupTests
return