Created
July 20, 2015 18:54
-
-
Save bhenderson/45b786e5a55506e2f6f7 to your computer and use it in GitHub Desktop.
minitest/minitest#467 - store pid that registered at_exit hook
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
diff --git a/lib/minitest.rb b/lib/minitest.rb | |
index 2d4344e..5c50120 100644 | |
--- a/lib/minitest.rb | |
+++ b/lib/minitest.rb | |
@@ -43,12 +43,14 @@ module Minitest | |
# Registers Minitest to run at process exit | |
def self.autorun | |
+ registered_pid = $$ | |
at_exit { | |
next if $! and not ($!.kind_of? SystemExit and $!.success?) | |
exit_code = nil | |
at_exit { | |
+ next unless registered_pid == $$ | |
@@after_run.reverse_each(&:call) | |
exit exit_code || false | |
} | |
diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb | |
index e8b5974..a60df9d 100644 | |
--- a/test/minitest/test_minitest_unit.rb | |
+++ b/test/minitest/test_minitest_unit.rb | |
@@ -1883,4 +1883,10 @@ def test_method | |
end | |
end | |
end | |
+ | |
+ def test_forking_process | |
+ pid = fork{ true } | |
+ Process.waitpid(pid) | |
+ assert $?.success?, "forked process did not exit successfully" | |
+ end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment