This is the code:
require 'minitest/autorun'
class Foo < Minitest::Test
def test_foo
Process.fork do
exit(0)
end
p Process.waitall
end
end
This is the output:
$ ruby a.rb
Run options: --seed 40445
# Running:
[[41827, #<Process::Status: pid 41827 exit 1>]]
.
Finished in 0.016218s, 61.6599 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 0 errors, 0 skips
Why exit code is not zero?
The same code without Minitest works just fine:
Process.fork do
exit(0)
end
p Process.waitall
What's wrong?
https://github.com/seattlerb/minitest/issues/467
The problem is that
fork
duplicates theat_exit
handlers of the parent process. Minitest usesat_exit
to run the tests so you're hitting up against that. From the fork doco: "The child process can exit usingKernel.exit!
to avoid running anyat_exit
functions."