diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index 165d079..1656439 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -25,14 +25,14 @@ "lib/turbo_tests/reporter.rb:1386902608": [ [7, 5, 400, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2092085575] ], - "lib/turbo_tests/runner.rb:1092969829": [ + "lib/turbo_tests/runner.rb:3421474245": [ [13, 5, 271, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 21989008], [20, 5, 1311, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1925027850], - [216, 11, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], - [234, 47, 6, "Style/GlobalStdStream: Use `$stderr` instead of `STDERR`.", 3356712163], - [236, 21, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], - [245, 7, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], - [305, 9, 6, "Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.", 3356722952] + [221, 11, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], + [239, 47, 6, "Style/GlobalStdStream: Use `$stderr` instead of `STDERR`.", 3356712163], + [241, 21, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], + [250, 7, 10, "ThreadSafety/NewThread: Avoid starting new threads.", 3411682361], + [310, 9, 6, "Style/GlobalStdStream: Use `$stdout` instead of `STDOUT`.", 3356722952] ], "spec/cli_spec.rb:3990998076": [ [1, 1, 30, "RSpec/SpecFilePathFormat: Spec path should end with `turbo_tests/cli*_spec.rb`.", 965721356], diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb index f271d7c..6195da4 100644 --- a/lib/turbo_tests/runner.rb +++ b/lib/turbo_tests/runner.rb @@ -97,6 +97,8 @@ def run ParallelTests::RSpec::Runner.tests_with_size(@files, {}).size, ].min + options_file = [".rspec_parallel", "spec/parallel_spec.opts", "spec/spec.opts"].detect { |f| File.file?(f) } + tests_in_groups = ParallelTests::RSpec::Runner.tests_in_groups( @files, @@ -108,6 +110,7 @@ def run subprocess_opts = { record_runtime: @record_runtime, + options_file: options_file, } @reporter.report(tests_in_groups) do |_reporter| @@ -151,7 +154,7 @@ def start_regular_subprocess(tests, process_id, **opts) ) end - def start_subprocess(env, extra_args, tests, process_id, record_runtime:) + def start_subprocess(env, extra_args, tests, process_id, record_runtime:, options_file:) if tests.empty? @messages << { type: "exit", @@ -188,6 +191,8 @@ def start_subprocess(env, extra_args, tests, process_id, record_runtime:) [] end + spec_opts = ["-O", options_file] if options_file + command = [ *command_name, *extra_args, @@ -195,9 +200,9 @@ def start_subprocess(env, extra_args, tests, process_id, record_runtime:) "--format", "TurboTests::JsonRowsFormatter", *record_runtime_options, + *spec_opts, *tests, ] - command.unshift(ENV["BUNDLE_BIN_PATH"], "exec") if ENV["BUNDLE_BIN_PATH"] command.unshift("nice") if @nice if @verbose