Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.2978
diff -u -r1.2978 ChangeLog
--- ChangeLog	16 Mar 2006 18:22:54 -0000	1.2978
+++ ChangeLog	16 Mar 2006 19:08:59 -0000
@@ -1,5 +1,10 @@
 2006-03-16  Andreas Kupries <andreask@activestate.com>
 
+	* tests/io.test (io-43.1 io-44.[1234]): Rewritten to be
+	  self-contained with regard to setup and cleanup. [Bug 681793].
+
+2006-03-16  Andreas Kupries <andreask@activestate.com>
+
 	* generic/tclIOUtil.c (TclGetOpenMode): Added the flag O_APPEND to
 	  the list of POSIX modes used when opening a file for
 	  'a'ppend. This enables the proper automatic seek-to-end-on-write
Index: tests/io.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/io.test,v
retrieving revision 1.69
diff -u -r1.69 io.test
--- tests/io.test	24 Aug 2005 17:56:24 -0000	1.69
+++ tests/io.test	16 Mar 2006 19:08:59 -0000
@@ -5344,13 +5344,6 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     set x
 } {initial foo eof}
 
-catch {close $f2}
-catch {close $f3}
 close $f
 makeFile "foo bar" foo
 
