From e8e985a2ee656cbbb2ea0d7d16a751fff357f965 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Sun, 17 Dec 2023 02:41:27 +0000 Subject: [PATCH] Support reading `.rspec_parallel` --- lib/turbo_tests/runner.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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