Diff
Not logged in

Differences From Artifact [78e47ae35d]:

To Artifact [3654010aef]:


282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
    catch {package forget test0}
    catch {package forget mod1::test1}
    catch {package forget mod2::test2}
    catch {namespace delete ::test0}
    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
    # there is a failure in the script.
    set SafeInterp [interp create -safe]
    catch {$SafeInterp eval $script} msg opts
    interp delete $SafeInterp







<







282
283
284
285
286
287
288

289
290
291
292
293
294
295
    catch {package forget test0}
    catch {package forget mod1::test1}
    catch {package forget mod2::test2}
    catch {namespace delete ::test0}
    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
    # there is a failure in the script.
    set SafeInterp [interp create -safe]
    catch {$SafeInterp eval $script} msg opts
    interp delete $SafeInterp
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
} {byteOrder engine pathSeparator platform pointerSize wordSize}

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 tcl8.x/opt
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]
    set ::auto_path $tmpAutoPath
} -body {
    # no error shall occur:
    # (because the default access_path shall include 1st level sub dirs so
    #  package require in a slave works like in the master)
    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::setAutoPathSync $SyncVal_TMP
    }
} -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
    } else {
        set SyncVal_TMP 1
    }
} -body {







|

<

<




<



















<

<







313
314
315
316
317
318
319
320
321

322

323
324
325
326

327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345

346

347
348
349
350
351
352
353
} {byteOrder engine pathSeparator platform pointerSize wordSize}

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 with conventional AutoPathSync} -setup {

    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]
    set ::auto_path $tmpAutoPath
} -body {
    # no error shall occur:
    # (because the default access_path shall include 1st level sub dirs so
    #  package require in a slave works like in the master)
    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::setAutoPathSync $SyncVal_TMP
    }
} -match glob -result 1.2.3
test safe-7.2 {tests specific path and interpFind/AddToAccessPath with conventional AutoPathSync} -setup {

    set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]

    if {$SyncExists} {
        set SyncVal_TMP [safe::setAutoPathSync]
        safe::setAutoPathSync 1
    } else {
        set SyncVal_TMP 1
    }
} -body {
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
    set j [safe::interpCreate [list $i hello::world]]
    list $g $h [interp eval $j {join {o k} ""}] \
            [foo::bar eval {hello::world eval {join {o k} ""}}] \
            [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 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
    } else {
        set SyncVal_TMP 1
    }
} -body {







<

<







400
401
402
403
404
405
406

407

408
409
410
411
412
413
414
    set j [safe::interpCreate [list $i hello::world]]
    list $g $h [interp eval $j {join {o k} ""}] \
            [foo::bar eval {hello::world eval {join {o k} ""}}] \
            [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 with conventional AutoPathSync} -setup {

    set SyncExists [expr {[info commands ::safe::setAutoPathSync] ne {}}]

    if {$SyncExists} {
        set SyncVal_TMP [safe::setAutoPathSync]
        safe::setAutoPathSync 1
    } else {
        set SyncVal_TMP 1
    }
} -body {
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
} -cleanup {
    if {$SyncExists} {
        safe::setAutoPathSync $SyncVal_TMP
    }
} -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
    }

    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}

# test source control on file name
test safe-8.1 {safe source control on file} -setup {
    set i "a"
    catch {safe::interpDelete $i}
} -body {
    safe::interpCreate $i







<

<




|

|

<
|
|



|

|






|







428
429
430
431
432
433
434

435

436
437
438
439
440
441
442
443

444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
} -cleanup {
    if {$SyncExists} {
        safe::setAutoPathSync $SyncVal_TMP
    }
} -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 {

    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 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::setAutoPathSync $SyncVal_TMP
    }
} -result {1 {can't find package test1} 0}

# test source control on file name
test safe-8.1 {safe source control on file} -setup {
    set i "a"
    catch {safe::interpDelete $i}
} -body {
    safe::interpCreate $i
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
    # 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]]

    # 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]]

    # Try to load the packages and run a command from each one.







<







842
843
844
845
846
847
848

849
850
851
852
853
854
855
    # 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]]

    # 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]]

    # Try to load the packages and run a command from each one.
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
    string map [list $user USER] [$i eval [list file join {$p(:0:)/foo/bar} ~$user]]
} -cleanup {
    safe::interpDelete $i
    unset user
} -result {~USER}

### 17. The first element in a slave's ::auto_path and access path must be [info library].

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]
    set ::auto_TMP  $::auto_path
    set ::auto_path [list $lib1 $lib2]

    set i [safe::interpCreate]







|







1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
    string map [list $user USER] [$i eval [list file join {$p(:0:)/foo/bar} ~$user]]
} -cleanup {
    safe::interpDelete $i
    unset user
} -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]
    set ::auto_TMP  $::auto_path
    set ::auto_path [list $lib1 $lib2]

    set i [safe::interpCreate]
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
    return [list [lindex $accessList 0] $auto0]
} -cleanup {
    set ::auto_path $::auto_TMP
    safe::interpDelete $i
} -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]
    set lib2        [file join $TestsDir auto0]
    set ::auto_TMP  $::auto_path
    set ::auto_path [list $lib1 $lib2]








<

<

<






<







1825
1826
1827
1828
1829
1830
1831

1832

1833

1834
1835
1836
1837
1838
1839

1840
1841
1842
1843
1844
1845
1846
    return [list [lindex $accessList 0] $auto0]
} -cleanup {
    set ::auto_path $::auto_TMP
    safe::interpDelete $i
} -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 {

    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]
    set lib2        [file join $TestsDir auto0]
    set ::auto_TMP  $::auto_path
    set ::auto_path [list $lib1 $lib2]

1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
} -cleanup {
    safe::interpDelete $i
    if {$SyncExists} {
        safe::setAutoPathSync $SyncVal_TMP
    }
} -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
    } else {
        error {This test is meaningful only if the command ::safe::setAutoPathSync is defined}
    }
} -body {







<

<







1857
1858
1859
1860
1861
1862
1863

1864

1865
1866
1867
1868
1869
1870
1871
} -cleanup {
    safe::interpDelete $i
    if {$SyncExists} {
        safe::setAutoPathSync $SyncVal_TMP
    }
} -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 {

    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}
    }
} -body {
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
} -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 [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]
    }
    return $ap
} -cleanup {
    safe::interpDelete $i
    if {$SyncExists} {
	safe::setAutoPathSync $SyncVal_TMP
    }
} -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
    } else {
        error {This test is meaningful only if the command ::safe::setAutoPathSync is defined}
    }
} -body {







<

<






<

<



<












<

<







1891
1892
1893
1894
1895
1896
1897

1898

1899
1900
1901
1902
1903
1904

1905

1906
1907
1908

1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920

1921

1922
1923
1924
1925
1926
1927
1928
} -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 [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 {

    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]
    }
    return $ap
} -cleanup {
    safe::interpDelete $i
    if {$SyncExists} {
	safe::setAutoPathSync $SyncVal_TMP
    }
} -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 {

    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}
    }
} -body {
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
	safe::setAutoPathSync $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 {[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}
    }

    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}



### 19. Test tokenization of directories available to a slave.

test safe-19.1 {Check that each directory of the default auto_path is a valid token} -setup {
    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







<

<






|

|

<
|
|



|

|






|

<
<

|







1957
1958
1959
1960
1961
1962
1963

1964

1965
1966
1967
1968
1969
1970
1971
1972
1973
1974

1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990


1991
1992
1993
1994
1995
1996
1997
1998
1999
	safe::setAutoPathSync $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 {[list $tcl_library $TestsDir/auto0]}} {}"
test safe-18.5 {cf. safe-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}
    }
    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::setAutoPathSync $SyncVal_TMP
    }
} -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 {
    set badTokens {}
    foreach dir [$i eval {set ::auto_path}] {
        if {[regexp {^\$p\(:[0-9]+:\)$} $dir]} {
            # Match - OK - token has expected form
2049
2050
2051
2052
2053
2054
2055
2056

2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
            lappend badTokens $dir
        }
    }
    set badTokens
} -cleanup {
    safe::interpDelete $i
} -result {}


set ::auto_path $SaveAutoPath
unset SaveAutoPath TestsDir PathMapp
rename mapList {}
rename mapAndSortList {}
# cleanup
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End:







|
>




<






2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031

2032
2033
2034
2035
2036
2037
            lappend badTokens $dir
        }
    }
    set badTokens
} -cleanup {
    safe::interpDelete $i
} -result {}

# cleanup
set ::auto_path $SaveAutoPath
unset SaveAutoPath TestsDir PathMapp
rename mapList {}
rename mapAndSortList {}

::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End: