diff options
Diffstat (limited to 'test/helper.rb')
-rw-r--r-- | test/helper.rb | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/test/helper.rb b/test/helper.rb index 626a046..5fa9599 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -51,33 +51,29 @@ if ENV["COVERAGE"] end gem 'minitest' -require 'minitest/autorun' -require "tempfile" - -Testcase = begin - Minitest::Test # minitest 5 -rescue NameError - Minitest::Unit::TestCase # minitest 4 +begin # favor minitest 5 + require 'minitest' + Testcase = Minitest::Test + mtobj = Minitest +rescue NameError, LoadError # but support minitest 4 + require 'minitest/unit' + Testcase = Minitest::Unit::TestCase + mtobj = MiniTest::Unit.new end -FIFOS = [] -def tmpfifo - tmp = Tempfile.new(%w(yahns-test .fifo)) - path = tmp.path - tmp.close! - assert system(*%W(mkfifo #{path})), "mkfifo #{path}" - - GTL.synchronize do - if FIFOS.empty? - at_exit do - FIFOS.each { |(pid,_path)| File.unlink(_path) if $$ == pid } - end - end - FIFOS << [ $$, path ] +# Not using minitest/autorun because that doesn't guard against redundant +# extra runs with fork. We cannot use exit! in the tests either +# (since users/apps hosted on yahns _should_ expect exit, not exit!). +TSTART_PID = $$ +at_exit do + # skipping @@after_run stuff in minitest since we don't need it + case $! + when nil, SystemExit + mtobj.run(ARGV) if $$ == TSTART_PID end - path end +require "tempfile" require 'tmpdir' class Dir require 'fileutils' |