test/helper.rb in dtas-0.3.0 vs test/helper.rb in dtas-0.4.0

- old
+ new

@@ -1,8 +1,10 @@ # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) $stdout.sync = $stderr.sync = Thread.abort_on_exception = true +require 'thread' +WAIT_ALL_MTX = Mutex.new # fork-aware coverage data gatherer, see also test/covshow.rb if ENV["COVERAGE"] require "coverage" COVMATCH = %r{/lib/dtas\b.*rb\z} @@ -44,16 +46,27 @@ gem 'minitest' require 'minitest/autorun' require "tempfile" +Testcase = begin + Minitest::Test +rescue NameError + Minitest::Unit::TestCase +end + 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 require 'tmpdir'