Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 83f7105

Browse files
committed
Refactor: create factory method for bisect failed error.
Also, move it to `utilities` as the server will not always be loaded.
1 parent 9d2893f commit 83f7105

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

lib/rspec/core/bisect/coordinator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
RSpec::Support.require_rspec_core "bisect/shell_command"
22
RSpec::Support.require_rspec_core "bisect/shell_runner"
33
RSpec::Support.require_rspec_core "bisect/example_minimizer"
4+
RSpec::Support.require_rspec_core "bisect/utilities"
45
RSpec::Support.require_rspec_core "formatters/bisect_progress_formatter"
56

67
module RSpec

lib/rspec/core/bisect/example_minimizer.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
RSpec::Support.require_rspec_core "bisect/utilities"
2+
13
module RSpec
24
module Core
35
module Bisect

lib/rspec/core/bisect/server.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ module RSpec
66
module Core
77
# @private
88
module Bisect
9-
# @private
10-
BisectFailedError = Class.new(StandardError)
11-
129
# @private
1310
# A DRb server that receives run results from a separate RSpec process
1411
# started by the bisect process.
@@ -28,7 +25,7 @@ def capture_run_results(files_or_directories_to_run=[], expected_failures=[])
2825
run_output = yield
2926

3027
if latest_run_results.nil? || latest_run_results.all_example_ids.empty?
31-
raise_bisect_failed(run_output)
28+
raise BisectFailedError.for_failed_spec_run(run_output)
3229
end
3330

3431
latest_run_results
@@ -58,13 +55,6 @@ def drb_port
5855

5956
# Fetched via DRb to tell clients which files to run
6057
attr_accessor :files_or_directories_to_run
61-
62-
private
63-
64-
def raise_bisect_failed(run_output)
65-
raise BisectFailedError, "Failed to get results from the spec " \
66-
"run. Spec run output:\n\n#{run_output}"
67-
end
6858
end
6959
end
7060
end

lib/rspec/core/bisect/utilities.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ module Core
33
module Bisect
44
# @private
55
ExampleSetDescriptor = Struct.new(:all_example_ids, :failed_example_ids)
6+
7+
# @private
8+
class BisectFailedError < StandardError
9+
def self.for_failed_spec_run(spec_output)
10+
new("Failed to get results from the spec run. Spec run output:\n\n" +
11+
spec_output)
12+
end
13+
end
614
end
715
end
816
end

0 commit comments

Comments
 (0)