Skip to content

Commit 51a90f1

Browse files
authored
Merge pull request rspec#2274 from urbanautomaton/include-spec-opts-in-bisect-repro-command
Include SPEC_OPTS in bisect reproduction command
2 parents 0151ec9 + 8e30895 commit 51a90f1

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

features/command_line/bisect.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@with-clean-spec-opts
12
Feature: Bisect
23

34
RSpec's `--order random` and `--seed` options help surface flickering examples that only fail when one or more other examples are executed first. It can be very difficult to isolate the exact combination of examples that triggers the failure. The `--bisect` flag helps solve that problem.

features/support/require_expect_syntax_in_aruba_specs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
if defined?(Cucumber)
22
require 'shellwords'
3-
Before('~@allow-should-syntax') do
3+
Before('~@allow-should-syntax', '~@with-clean-spec-opts') do
44
set_env('SPEC_OPTS', "-r#{Shellwords.escape(__FILE__)}")
55
end
66

lib/rspec/core/bisect/runner.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def command_for(locations)
3838
def repro_command_from(locations)
3939
parts = []
4040

41+
parts.concat environment_repro_parts
4142
parts << "rspec"
4243
parts.concat Formatters::Helpers.organize_ids(locations)
4344
parts.concat original_cli_args_without_locations
@@ -103,6 +104,12 @@ def bisect_environment_hash
103104
end
104105
end
105106

107+
def environment_repro_parts
108+
bisect_environment_hash.map do |k, v|
109+
%Q(#{k}="#{v}")
110+
end
111+
end
112+
106113
def spec_opts_without_bisect
107114
Shellwords.join(
108115
Shellwords.split(ENV.fetch('SPEC_OPTS', '')).reject do |arg|

spec/rspec/core/bisect/runner_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ def repro_command_from(ids)
167167
expect(cmd).to include("--seed 1234").and exclude("spec/unit ")
168168
end
169169

170+
it 'includes the original SPEC_OPTS but excludes the --bisect flag' do
171+
with_env_vars('SPEC_OPTS' => '--bisect --seed 1234') do
172+
cmd = repro_command_from(%w[ ./spec/unit/1_spec.rb[1:1] ])
173+
expect(cmd).to include('SPEC_OPTS="--seed 1234"').and exclude("--bisect")
174+
end
175+
end
176+
170177
it 'includes original options that `command_for` excludes' do
171178
original_cli_args << "--format" << "progress"
172179
expect(runner.command_for(%w[ ./foo.rb[1:1] ])).to exclude("--format progress")

0 commit comments

Comments
 (0)