From 45ba16a3055b23da16e3275473875be2d863443e Mon Sep 17 00:00:00 2001 From: Kevin B Kenny Date: Fri, 4 May 2007 14:59:06 +0000 Subject: * tests/encoding.test: Modified so that encoding tests happen in a private namespace, to avoid polluting the global one. This problem was discovered when running the test suite '-singleproc 1 -skip exec.test' because the 'path' variable in encoding.test conflicted with the one in io.test. * tests/io.test: Made more of the working variables private to the namespace. --- ChangeLog | 13 +++++++++++++ generic/tclIO.c | 4 ++-- tests/encoding.test | 45 ++++++++++++++++++++++++++++++--------------- tests/io.test | 11 ++++++++++- 4 files changed, 55 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index c93ec58..6659edb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-05-04 Kevin B. Kenny + + * generic/tclIO.c (TclFinalizeIOSubsystem): Added an initializer + to silence a spurious gcc warning about use of an uninitialized + variable. + * tests/encoding.test: Modified so that encoding tests happen + in a private namespace, to avoid polluting the global one. This + problem was discovered when running the test suite '-singleproc 1 + -skip exec.test' because the 'path' variable in encoding.test + conflicted with the one in io.test. + * tests/io.test: Made more of the working variables private to the + namespace. + 2007-05-02 Kevin B. Kenny * generic/tclTest.c (SimpleMatchInDirectory): Corrected a refcount diff --git a/generic/tclIO.c b/generic/tclIO.c index 26d9724..534556d 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -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: tclIO.c,v 1.120 2007/05/01 22:43:49 kennykb Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.121 2007/05/04 14:59:06 kennykb Exp $ */ #include "tclInt.h" @@ -247,7 +247,7 @@ void TclFinalizeIOSubsystem(void) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); - Channel *chanPtr; /* Iterates over open channels. */ + Channel *chanPtr = NULL; /* Iterates over open channels. */ ChannelState *statePtr; /* State of channel stack */ int active = 1; /* Flag == 1 while there's still work to do */ diff --git a/tests/encoding.test b/tests/encoding.test index 36eb475..a11f5cd 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -8,20 +8,28 @@ # 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.26 2006/11/03 00:34:52 hobbs Exp $ +# RCS: @(#) $Id: encoding.test,v 1.27 2007/05/04 14:59:06 kennykb Exp $ package require tcltest 2 + +namespace eval ::tcl::test::encoding { + variable x + namespace import -force ::tcltest::* proc toutf {args} { - global x + variable x lappend x "toutf $args" } proc fromutf {args} { - global x + variable x lappend x "fromutf $args" } +proc runtests {} { + + variable x + # Some tests require the testencoding command testConstraint testencoding [llength [info commands testencoding]] testConstraint exec [llength [info commands exec]] @@ -30,7 +38,7 @@ testConstraint exec [llength [info commands exec]] # TclFinalizeEncodingSubsystem is not currently tested test encoding-1.1 {Tcl_GetEncoding: system encoding} {testencoding} { - testencoding create foo toutf fromutf + testencoding create foo [namespace origin toutf] [namespace origin fromutf] set old [encoding system] encoding system foo set x {} @@ -40,7 +48,7 @@ test encoding-1.1 {Tcl_GetEncoding: system encoding} {testencoding} { set x } {{fromutf }} test encoding-1.2 {Tcl_GetEncoding: existing encoding} {testencoding} { - testencoding create foo toutf fromutf + testencoding create foo [namespace origin toutf] [namespace origin fromutf] set x {} encoding convertto foo abcd testencoding delete foo @@ -125,7 +133,8 @@ test encoding-5.2 {Tcl_SetSystemEncoding: test ref count} { } {0} test encoding-6.1 {Tcl_CreateEncoding: new} {testencoding} { - testencoding create foo {toutf 1} {fromutf 2} + testencoding create foo [namespace code {toutf 1}] \ + [namespace code {fromutf 2}] set x {} encoding convertfrom foo abcd encoding convertto foo abcd @@ -133,7 +142,8 @@ test encoding-6.1 {Tcl_CreateEncoding: new} {testencoding} { set x } {{toutf 1} {fromutf 2}} test encoding-6.2 {Tcl_CreateEncoding: replace encoding} {testencoding} { - testencoding create foo {toutf a} {fromutf b} + testencoding create foo [namespace code {toutf a}] \ + [namespace code {fromutf b}] set x {} encoding convertfrom foo abcd encoding convertto foo abcd @@ -329,14 +339,14 @@ test encoding-21.1 {EscapeToUtfProc} { test encoding-22.1 {EscapeFromUtfProc} { } {} -set ::iso2022encData "\u001b\$B;d\$I\$b\$G\$O!\"%A%C%W\$49XF~;~\$K\$4EPO?\$\$\$?\$@\$\$\$?\$4=;=j\$r%-%c%C%7%e%\"%&%H\$N:]\$N\u001b(B +set iso2022encData "\u001b\$B;d\$I\$b\$G\$O!\"%A%C%W\$49XF~;~\$K\$4EPO?\$\$\$?\$@\$\$\$?\$4=;=j\$r%-%c%C%7%e%\"%&%H\$N:]\$N\u001b(B \u001b\$B>.@Z reads size in chars, not raw bytes. set fid [open iso2022.txt r] @@ -379,7 +389,7 @@ test encoding-23.3 {iso2022-jp escape encoding test} { set data [read $fid 50] close $fid set data -} [string range $::iso2022uniData 0 49] ; # 0 .. 49 inclusive == 50 +} [string range $iso2022uniData 0 49] ; # 0 .. 49 inclusive == 50 cd [workingDirectory] test encoding-24.1 {EscapeFreeProc on open channels} -constraints { @@ -575,7 +585,12 @@ file delete {*}[glob -directory [temporaryDirectory] *.chars *.tcltestout] # EscapeFreeProc, GetTableEncoding, unilen # are fully tested by the rest of this file +} +runtests + +} # cleanup +namespace delete ::tcl::test::encoding ::tcltest::cleanupTests return diff --git a/tests/io.test b/tests/io.test index 2ba2183..f74b078 100644 --- a/tests/io.test +++ b/tests/io.test @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: io.test,v 1.75 2006/12/27 01:25:35 mdejong Exp $ +# RCS: @(#) $Id: io.test,v 1.76 2007/05/04 14:59:06 kennykb Exp $ if {[catch {package require tcltest 2}]} { puts stderr "Skipping tests in [info script]. tcltest 2 required." @@ -22,6 +22,15 @@ if {[catch {package require tcltest 2}]} { namespace eval ::tcl::test::io { namespace import ::tcltest::* + variable umaskValue + variable path + variable f + variable i + variable n + variable v + variable msg + variable expected + testConstraint testchannel [llength [info commands testchannel]] testConstraint exec [llength [info commands exec]] testConstraint openpipe 1 -- cgit v0.12