diff options
Diffstat (limited to 'tests/io.test')
-rw-r--r-- | tests/io.test | 121 |
1 files changed, 61 insertions, 60 deletions
diff --git a/tests/io.test b/tests/io.test index aba370b..7b89bda 100644 --- a/tests/io.test +++ b/tests/io.test @@ -12,10 +12,11 @@ # 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.8 1999/06/09 17:06:00 hershey Exp $ +# RCS: @(#) $Id: io.test,v 1.9 1999/06/26 03:54:15 jenn Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] + package require tcltest + namespace import ::tcltest::* } if {"[info commands testchannel]" != "testchannel"} { @@ -114,7 +115,7 @@ test io-1.4 {unsupported0 command} {knownBug unixOrPc} { puts $f1 {puts [read $f1 100]} puts $f1 {close $f1} close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] gets $f1 puts $f1 ready flush $f1 @@ -450,7 +451,7 @@ test io-6.6 {Tcl_GetsObj: loop test} { test io-6.7 {Tcl_GetsObj: error in input} {stdio} { # if (FilterInputBytes(chanPtr, &gs) != 0) - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] puts -nonewline $f "hi\nwould" flush $f gets $f @@ -712,7 +713,7 @@ test io-6.30 {Tcl_GetsObj: crlf mode: buffer exhausted} { test io-6.31 {Tcl_GetsObj: crlf mode: buffer exhausted, blocked} {stdio} { # (FilterInputBytes() != 0) - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {crlf lf} -buffering none puts -nonewline $f "bbbbbbbbbbbbbb\r\n123456789012345\r" fconfigure $f -buffersize 16 @@ -851,7 +852,7 @@ test io-6.42 {Tcl_GetsObj: auto mode: several chars} { test io-6.43 {Tcl_GetsObj: input saw cr} {stdio} { # if (chanPtr->flags & INPUT_SAW_CR) - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {auto lf} -buffering none puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r" fconfigure $f -buffersize 16 @@ -868,7 +869,7 @@ test io-6.43 {Tcl_GetsObj: input saw cr} {stdio} { test io-6.44 {Tcl_GetsObj: input saw cr, not followed by cr} {stdio} { # not (*eol == '\n') - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {auto lf} -buffering none puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r" fconfigure $f -buffersize 16 @@ -885,7 +886,7 @@ test io-6.44 {Tcl_GetsObj: input saw cr, not followed by cr} {stdio} { test io-6.45 {Tcl_GetsObj: input saw cr, skip right number of bytes} {stdio} { # Tcl_ExternalToUtf() - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {auto lf} -buffering none fconfigure $f -encoding unicode puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r" @@ -902,7 +903,7 @@ test io-6.45 {Tcl_GetsObj: input saw cr, skip right number of bytes} {stdio} { test io-6.46 {Tcl_GetsObj: input saw cr, followed by just \n should give eof} {stdio} { # memmove() - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {auto lf} -buffering none puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r" fconfigure $f -buffersize 16 @@ -1026,7 +1027,7 @@ test io-6.55 {Tcl_GetsObj: overconverted} { } [list 8 "there\u4e00ok" 11 "\u4e01more bytes" 4 "here"] test io-6.56 {Tcl_GetsObj: incomplete lines should disable file events} {stdio} { update - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -buffering none puts -nonewline $f "foobar" fconfigure $f -blocking 0 @@ -1085,7 +1086,7 @@ test io-7.3 {FilterInputBytes: split up character at EOF} { set x } [list 15 "1234567890123\uff10\uff11" 18 0 1 -1 ""] test io-7.4 {FilterInputBytes: recover from split up character} {stdio} { - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -encoding binary -buffering none puts -nonewline $f "1234567890123\x82\x4f\x82\x50\x82" fconfigure $f -encoding shiftjis -blocking 0 @@ -1121,7 +1122,7 @@ test io-8.1 {PeekAhead: only go to device if no more cached data} { test io-8.2 {PeekAhead: only go to device if no more cached data} {stdio} { # not (bufPtr->nextPtr == NULL) - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation lf -encoding ascii -buffering none puts -nonewline $f "123456789012345\r\nbcdefghijklmnopqrstuvwxyz" set x {} @@ -1140,7 +1141,7 @@ test io-8.2 {PeekAhead: only go to device if no more cached data} {stdio} { test io-8.3 {PeekAhead: no cached data available} {stdio} { # (bytesLeft == 0) - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {auto binary} puts -nonewline $f "abcdefghijklmno\r" flush $f @@ -1173,7 +1174,7 @@ unset a test io-8.5 {PeekAhead: don't peek if last read was short} {stdio} { # (bufPtr->nextAdded < bufPtr->length) - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {auto binary} puts -nonewline $f "abcdefghijklmno\r" flush $f @@ -1185,7 +1186,7 @@ test io-8.5 {PeekAhead: don't peek if last read was short} {stdio} { test io-8.6 {PeekAhead: change to non-blocking mode} {stdio} { # ((chanPtr->flags & CHANNEL_NONBLOCKING) == 0) - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {auto binary} -buffersize 16 puts -nonewline $f "abcdefghijklmno\r" flush $f @@ -1197,7 +1198,7 @@ test io-8.6 {PeekAhead: change to non-blocking mode} {stdio} { test io-8.7 {PeekAhead: cleanup} {stdio} { # Make sure bytes are removed from buffer. - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -translation {auto binary} -buffering none puts -nonewline $f "abcdefghijklmno\r" # here @@ -1363,7 +1364,7 @@ test io-12.3 {ReadChars: allocate more space} { test io-12.4 {ReadChars: split-up char} {stdio} { # (srcRead == 0) - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -encoding binary -buffering none -buffersize 16 puts -nonewline $f "123456789012345\x96" fconfigure $f -encoding shiftjis -blocking 0 @@ -1391,7 +1392,7 @@ test io-12.5 {ReadChars: fileevents on partial characters} {stdio} { gets stdin; puts -nonewline "\x89" gets stdin; puts -nonewline "\xa6" } test1 - set f [open "|[list $tcltest test1]" r+] + set f [open "|[list $::tcltest::tcltest test1]" r+] fileevent $f readable { lappend x [read $f] if {[eof $f]} { @@ -1483,7 +1484,7 @@ test io-13.6 {TranslateInputEOL: auto mode: saw cr in last segment} {stdio} { # (chanPtr->flags & INPUT_SAW_CR) # This test may fail on slower machines. - set f [open "|[list $tcltest cat]" w+] + set f [open "|[list $::tcltest::tcltest cat]" w+] fconfigure $f -blocking 0 -buffering none -translation {auto lf} fileevent $f read "ready $f" @@ -1623,7 +1624,7 @@ test io-14.3 {Tcl_SetStdChannel & Tcl_GetStdChannel} {stdio} { close $f3 } close $f - set result [exec $tcltest test1] + set result [exec $::tcltest::tcltest test1] set f [open test2 r] set f2 [open test3 r] lappend result [read $f] [read $f2] @@ -1651,7 +1652,7 @@ test io-14.4 {Tcl_SetStdChannel & Tcl_GetStdChannel} {unixOnly} { close $f3 } close $f - set result [exec $tcltest test1] + set result [exec $::tcltest::tcltest test1] set f [open test2 r] set f2 [open test3 r] lappend result [read $f] [read $f2] @@ -1706,7 +1707,7 @@ test io-14.8 {reuse of stdio special channels} {stdio} { puts [gets $f] } close $f - set f [open "|[list $tcltest script]" r] + set f [open "|[list $::tcltest::tcltest script]" r] set c [gets $f] close $f set c @@ -1724,7 +1725,7 @@ test io-14.9 {reuse of stdio special channels} {stdio} { puts [gets $f] } close $f - set f [open "|[list $tcltest script]" r] + set f [open "|[list $::tcltest::tcltest script]" r] set c [gets $f] close $f set c @@ -1901,7 +1902,7 @@ test io-20.5 {Tcl_CreateChannel: install channel in empty slot} {stdio} { puts stderr [fconfigure stdout -buffersize] } close $f - set f [open "|[list $tcltest script]"] + set f [open "|[list $::tcltest::tcltest script]"] catch {close $f} msg set msg } {777} @@ -1968,7 +1969,7 @@ test io-26.1 {Tcl_GetChannelInstanceData} {stdio} { # "pid" command uses Tcl_GetChannelInstanceData # Don't care what pid is (but must be a number), just want to exercise it. - set f [open "|[list $tcltest << exit]"] + set f [open "|[list $::tcltest::tcltest << exit]"] expr [pid $f] close $f } {} @@ -2059,7 +2060,7 @@ test io-27.6 {FlushChannel, async flushing, async close} \ } set f [open output w] close $f - set f [open "|[list $tcltest pipe]" w] + set f [open "|[list $::tcltest::tcltest pipe]" w] fconfigure $f -blocking off puts -nonewline $f $x close $f @@ -2135,7 +2136,7 @@ test io-28.3 {CloseChannel, not called before output queue is empty} \ } set f [open output w] close $f - set f [open "|[list $tcltest pipe]" r+] + set f [open "|[list $::tcltest::tcltest pipe]" r+] fconfigure $f -blocking off -eofchar {} puts -nonewline $f $x @@ -2173,7 +2174,7 @@ test io-28.5 {Tcl_Close vs standard handles} {stdio unixOnly} { puts [testchannel open] } close $f - set f [open "|[list $tcltest script]" r] + set f [open "|[list $::tcltest::tcltest script]" r] set l [gets $f] close $f set l @@ -2316,7 +2317,7 @@ test io-29.12 {Tcl_WriteChars on a pipe} {stdio} { } } close $f1 - set f1 [open "|[list $tcltest pipe]" r] + set f1 [open "|[list $::tcltest::tcltest pipe]" r] set f2 [open longfile r] set y ok for {set x 0} {$x < 10} {incr x} { @@ -2340,7 +2341,7 @@ test io-29.13 {Tcl_WriteChars to a pipe, line buffered} {stdio} { } close $f1 set y ok - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] fconfigure $f1 -buffering line set f2 [open longfile r] set line [gets $f2] @@ -2382,7 +2383,7 @@ test io-29.15 {Tcl_Flush, channel not open for writing} { [list 1 "channel \"$fd\" wasn't opened for writing"] } 0 test io-29.16 {Tcl_Flush on pipe opened only for reading} {stdio} { - set fd [open "|[list $tcltest cat longfile]" r] + set fd [open "|[list $::tcltest::tcltest cat longfile]" r] set x [list [catch {flush $fd} msg] $msg] catch {close $fd} string compare $x \ @@ -2462,7 +2463,7 @@ test io-29.21 {Tcl_Flush to pipe} {stdio} { puts $f1 {set cnt [string length $x]} puts $f1 {puts "read $cnt characters"} close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] puts $f1 hello flush $f1 set x [gets $f1] @@ -2482,7 +2483,7 @@ test io-29.22 {Tcl_Flush called at other end of pipe} {stdio} { flush stdout } close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] set x "" lappend x [gets $f1] lappend x [gets $f1] @@ -2502,7 +2503,7 @@ test io-29.23 {Tcl_Flush and line buffering at end of pipe} {stdio} { puts bye } close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] set x "" lappend x [gets $f1] lappend x [gets $f1] @@ -2529,7 +2530,7 @@ test io-29.24 {Tcl_WriteChars and Tcl_Flush move end of file} { } "{} {Line 1\nLine 2}" test io-29.25 {Implicit flush with Tcl_Flush to command pipelines} {stdio} { removeFile test3 - set f [open "|[list $tcltest cat | $tcltest cat > test3]" w] + set f [open "|[list $::tcltest::tcltest cat | $::tcltest::tcltest cat > test3]" w] puts $f "Line 1" puts $f "Line 2" close $f @@ -2552,7 +2553,7 @@ test io-29.27 {Tcl_Flush on closed pipeline} {stdio} { set f [open pipe w] puts $f {exit} close $f - set f [open "|[list $tcltest pipe]" r+] + set f [open "|[list $::tcltest::tcltest pipe]" r+] gets $f puts $f output after 50 @@ -2621,7 +2622,7 @@ test io-29.31 {Tcl_WriteChars, background flush} {stdio} { } set f [open output w] close $f - set f [open "|[list $tcltest pipe]" r+] + set f [open "|[list $::tcltest::tcltest pipe]" r+] fconfigure $f -blocking off puts -nonewline $f $x close $f @@ -2659,7 +2660,7 @@ test io-29.32 {Tcl_WriteChars, background flush to slow reader} \ } set f [open output w] close $f - set f [open "|[list $tcltest pipe]" r+] + set f [open "|[list $::tcltest::tcltest pipe]" r+] fconfigure $f -blocking off puts -nonewline $f $x close $f @@ -2685,7 +2686,7 @@ test io-29.33 {Tcl_Flush, implicit flush on exit} {stdio} { puts $f strange } close $f - exec $tcltest script + exec $::tcltest::tcltest script set f [open test1 r] set r [read $f] close $f @@ -3886,7 +3887,7 @@ test io-32.10 {Tcl_Read from a pipe} {stdio} { set f1 [open pipe w] puts $f1 {puts [gets stdin]} close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] puts $f1 hello flush $f1 set x [read $f1] @@ -3899,7 +3900,7 @@ test io-32.11 {Tcl_Read from a pipe} {stdio} { puts $f1 {puts [gets stdin]} puts $f1 {puts [gets stdin]} close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] puts $f1 hello flush $f1 set x "" @@ -4008,7 +4009,7 @@ test io-33.3 {Tcl_Gets from pipe} {stdio} { set f1 [open pipe w] puts $f1 {puts [gets stdin]} close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] puts $f1 hello flush $f1 set x [gets $f1] @@ -4201,7 +4202,7 @@ test io-34.7 {Tcl_Seek to offset from end of file, then to current position} { list $c1 $r1 $c2 } {44 rstuv 49} test io-34.8 {Tcl_Seek on pipes: not supported} {stdio} { - set f1 [open "|[list $tcltest]" r+] + set f1 [open "|[list $::tcltest::tcltest]" r+] set x [list [catch {seek $f1 0 current} msg] $msg] close $f1 regsub {".*":} $x {"":} x @@ -4308,13 +4309,13 @@ test io-34.15 {Tcl_Tell combined with seeking} { list $c1 $c2 } {10 20} test io-34.16 {Tcl_tell on pipe: always -1} {stdio} { - set f1 [open "|[list $tcltest]" r+] + set f1 [open "|[list $::tcltest::tcltest]" r+] set c [tell $f1] close $f1 set c } -1 test io-34.17 {Tcl_Tell on pipe: always -1} {stdio} { - set f1 [open "|[list $tcltest]" r+] + set f1 [open "|[list $::tcltest::tcltest]" r+] puts $f1 {puts hello} flush $f1 set c [tell $f1] @@ -4396,7 +4397,7 @@ test io-35.2 {Tcl_Eof with pipe} {stdio} { puts $f1 {gets stdin} puts $f1 {puts hello} close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] puts $f1 hello set x [eof $f1] flush $f1 @@ -4414,7 +4415,7 @@ test io-35.3 {Tcl_Eof with pipe} {stdio} { puts $f1 {gets stdin} puts $f1 {puts hello} close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] puts $f1 hello set x [eof $f1] flush $f1 @@ -4449,7 +4450,7 @@ test io-35.5 {Tcl_Eof, eof detection on nonblocking pipe} {stdio} { exit } close $f - set f [open "|[list $tcltest pipe]" r] + set f [open "|[list $::tcltest::tcltest pipe]" r] set l "" lappend l [gets $f] lappend l [eof $f] @@ -4634,7 +4635,7 @@ test io-35.17 {Tcl_Eof, eof char in middle, crlf write, crlf read} { # Test Tcl_InputBlocked test io-36.1 {Tcl_InputBlocked on nonblocking pipe} {stdio} { - set f1 [open "|[list $tcltest]" r+] + set f1 [open "|[list $::tcltest::tcltest]" r+] puts $f1 {puts hello_from_pipe} flush $f1 gets $f1 @@ -4653,7 +4654,7 @@ test io-36.1 {Tcl_InputBlocked on nonblocking pipe} {stdio} { set x } {{} 1 hello 0 {} 1} test io-36.2 {Tcl_InputBlocked on blocking pipe} {stdio} { - set f1 [open "|[list $tcltest]" r+] + set f1 [open "|[list $::tcltest::tcltest]" r+] fconfigure $f1 -buffering line puts $f1 {puts hello_from_pipe} set x "" @@ -4913,7 +4914,7 @@ test io-39.10 {Tcl_SetChannelOption, blocking mode} {stdio} { } close $f1 set x "" - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] fconfigure $f1 -blocking off -buffering line lappend x [fconfigure $f1 -blocking] lappend x [gets $f1] @@ -4994,7 +4995,7 @@ test io-39.16 {Tcl_SetChannelOption: -encoding, errors} { set result } {1 {unknown encoding "foobar"}} test io-39.17 {Tcl_SetChannelOption: -encoding, clearing CHANNEL_NEED_MORE_DATA} {stdio} { - set f [open "|[list $tcltest cat]" r+] + set f [open "|[list $::tcltest::tcltest cat]" r+] fconfigure $f -encoding binary puts -nonewline $f "\xe7" flush $f @@ -5377,7 +5378,7 @@ test io-44.4 {FileEventProc procedure: eror in write event} {stdio unixExecs} { list $x [fileevent $f2 writable] } {bad-write {}} test io-44.5 {FileEventProc procedure: end of file} {stdio unixExecs} { - set f4 [open "|[list $tcltest cat << foo]" r] + set f4 [open "|[list $::tcltest::tcltest cat << foo]" r] fileevent $f4 readable { if {[gets $f4 line] < 0} { lappend x eof @@ -5670,7 +5671,7 @@ test io-48.3 {testing readability conditions} {unixOnly nonBlockFiles} { } } close $f - set f [open "|[list $tcltest]" r+] + set f [open "|[list $::tcltest::tcltest]" r+] fileevent $f readable [list consume $f] fconfigure $f -buffering line fconfigure $f -blocking off @@ -6422,7 +6423,7 @@ test io-52.8 {TclCopyChannel} {stdio} { close \$f1 " close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] fconfigure $f1 -translation lf gets $f1 puts $f1 ready @@ -6480,7 +6481,7 @@ test io-53.3 {CopyData: background read underflow} {unixOnly} { close $f } close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] set result [gets $f1] puts $f1 line1 flush $f1 @@ -6513,7 +6514,7 @@ test io-53.4 {CopyData: background write overflow} {unixOnly} { close $f } close $f1 - set f1 [open "|[list $tcltest pipe]" r+] + set f1 [open "|[list $::tcltest::tcltest pipe]" r+] set result [gets $f1] fconfigure $f1 -blocking 0 puts $f1 $big @@ -6566,7 +6567,7 @@ test io-53.6 {CopyData: error during fcopy} {stdio} { set f1 [open pipe w] puts $f1 "exit 1" close $f1 - set in [open "|[list $tcltest pipe]" r+] + set in [open "|[list $::tcltest::tcltest pipe]" r+] set out [open test1 w] fcopy $in $out -command [list FcopyTestDone] if ![info exists fcopyTestDone] { @@ -6780,7 +6781,7 @@ test io-58.1 {Tcl_NotifyChannel and error when closing} {unixOrPc} { } } close $out - set pipe [open "|[list $tcltest] script" r] + set pipe [open "|[list $::tcltest::tcltest] script" r] fileevent $pipe readable [list readit $pipe] set x "" set result "" @@ -6793,7 +6794,7 @@ foreach file [list fooBar longfile script output test1 pipe my_script foo \ bar test2 test3 cat stdout] { ::tcltest::removeFile $file } -restoreState +::tcltest::restoreState ::tcltest::cleanupTests return |