Last active
February 4, 2016 20:58
-
-
Save everton/aa4a1fff3c6bc02e266d to your computer and use it in GitHub Desktop.
Minitest running twice when dealing with forks
This file contains hidden or 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/autorun' | |
class TestSuite | |
def self.before_run | |
pid = fork do | |
puts "on fork" | |
exit 0 | |
end | |
Process.detach pid | |
end | |
end | |
class MyTestCase < Minitest::Test | |
TestSuite.before_run | |
end | |
class TestTests < MyTestCase | |
def test_aa | |
puts "aaa" | |
end | |
end |
Author
everton
commented
Feb 4, 2016
The reason for this duplication is that Minitest uses #at_exit
to write results (is the only way to deal with exits inside application); To workaround this, calls to Kernel#exit
should be replaced by Kernel#exit!
, which ignore callbacks).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment