diff options
author | andreas_kupries <akupries@shaw.ca> | 2008-04-04 20:13:17 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2008-04-04 20:13:17 (GMT) |
commit | af0c3541192d9fdf06f543f52649706e29a77ae8 (patch) | |
tree | 499af96c2ce17757519720631bb97cb037660306 /tests | |
parent | 3554b9e788ccb6740c210c1d3d1c8f01eea7a6fc (diff) | |
download | tcl-af0c3541192d9fdf06f543f52649706e29a77ae8.zip tcl-af0c3541192d9fdf06f543f52649706e29a77ae8.tar.gz tcl-af0c3541192d9fdf06f543f52649706e29a77ae8.tar.bz2 |
* tests/io.test (io-53.9): Added testcase for [Bug 780533], based
* tests/chanio.test: on Alexandre's test script. Also fixed
problem with timer in preceding test, was not canceled properly
in the ok case.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/chanio.test | 54 | ||||
-rw-r--r-- | tests/io.test | 54 |
2 files changed, 102 insertions, 6 deletions
diff --git a/tests/chanio.test b/tests/chanio.test index c2a6940..027e4c0 100644 --- a/tests/chanio.test +++ b/tests/chanio.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: chanio.test,v 1.3.2.1 2008/04/03 18:06:26 andreas_kupries Exp $ +# RCS: @(#) $Id: chanio.test,v 1.3.2.2 2008/04/04 20:13:23 andreas_kupries Exp $ if {[catch {package require tcltest 2}]} { chan puts stderr "Skipping tests in [info script]. tcltest 2 required." @@ -6915,11 +6915,12 @@ test chan-io-53.8 {CopyData: async callback and error handling, Bug 1932639} -se lappend ::RES [expr {($sbs > 0) ? "sync/FAIL" : "sync/OK"}] $sbs # Now let the async part happen. Should capture the error in cmd # via bgerror. If not break the event loop via timer. - after 1000 { + set token [after 1000 { lappend ::RES {bgerror/FAIL timeout} set ::forever has-been-reached - } + }] vwait ::forever + catch {after cancel $token} # Report set ::RES } -cleanup { @@ -6932,6 +6933,53 @@ test chan-io-53.8 {CopyData: async callback and error handling, Bug 1932639} -se removeFile foo removeFile bar } -result {0 sync/OK 0 {CMD 2} {bgerror/OK !STOP}} +test chan-io-53.9 {CopyData: -size and event interaction, Bug 780533} -setup { + set out [makeFile {} out] + set err [makeFile {} err] + set pipe [open "|[info nameofexecutable] 2> $err" r+] + chan configure $pipe -translation binary -buffering line + chan puts $pipe { + chan configure stdout -translation binary -buffering line + chan puts stderr Waiting... + after 1000 + foreach x {a b c} { + chan puts stderr Looping... + chan puts $x + after 500 + } + proc bye args { + if {[chan gets stdin line]<0} { + chan puts stderr "CHILD: EOF detected, exiting" + exit + } else { + chan puts stderr "CHILD: ignoring line: $line" + } + } + chan puts stderr Now-sleeping-forever + chan event stdin readable bye + vwait forever + } + proc ::done args { + set ::forever OK + return + } + set ::forever {} + set out [open $out w] +} -constraints {stdio openpipe fcopy} -body { + chan copy $pipe $out -size 6 -command ::done + set token [after 5000 { + set ::forever {fcopy hangs} + }] + vwait ::forever + catch {after cancel $token} + set ::forever +} -cleanup { + chan close $pipe + rename ::done {} + removeFile out + removeFile err + catch {unset ::forever} +} -result OK test chan-io-54.1 {Recursive channel events} {socket fileevent} { # This test checks to see if file events are delivered during recursive diff --git a/tests/io.test b/tests/io.test index 86ccddc..918de33 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.80.2.1 2008/04/03 18:06:25 andreas_kupries Exp $ +# RCS: @(#) $Id: io.test,v 1.80.2.2 2008/04/04 20:13:22 andreas_kupries Exp $ if {[catch {package require tcltest 2}]} { puts stderr "Skipping tests in [info script]. tcltest 2 required." @@ -6915,10 +6915,11 @@ test io-53.8 {CopyData: async callback and error handling, Bug 1932639} -setup { lappend ::RES [expr {($sbs > 0) ? "sync/FAIL" : "sync/OK"}] $sbs # Now let the async part happen. Should capture the error in cmd # via bgerror. If not break the event loop via timer. - after 1000 { + set token [after 1000 { lappend ::RES {bgerror/FAIL timeout} set ::forever has-been-reached - } + }] + catch {after cancel $token} vwait ::forever # Report set ::RES @@ -6932,6 +6933,53 @@ test io-53.8 {CopyData: async callback and error handling, Bug 1932639} -setup { removeFile foo removeFile bar } -result {0 sync/OK 0 {CMD 2} {bgerror/OK !STOP}} +test io-53.9 {CopyData: -size and event interaction, Bug 780533} -setup { + set out [makeFile {} out] + set err [makeFile {} err] + set pipe [open "|[info nameofexecutable] 2> $err" r+] + fconfigure $pipe -translation binary -buffering line + puts $pipe { + fconfigure stdout -translation binary -buffering line + puts stderr Waiting... + after 1000 + foreach x {a b c} { + puts stderr Looping... + puts $x + after 500 + } + proc bye args { + if {[gets stdin line]<0} { + puts stderr "CHILD: EOF detected, exiting" + exit + } else { + puts stderr "CHILD: ignoring line: $line" + } + } + puts stderr Now-sleeping-forever + fileevent stdin readable bye + vwait forever + } + proc ::done args { + set ::forever OK + return + } + set ::forever {} + set out [open $out w] +} -constraints {stdio openpipe fcopy} -body { + fcopy $pipe $out -size 6 -command ::done + set token [after 5000 { + set ::forever {fcopy hangs} + }] + vwait ::forever + catch {after cancel $token} + set ::forever +} -cleanup { + close $pipe + rename ::done {} + removeFile out + removeFile err + catch {unset ::forever} +} -result OK test io-54.1 {Recursive channel events} {socket fileevent} { # This test checks to see if file events are delivered during recursive |