summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/io.test55
1 files changed, 36 insertions, 19 deletions
diff --git a/tests/io.test b/tests/io.test
index 4edb308..f1299af 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.69 2005/08/24 17:56:24 andreas_kupries Exp $
+# RCS: @(#) $Id: io.test,v 1.70 2006/03/16 19:12:17 andreas_kupries Exp $
if {[catch {package require tcltest 2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2 required."
@@ -5344,13 +5344,6 @@ test io-42.3 {Tcl_FileeventCmd: replacing, with NULL chars in script} {fileevent
lappend result [fileevent $f readable]
} {13 11 12 {}}
-#
-# Test fileevent on a pipe
-#
-if {[testConstraint openpipe]} {
- catch {set f2 [open "|[list cat -u]" r+]}
- catch {set f3 [open "|[list cat -u]" r+]}
-}
test io-43.1 {Tcl_FileeventCmd: creating, deleting, querying} {stdio unixExecs fileevent} {
set result {}
@@ -5363,7 +5356,10 @@ test io-43.1 {Tcl_FileeventCmd: creating, deleting, querying} {stdio unixExecs f
fileevent $f writable {}
lappend result [fileevent $f readable] [fileevent $f writable]
} {{script 1} {} {script 1} {write script} {} {write script} {} {}}
-test io-43.2 {Tcl_FileeventCmd: deleting when many present} {stdio unixExecs fileevent} {
+test io-43.2 {Tcl_FileeventCmd: deleting when many present} -setup {
+ set f2 [open "|[list cat -u]" r+]
+ set f3 [open "|[list cat -u]" r+]
+} -constraints {stdio unixExecs fileevent openpipe} -body {
set result {}
lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r]
fileevent $f r "read f"
@@ -5376,9 +5372,15 @@ test io-43.2 {Tcl_FileeventCmd: deleting when many present} {stdio unixExecs fil
lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r]
fileevent $f r {}
lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r]
-} {{} {} {} {read f} {read f2} {read f3} {read f} {} {read f3} {read f} {} {} {} {} {}}
-
-test io-44.1 {FileEventProc procedure: normal read event} {stdio unixExecs fileevent} {
+} -cleanup {
+ catch {close $f2}
+ catch {close $f3}
+} -result {{} {} {} {read f} {read f2} {read f3} {read f} {} {read f3} {read f} {} {} {} {} {}}
+
+test io-44.1 {FileEventProc procedure: normal read event} -setup {
+ set f2 [open "|[list cat -u]" r+]
+ set f3 [open "|[list cat -u]" r+]
+} -constraints {stdio unixExecs fileevent openpipe} -body {
fileevent $f2 readable [namespace code {
set x [gets $f2]; fileevent $f2 readable {}
}]
@@ -5386,10 +5388,15 @@ test io-44.1 {FileEventProc procedure: normal read event} {stdio unixExecs filee
variable x initial
vwait [namespace which -variable x]
set x
-} {text}
+} -cleanup {
+ catch {close $f2}
+ catch {close $f3}
+} -result {text}
test io-44.2 {FileEventProc procedure: error in read event} -constraints {
- stdio unixExecs fileevent
+ stdio unixExecs fileevent openpipe
} -setup {
+ set f2 [open "|[list cat -u]" r+]
+ set f3 [open "|[list cat -u]" r+]
proc myHandler {msg options} {
variable x $msg
}
@@ -5403,8 +5410,13 @@ test io-44.2 {FileEventProc procedure: error in read event} -constraints {
list $x [fileevent $f2 readable]
} -cleanup {
interp bgerror {} $handler
+ catch {close $f2}
+ catch {close $f3}
} -result {bogus {}}
-test io-44.3 {FileEventProc procedure: normal write event} {stdio unixExecs fileevent} {
+test io-44.3 {FileEventProc procedure: normal write event} -setup {
+ set f2 [open "|[list cat -u]" r+]
+ set f3 [open "|[list cat -u]" r+]
+} -constraints {stdio unixExecs fileevent openpipe} -body {
fileevent $f2 writable [namespace code {
lappend x "triggered"
incr count -1
@@ -5418,10 +5430,15 @@ test io-44.3 {FileEventProc procedure: normal write event} {stdio unixExecs file
vwait [namespace which -variable x]
vwait [namespace which -variable x]
set x
-} {initial triggered triggered triggered}
+} -cleanup {
+ catch {close $f2}
+ catch {close $f3}
+} -result {initial triggered triggered triggered}
test io-44.4 {FileEventProc procedure: eror in write event} -constraints {
- stdio unixExecs fileevent
+ stdio unixExecs fileevent openpipe
} -setup {
+ set f2 [open "|[list cat -u]" r+]
+ set f3 [open "|[list cat -u]" r+]
proc myHandler {msg options} {
variable x $msg
}
@@ -5434,6 +5451,8 @@ test io-44.4 {FileEventProc procedure: eror in write event} -constraints {
list $x [fileevent $f2 writable]
} -cleanup {
interp bgerror {} $handler
+ catch {close $f2}
+ catch {close $f3}
} -result {bad-write {}}
test io-44.5 {FileEventProc procedure: end of file} {stdio unixExecs openpipe fileevent} {
set f4 [open "|[list [interpreter] $path(cat) << foo]" r]
@@ -5452,8 +5471,6 @@ test io-44.5 {FileEventProc procedure: end of file} {stdio unixExecs openpipe fi
set x
} {initial foo eof}
-catch {close $f2}
-catch {close $f3}
close $f
makeFile "foo bar" foo