Bubble assertion failures back to the main thread

Without some help, failures in a forked process make for some noise in
the output, but won't fail the build.

Instead of trying to transfer the whole exception back, I've gone for a
simpler solution of just sending _something_ (the exception class name)
back so we'll fail; the full failure will be visible in the child
process's stderr output.
This commit is contained in:
Matthew Draper 2022-05-11 15:56:27 +09:30
parent 3b4e476221
commit a34fec7413
1 changed files with 11 additions and 1 deletions

View File

@ -55,6 +55,7 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase
# Pipes used for flow control across fork.
boot_reader, boot_writer = IO.pipe
touch_reader, touch_writer = IO.pipe
result_reader, result_writer = IO.pipe
pid = fork do
assert_not_predicate checker, :updated?
@ -68,10 +69,17 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase
IO.select([touch_reader])
assert_predicate checker, :updated?
rescue Exception => ex
result_writer.write(ex.class.name)
raise
ensure
result_writer.close
end
assert pid
result_writer.close
# Wait for fork to be booted before touching files.
IO.select([boot_reader])
touch(tmpfiles)
@ -82,6 +90,8 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase
assert_predicate checker, :updated?
Process.wait(pid)
assert_equal "", result_reader.read
end
test "can be garbage collected" do