From ab2eaad734c814616d7b7db97f167188aec4e710 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb index 1a74b76..a86b93f 100644 --- a/lib/turbo_tests/runner.rb +++ b/lib/turbo_tests/runner.rb @@ -77,6 +77,8 @@ def run group_opts[:group_by] = :filesize end + 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, @@ -87,7 +89,8 @@ def run setup_tmp_dir subprocess_opts = { - record_runtime: use_runtime_info + record_runtime: use_runtime_info, + options_file: options_file } report_number_of_tests(tests_in_groups) @@ -130,7 +133,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", @@ -157,6 +160,8 @@ def start_subprocess(env, extra_args, tests, process_id, record_runtime:) [] end + spec_opts = ["-O", options_file] if options_file + command = [ "rspec", *extra_args, @@ -164,6 +169,7 @@ def start_subprocess(env, extra_args, tests, process_id, record_runtime:) "--format", "TurboTests::JsonRowsFormatter", "--out", tmp_filename, *record_runtime_options, + *spec_opts, *tests ] command.unshift(ENV["BUNDLE_BIN_PATH"], "exec") if ENV["BUNDLE_BIN_PATH"]