aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2018-12-19 17:19:28 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2018-12-19 17:19:28 +0100
commitabae9d0e0a0f1628cbf608765db09c1db3303732 (patch)
tree8724c47b02415b4229e74676b4be8dae1070a762 /railties
parente7a7e174c1f8d31687676d74dabc6b464ffd81cb (diff)
downloadrails-abae9d0e0a0f1628cbf608765db09c1db3303732.tar.gz
rails-abae9d0e0a0f1628cbf608765db09c1db3303732.tar.bz2
rails-abae9d0e0a0f1628cbf608765db09c1db3303732.zip
Clarify implicit meaning of 'workers: 2' in parallelization tests.
Diffstat (limited to 'railties')
-rw-r--r--railties/test/application/test_runner_test.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index 55cfda82ea..55ce72181f 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -523,7 +523,7 @@ module ApplicationTests
end
def test_run_in_parallel_with_processes
- substitute_arguments_of_parallelize_method("workers: 2, with: :processes")
+ exercise_parallelization_regardless_of_machine_core_count(with: :processes)
file_name = create_parallel_processes_test_file
@@ -542,7 +542,7 @@ module ApplicationTests
end
def test_run_in_parallel_with_threads
- substitute_arguments_of_parallelize_method("workers: 2, with: :threads")
+ exercise_parallelization_regardless_of_machine_core_count(with: :threads)
file_name = create_parallel_threads_test_file
@@ -561,7 +561,7 @@ module ApplicationTests
end
def test_run_in_parallel_with_unmarshable_exception
- substitute_arguments_of_parallelize_method("workers: 2, with: :processes")
+ exercise_parallelization_regardless_of_machine_core_count(with: :processes)
file = app_file "test/fail_test.rb", <<-RUBY
require "test_helper"
@@ -587,8 +587,10 @@ module ApplicationTests
end
def test_run_in_parallel_with_unknown_object
- substitute_arguments_of_parallelize_method("workers: 2, with: :processes")
+ exercise_parallelization_regardless_of_machine_core_count(with: :processes)
+
create_scaffold
+
app_file "config/environments/test.rb", <<-RUBY
Rails.application.configure do
config.action_controller.allow_forgery_protection = true
@@ -967,10 +969,10 @@ module ApplicationTests
RUBY
end
- def substitute_arguments_of_parallelize_method(arguments)
+ def exercise_parallelization_regardless_of_machine_core_count(with:)
app_path("test/test_helper.rb") do |file_name|
file = File.read(file_name)
- file.sub!(/parallelize\(([^\)]*)\)/, "parallelize(#{arguments})")
+ file.sub!(/parallelize\(([^\)]*)\)/, "parallelize(workers: 2, with: :#{with})")
File.write(file_name, file)
end
end