Created
December 13, 2010 10:59
-
-
Save paneq/738891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/unit' | |
MiniTest::Unit.class_eval do | |
def self.autorun | |
at_exit { | |
next if $! # don't run if there was an exception | |
# the order here is important. The at_exit handler must be | |
# installed before anyone else gets a chance to install their | |
# own, that way we can be assured that our exit will be last | |
# to run (at_exit stacks). | |
exit_code = nil | |
at_exit { exit false if exit_code && exit_code != 0 } | |
exit_code = MiniTest::Unit.new.run ARGV | |
} unless @@installed_at_exit | |
@@installed_at_exit = true | |
end | |
end | |
MiniTest::Unit.autorun | |
class TestMeme < MiniTest::Unit::TestCase | |
def test_flunk | |
pid = fork do | |
exec("sleep 100") # firefox in reality | |
end | |
at_exit do | |
begin | |
::Process.kill "TERM", pid | |
raise "x" | |
rescue | |
sleep 2 | |
::Process.kill "KILL", pid | |
sleep 2 | |
end | |
end | |
flunk("no reason") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment