From a34fec74131f1b64e7fbc6479bd6769a32fe0eda Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Wed, 11 May 2022 15:56:27 +0930 Subject: [PATCH] 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. --- .../test/evented_file_update_checker_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/activesupport/test/evented_file_update_checker_test.rb b/activesupport/test/evented_file_update_checker_test.rb index edbb860e87..8ed796c1a1 100644 --- a/activesupport/test/evented_file_update_checker_test.rb +++ b/activesupport/test/evented_file_update_checker_test.rb @@ -53,8 +53,9 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase assert_not_predicate checker, :updated? # Pipes used for flow control across fork. - boot_reader, boot_writer = IO.pipe + 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