Subject: [Bug 3605120]: Stop test chan-io-28.7 from hanging when run standalone.

From: dkf <[email-masked]>
Date: Tue, 26 Feb 2013 13:37:42 +0000

---
 ChangeLog         |  5 +++++
 tests/chanio.test | 14 +++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2036b9c..7453768 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-26  Donal K. Fellows  <[email-masked]>
+
+	* tests/chanio.test (chan-io-28.7): [Bug 3605120]: Stop test from
+	hanging when run standalone.
+
 2013-02-26  Jan Nijtmans  <[email-masked]>
 
 	* generic/tclObj.c: Don't panic if Tcl_ConvertToType is called for a
diff --git a/tests/chanio.test b/tests/chanio.test
index 665df50..999d0bb 100644
--- a/tests/chanio.test
+++ b/tests/chanio.test
@@ -2214,13 +2214,17 @@ test chan-io-28.7 {Tcl_CloseEx (half-close) socket} -setup {
 	puts $sok DONE
 	exit 0
     } echo.tcl]
-} -body {
+    variable done
+    unset -nocomplain done
+    set done ""
+    set timer ""
     set ff [openpipe r $echo]
     gets $ff port
+} -body {
     set s [socket 127.0.0.1 $port]
     puts $s Hey
     close $s w
-    set timer [after 1000 [namespace code {set ::done Failed}]]
+    set timer [after 1000 [namespace code {set done Failed}]]
     set acc {}
     fileevent $s readable [namespace code {
 	if {[gets $s line]<0} {
@@ -2230,11 +2234,11 @@ test chan-io-28.7 {Tcl_CloseEx (half-close) socket} -setup {
 	}
     }]
     vwait [namespace which -variable done]
-    after cancel $timer
-    close $s r
-    close $ff
     list $done $acc
 } -cleanup {
+    catch {close $s}
+    close $ff
+    after cancel $timer
     removeFile echo.tcl
 } -result {Succeeded {Hey DONE}}
 
-- 
cgit v0.12