aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-05-30 16:56:29 -0700
committerJohn Hawthorn <john@hawthorn.email>2019-05-30 21:34:47 -0700
commit9fd02d181a0706cd3a98e08b2caa7c9ed3c39b50 (patch)
tree2c0557c4ae786adeb26baec1a4fed8d1d668dd16 /railties/test
parent165785e8cf43456816c8152ca4295640b21d1765 (diff)
downloadrails-9fd02d181a0706cd3a98e08b2caa7c9ed3c39b50.tar.gz
rails-9fd02d181a0706cd3a98e08b2caa7c9ed3c39b50.tar.bz2
rails-9fd02d181a0706cd3a98e08b2caa7c9ed3c39b50.zip
Fail parallel tests if workers exit early
Previously, if a test worker exited early, the in-flight test it was supposed to run wasn't reported as a failure. If all workers exited immediately, this would be reported as ex. Finished in 1.708349s, 39.2192 runs/s, 79.0237 assertions/s. 67 runs, 135 assertions, 0 failures, 0 errors, 2 skips This commit validates that all workers finish running tests by ensuring that the queue is empty after they exit. This works because we signal the workers to exit by pushing nil onto the queue, so that there should be a number of items left in the queue matching potentially missed tests.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/test_runner_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index 1ab45abcd0..7fc918898b 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -564,6 +564,24 @@ module ApplicationTests
assert_no_match "create_table(:users)", output
end
+ def test_run_in_parallel_with_process_worker_crash
+ exercise_parallelization_regardless_of_machine_core_count(with: :processes)
+
+ file_name = app_file("test/models/parallel_test.rb", <<-RUBY)
+ require 'test_helper'
+
+ class ParallelTest < ActiveSupport::TestCase
+ def test_crash
+ Kernel.exit 1
+ end
+ end
+ RUBY
+
+ output = run_test_command(file_name)
+
+ assert_match %r{Queue not empty, but all workers have finished. This probably means that a worker crashed and 1 tests were missed.}, output
+ end
+
def test_run_in_parallel_with_threads
exercise_parallelization_regardless_of_machine_core_count(with: :threads)