summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2004-11-30 19:34:44 (GMT)
committerdgp <dgp@users.sourceforge.net>2004-11-30 19:34:44 (GMT)
commit999c1d1867082cb366aeb7bb7d6f46f27ed40596 (patch)
tree3f6ea55c8096d98ba728284819430a49be305cf6 /tests
parentf1608d9d16479048838c99d496b9f2812de574f2 (diff)
downloadtcl-999c1d1867082cb366aeb7bb7d6f46f27ed40596.zip
tcl-999c1d1867082cb366aeb7bb7d6f46f27ed40596.tar.gz
tcl-999c1d1867082cb366aeb7bb7d6f46f27ed40596.tar.bz2
Patch 976520 reworks several of the details involved with
startup/initialization of the Tcl library, focused on the activities of Tcl_FindExecutable(). * generic/tclIO.c: Removed bogus claim in comment that encoding "iso8859-1" is "built-in" to Tcl. * generic/tclInt.h: Created a new struct ProcessGlobalValue, * generic/tclUtil.c: routines Tcl(Get|Set)ProcessGlobalValue, and function type TclInitProcessGlobalValueProc. Together, these take care of the housekeeping for "values" (things that can be held in a Tcl_Obj) that are global across a whole process. That is, they are shared among multiple threads, and epoch and mutex protection must govern the validity of cached copies maintained in each thread. * generic/tclNotify.c: Modified TclInitNotifier() to tolerate being called multiple times in the same thread. * generic/tclEvent.c: Dropped the unused argv0 argument to TclInitSubsystems(). Removed machinery to unsure only one TclInitNotifier() call per thread, now that that is safe. Converted Tcl(Get|Set)LibraryPath to use a ProcessGlobalValue, and moved them to tclEncoding.c. * generic/tclBasic.c: Updated caller. * generic/tclInt.h: TclpFindExecutable now returns void. * unix/tclUnixFile.c: * win/tclWinFile.c: * win/tclWinPipe.c: * generic/tclEncoding.c: Built new encoding search initialization on a foundation of ProcessGlobalValues, exposing new routines Tcl(Get|Set)EncodingSearchPath. A cache of a map from encoding name to directory pathname keeps track of where encodings are available for loading. Tcl_FindExecutable greatly simplified into just three function calls. The "library path" is now misnamed, as its only remaining purpose is as a foundation for the default encoding search path. * generic/tclInterp.c: Inlined the initScript that is evaluated by Tcl_Init(). Added verification after initScript evaluation that Tcl can find its installed *.enc files, and that it has initialized [encoding system] in agreement with what the environment expects. [tclInit] no longer driven by the value of $::tcl_libPath; it largely constructs its own search path now, rather than attempt to share one with the encoding system. * unix/tclUnixInit.c: TclpSetInitialEncodings factored so that a new * win/tclWinInit.c: routine TclpGetEncodingNameFromEnvironment can reveal that Tcl thinks the [encoding system] should be, even when an incomplete encoding search path, or a missing *.enc file won't allow that initialization to succeed. TclpInitLibraryPath reworked as an initializer of a ProcessGlobalValue. * unix/tclUnixTest.c: Update implementations of [testfindexecutable], [testgetdefenc], and [testsetdefenc]. * tests/unixInit.test: Corrected tests to operate properly even when a value of TCL_LIBRARY is required to find encodings. * generic/tclInt.decls: New internal stubs: TclGetEncodingSearchPath, TclSetEncodingSearchPath, TclpGetEncodingNameFromEnvironment. These are candidates for public exposure by future TIPs. * generic/tclIntDecls.h: make genstubs * generic/tclStubInit.c: * generic/tclTest.c: Updated [testencoding] to use * tests/encoding.test: Tcl(Get|Set)EncodingSearchPath. Updated tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/encoding.test6
-rw-r--r--tests/unixInit.test109
2 files changed, 88 insertions, 27 deletions
diff --git a/tests/encoding.test b/tests/encoding.test
index 97ae787..897bebf 100644
--- a/tests/encoding.test
+++ b/tests/encoding.test
@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: encoding.test,v 1.20 2004/05/07 20:01:23 rmax Exp $
+# RCS: @(#) $Id: encoding.test,v 1.21 2004/11/30 19:34:51 dgp Exp $
package require tcltest 2
namespace import -force ::tcltest::*
@@ -95,7 +95,7 @@ test encoding-4.1 {Tcl_GetEncodingNames} {testencoding} {
foreach encoding [encoding names] {
set encodings($encoding) 1
}
- testencoding path [list [pwd]]
+ testencoding path [list [file join [pwd] encoding]]
foreach encoding [encoding names] {
if {![info exists encodings($encoding)]} {
lappend x $encoding
@@ -237,7 +237,7 @@ test encoding-11.6 {LoadEncodingFile: invalid file} {testencoding} {
set path [testencoding path]
encoding system identity
cd [temporaryDirectory]
- testencoding path tmp
+ testencoding path [file join tmp encoding]
makeDirectory tmp
makeDirectory [file join tmp encoding]
set f [open [file join tmp encoding splat.enc] w]
diff --git a/tests/unixInit.test b/tests/unixInit.test
index 22840fb..f42c868 100644
--- a/tests/unixInit.test
+++ b/tests/unixInit.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: unixInit.test,v 1.43 2004/11/22 21:24:31 dgp Exp $
+# RCS: @(#) $Id: unixInit.test,v 1.44 2004/11/30 19:34:51 dgp Exp $
package require tcltest 2
namespace import -force ::tcltest::*
@@ -113,8 +113,15 @@ test unixInit-2.0 {TclpInitLibraryPath: setting tclDefaultEncodingDir} \
testsetdefenc $origDir
set path
} {slappy}
-test unixInit-2.1 {TclpInitLibraryPath: value of installLib, developLib} \
- {unix stdio } {
+test unixInit-2.1 {TclpInitLibraryPath: value of installLib, developLib} -constraints {
+ unix stdio
+} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ unset env(TCL_LIBRARY)
+ }
+} -body {
set path [getlibpath]
set installLib lib/tcl[info tclversion]
@@ -122,13 +129,19 @@ test unixInit-2.1 {TclpInitLibraryPath: value of installLib, developLib} \
set prefix [file dirname [file dirname [interpreter]]]
set x {}
- lappend x [string compare [lindex $path 2] $prefix/$installLib]
- lappend x [string compare [lindex $path 6] [file dirname $prefix]/$developLib]
+ lappend x [string compare [lindex $path 0] $prefix/$installLib]
+ lappend x [string compare [lindex $path 4] [file dirname $prefix]/$developLib]
set x
-} {0 0}
+} -cleanup {
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result {0 0}
test unixInit-2.2 {TclpInitLibraryPath: TCL_LIBRARY} -constraints {
unix stdio
} -setup {
+ unset -nocomplain oldlibrary
if {[info exists env(TCL_LIBRARY)]} {
set oldlibrary $env(TCL_LIBRARY)
}
@@ -149,6 +162,7 @@ test unixInit-2.2 {TclpInitLibraryPath: TCL_LIBRARY} -constraints {
test unixInit-2.3 {TclpInitLibraryPath: TCL_LIBRARY wrong version} -constraints {
unix stdio
} -setup {
+ unset -nocomplain oldlibrary
if {[info exists env(TCL_LIBRARY)]} {
set oldlibrary $env(TCL_LIBRARY)
}
@@ -167,7 +181,7 @@ test unixInit-2.3 {TclpInitLibraryPath: TCL_LIBRARY wrong version} -constraints
}
} -result [list /a/b/tcl1.7 /a/b/tcl[info tclversion]]
test unixInit-2.4 {TclpInitLibraryPath: TCL_LIBRARY: INTL} -constraints {
- unix stdio
+ unix stdio knownBug
} -setup {
if {[info exists env(TCL_LIBRARY)]} {
set oldlibrary $env(TCL_LIBRARY)
@@ -191,8 +205,14 @@ test unixInit-2.5 {TclpInitLibraryPath: compiled-in library path} \
{emptyTest unix} {
# cannot test
} {}
-test unixInit-2.6 {TclpInitLibraryPath: executable relative} \
- {unix stdio } {
+test unixInit-2.6 {TclpInitLibraryPath: executable relative} -constraints {
+ unix stdio
+} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+ set env(TCL_LIBRARY) [info library]
makeDirectory tmp
makeDirectory [file join tmp sparkly]
makeDirectory [file join tmp sparkly bin]
@@ -201,17 +221,23 @@ test unixInit-2.6 {TclpInitLibraryPath: executable relative} \
makeDirectory [file join tmp sparkly lib]
makeDirectory [file join tmp sparkly lib tcl[info tclversion]]
makeFile {} [file join tmp sparkly lib tcl[info tclversion] init.tcl]
-
- set x [lrange [getlibpath [file join [temporaryDirectory] tmp sparkly \
- bin tcltest]] 2 3]
+} -body {
+ lrange [getlibpath [file join [temporaryDirectory] tmp sparkly \
+ bin tcltest]] 1 2
+} -cleanup {
removeFile [file join tmp sparkly lib tcl[info tclversion] init.tcl]
removeDirectory [file join tmp sparkly lib tcl[info tclversion]]
removeDirectory [file join tmp sparkly lib]
removeDirectory [file join tmp sparkly bin]
removeDirectory [file join tmp sparkly]
removeDirectory tmp
- set x
-} [list [temporaryDirectory]/tmp/sparkly/lib/tcl[info tclversion] [temporaryDirectory]/tmp/lib/tcl[info tclversion]]
+ unset env(TCL_LIBRARY)
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result [list [temporaryDirectory]/tmp/sparkly/lib/tcl[info tclversion] [temporaryDirectory]/tmp/lib/tcl[info tclversion]]
+
test unixInit-2.7 {TclpInitLibraryPath: compiled-in library path} \
{emptyTest unix} {
# would need test command to get defaultLibDir and compare it to
@@ -226,7 +252,14 @@ test unixInit-2.7 {TclpInitLibraryPath: compiled-in library path} \
testConstraint noSparkly [expr {![file exists [file join /tmp sparkly]]}]
testConstraint noTmpInstall [expr {![file exists \
[file join /tmp lib tcl[info tclversion]]]}]
-test unixInit-2.8 {TclpInitLibraryPath: all absolute pathtype} {unix noSparkly noTmpInstall } {
+test unixInit-2.8 {TclpInitLibraryPath: all absolute pathtype} -constraints {
+ unix noSparkly noTmpInstall
+} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+ set env(TCL_LIBRARY) [info library]
# Checking for Bug 219416
# When a program that embeds the Tcl library, like tcltest, is
# installed near the "root" of the file system, there was a problem
@@ -261,6 +294,7 @@ test unixInit-2.8 {TclpInitLibraryPath: all absolute pathtype} {unix noSparkly n
# ../lib/tcl$version relative to the executable.
file mkdir /tmp/lib/tcl[info tclversion]
close [open /tmp/lib/tcl[info tclversion]/init.tcl w]
+} -body {
# Check that all directories in the library path are absolute pathnames
set allAbsolute 1
@@ -268,16 +302,29 @@ test unixInit-2.8 {TclpInitLibraryPath: all absolute pathtype} {unix noSparkly n
set allAbsolute [expr {$allAbsolute \
&& [string equal absolute [file pathtype $dir]]}]
}
+ set allAbsolute
+} -cleanup {
# Clean up temporary installation
file delete -force /tmp/sparkly
file delete -force /tmp/lib/tcl[info tclversion]
if {$deletelib} {file delete -force /tmp/lib}
- set allAbsolute
-} 1
+ unset env(TCL_LIBRARY)
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result 1
testConstraint noTmpBuild [expr {![file exists [file join /tmp library]]}]
-test unixInit-2.9 {TclpInitLibraryPath: paths relative to executable} {unix noSparkly noTmpBuild } {
+test unixInit-2.9 {TclpInitLibraryPath: paths relative to executable} -constraints {
+ unix noSparkly noTmpBuild
+} -setup {
# Checking for Bug 438014
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+ set env(TCL_LIBRARY) [info library]
file delete -force /tmp/sparkly
file delete -force /tmp/library
file mkdir /tmp/sparkly
@@ -285,18 +332,27 @@ test unixInit-2.9 {TclpInitLibraryPath: paths relative to executable} {unix noSp
file mkdir /tmp/library/
close [open /tmp/library/init.tcl w]
-
- set x [lrange [getlibpath /tmp/sparkly/tcltest] 2 6]
-
+} -body {
+ lrange [getlibpath /tmp/sparkly/tcltest] 1 5
+} -cleanup {
file delete -force /tmp/sparkly
file delete -force /tmp/library
- set x
-} [list /tmp/lib/tcl[info tclversion] /lib/tcl[info tclversion] \
+ unset env(TCL_LIBRARY)
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result [list /tmp/lib/tcl[info tclversion] /lib/tcl[info tclversion] \
/tmp/library /library /tcl[info patchlevel]/library]
test unixInit-2.10 {TclpInitLibraryPath: executable relative} -constraints {
unix stdio
} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+ set env(TCL_LIBRARY) [info library]
set tmpDir [makeDirectory tmp]
set sparklyDir [makeDirectory sparkly $tmpDir]
set execPath [file join [makeDirectory bin $sparklyDir] tcltest]
@@ -308,7 +364,7 @@ test unixInit-2.10 {TclpInitLibraryPath: executable relative} -constraints {
cd $libDir
} -body {
# Checking for Bug 832657
- set x [lrange [getlibpath [file join .. bin tcltest]] 4 5]
+ set x [lrange [getlibpath [file join .. bin tcltest]] 3 4]
foreach p $x {
lappend y [file normalize $p]
}
@@ -329,6 +385,11 @@ test unixInit-2.10 {TclpInitLibraryPath: executable relative} -constraints {
unset tmpDir
removeDirectory tmp
unset x p y
+ unset env(TCL_LIBRARY)
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
} -result [list [file join [temporaryDirectory] tmp sparkly library] \
[file join [temporaryDirectory] tmp library] ]