aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-11-16 21:25:14 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-11-17 13:56:51 +0900
commit90266a7f1eff7c873cba7044fa0a4487b2a6ff84 (patch)
tree4699208d26dbdf0da30e43e79b768b541741f5cf
parentef5478d326d78d1e2b567c23b4a7c16b69dc72b2 (diff)
downloadrails-90266a7f1eff7c873cba7044fa0a4487b2a6ff84.tar.gz
rails-90266a7f1eff7c873cba7044fa0a4487b2a6ff84.tar.bz2
rails-90266a7f1eff7c873cba7044fa0a4487b2a6ff84.zip
Correctly handle unknown object in parallel tests
DRb wraps in `DRbUnknown` if the data contains a type that can not be resolved locally. This can happen if an error occurs in the test and the error class can not be resolved on the server side. When this happens, an instance of `DRbUnknown` is passed to the `result` of `Server#record`. This causes another error(undefined method assertions for #<DRb::DRbUnknown:> (NoMethodError)) in `reporter.record`. This can confirm by the following steps. ``` $ rails new app -B --dev; cd app $ rails g scaffold user name:string $ edit `config.action_controller.allow_forgery_protection = true` in environments/test.rb $ bin/rails t ``` In the case of `DRbUnknown` occurs, can't resolve error exception. So wrap exception with `DRbRemoteError` in the same way as an unmarshalled object.
-rw-r--r--activesupport/lib/active_support/testing/parallelization.rb2
-rw-r--r--railties/test/application/test_runner_test.rb14
2 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/testing/parallelization.rb b/activesupport/lib/active_support/testing/parallelization.rb
index 9c8dffa9d8..24c4f18931 100644
--- a/activesupport/lib/active_support/testing/parallelization.rb
+++ b/activesupport/lib/active_support/testing/parallelization.rb
@@ -15,6 +15,8 @@ module ActiveSupport
end
def record(reporter, result)
+ raise DRb::DRbConnError if result.is_a?(DRb::DRbUnknown)
+
reporter.synchronize do
reporter.record(result)
end
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index 0d7645e794..140703e118 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -586,6 +586,20 @@ module ApplicationTests
assert_match "1 runs, 0 assertions, 0 failures, 1 errors", output
end
+ def test_run_in_parallel_with_unknown_object
+ create_scaffold
+ app_file "config/environments/test.rb", <<-RUBY
+ Rails.application.configure do
+ config.action_controller.allow_forgery_protection = true
+ config.action_dispatch.show_exceptions = false
+ end
+ RUBY
+
+ output = run_test_command("-n test_should_create_user")
+
+ assert_match "ActionController::InvalidAuthenticityToken", output
+ end
+
def test_raise_error_when_specified_file_does_not_exist
error = capture(:stderr) { run_test_command("test/not_exists.rb", stderr: true) }
assert_match(%r{cannot load such file.+test/not_exists\.rb}, error)