Skip to content

Commit

Permalink
Add a test for buggy behavior of bisect
Browse files Browse the repository at this point in the history
  • Loading branch information
cmrd-senya committed Nov 3, 2020
1 parent c6315d6 commit 57ff312
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/integration/bisect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ def bisect(cli_args, expected_status=nil)
end
end

context "when the failing spec is in the second half of the group" do
it 'successfully finishes' do
output = bisect(%W[--order defined spec/rspec/core/resources/order_dependent/correct_specs.rb spec/rspec/core/resources/order_dependent/order_dependent_specs.rb], 0)
expect(output).to include(
"The minimal reproduction command is:",
"rspec ./spec/rspec/core/resources/order_dependent/order_dependent_specs.rb[1:1,1:3]"
)
end
end

context "when the failing spec is in the first half of the group" do
it 'successfully finishes' do
output = bisect(%W[--order defined spec/rspec/core/resources/order_dependent/order_dependent_specs.rb spec/rspec/core/resources/order_dependent/correct_specs.rb], 0)
expect(output).to include(
"The minimal reproduction command is:",
"rspec ./spec/rspec/core/resources/failure_is_not_in_the_end_specs.rb[1:1,1:3]"
)
end
end

context "when the bisect command saturates the pipe" do
# On OSX and Linux a file descriptor limit meant that the bisect process got stuck at a certain limit.
# This test demonstrates that we can run large bisects above this limit (found to be at time of commit).
Expand Down
7 changes: 7 additions & 0 deletions spec/rspec/core/resources/order_dependent/correct_specs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Deliberately named _specs.rb to avoid being loaded except when specified

RSpec.describe "Specs mutating the global state" do
10.times do |i|
it("passes #{i}") { true }
end
end
15 changes: 15 additions & 0 deletions spec/rspec/core/resources/order_dependent/order_dependent_specs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Deliberately named _specs.rb to avoid being loaded except when specified

arr = []

RSpec.describe "Group" do
it ("the first example mutates the global state") {
arr.push('mutation')
}

it ("the second example does not mutate the global state") { true }

it("order-dependent failing example") {
fail if arr.length > 0
}
end

0 comments on commit 57ff312

Please sign in to comment.