dtas-all
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/8] test/helper: delay at_exit registration for tmpfifo


From: Eric Wong
Subject: [PATCH 5/8] test/helper: delay at_exit registration for tmpfifo
Date: Sat, 7 Sep 2013 20:03:24 +0000

at_exit ordering is funky because minitest/autorun also runs
at_exit, so we need to delay registering the at_exit until we
call tmpfifo.
---
 test/helper.rb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/test/helper.rb b/test/helper.rb
index a36332b..81bc22f 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -50,12 +50,17 @@ Testcase = Minitest.const_defined?(:Test) ? Minitest::Test
            : Minitest::Unit::TestCase
 
 FIFOS = []
-at_exit { FIFOS.each { |(pid,path)| File.unlink(path) if $$ == pid } }
 def tmpfifo
   tmp = Tempfile.new(%w(dtas-test .fifo))
   path = tmp.path
   tmp.close!
   assert system(*%W(mkfifo #{path})), "mkfifo #{path}"
+
+  if FIFOS.empty?
+    at_exit do
+      FIFOS.each { |(pid,path)| File.unlink(path) if $$ == pid }
+    end
+  end
   FIFOS << [ $$, path ]
   path
 end
-- 
1.8.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]