Skip to content

Commit

Permalink
- Fix autorun bug that affects fork exit status in tests. (dylanahsmi…
Browse files Browse the repository at this point in the history
…th/jhawthorn)

[git-p4: depot-paths = "//src/minitest/dev/": change = 12350]
  • Loading branch information
zenspider committed Oct 20, 2019
1 parent d80a4d4 commit 9d8064c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def self.autorun

exit_code = nil

pid = Process.pid
at_exit {
next if Process.pid != pid
@@after_run.reverse_each(&:call)
exit exit_code || false
}
Expand Down
14 changes: 14 additions & 0 deletions test/minitest/test_minitest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,20 @@ def shitty_test_case.test_order; :lol end
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
end
end

def test_autorun_does_not_affect_fork_success_status
@assertion_count = 0
skip "windows doesn't have skip" unless Process.respond_to?(:fork)
Process.waitpid(fork {})
assert_equal true, $?.success?
end

def test_autorun_does_not_affect_fork_exit_status
@assertion_count = 0
skip "windows doesn't have skip" unless Process.respond_to?(:fork)
Process.waitpid(fork { exit 42 })
assert_equal 42, $?.exitstatus
end
end

class TestMinitestGuard < Minitest::Test
Expand Down

0 comments on commit 9d8064c

Please sign in to comment.