aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
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 /activesupport/lib
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 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/testing/parallelization.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/testing/parallelization.rb b/activesupport/lib/active_support/testing/parallelization.rb
index e760bf5ce3..f50a5e0554 100644
--- a/activesupport/lib/active_support/testing/parallelization.rb
+++ b/activesupport/lib/active_support/testing/parallelization.rb
@@ -27,6 +27,10 @@ module ActiveSupport
@queue << o
end
+ def length
+ @queue.length
+ end
+
def pop; @queue.pop; end
end
@@ -109,6 +113,10 @@ module ActiveSupport
def shutdown
@queue_size.times { @queue << nil }
@pool.each { |pid| Process.waitpid pid }
+
+ if @queue.length > 0
+ raise "Queue not empty, but all workers have finished. This probably means that a worker crashed and #{@queue.length} tests were missed."
+ end
end
private