@@ -68,7 +68,17 @@ def parser(options)
68
68
69
69
parser . on ( '--bisect[=verbose]' , 'Repeatedly runs the suite in order to isolate the failures to the ' ,
70
70
' smallest reproducible case.' ) do |argument |
71
- options [ :bisect ] = argument || true
71
+ options [ :runner ] = -> ( opts , err , out ) do
72
+ RSpec ::Support . require_rspec_core "bisect/coordinator"
73
+
74
+ success = Bisect ::Coordinator . bisect_with (
75
+ opts . command_line_and_env_args ,
76
+ RSpec . configuration ,
77
+ bisect_formatter_for ( argument )
78
+ )
79
+
80
+ exit ( success ? 0 : 1 )
81
+ end
72
82
end
73
83
74
84
parser . on ( '--[no-]fail-fast[=COUNT]' , 'Abort the run after a certain number of failures (1 by default).' ) do |argument |
@@ -97,15 +107,27 @@ def parser(options)
97
107
end
98
108
99
109
parser . on ( '-X' , '--[no-]drb' , 'Run examples via DRb.' ) do |o |
100
- options [ :drb ] = o
110
+ if o
111
+ options [ :runner ] = -> ( opts , err , out ) do
112
+ require 'rspec/core/drb'
113
+ begin
114
+ DRbRunner . new ( opts ) . run ( err , out )
115
+ exit
116
+ rescue DRb ::DRbConnError
117
+ err . puts "No DRb server is running. Running in local process instead ..."
118
+ end
119
+ end
120
+ end
101
121
end
102
122
103
123
parser . on ( '--drb-port PORT' , 'Port to connect to the DRb server.' ) do |o |
104
124
options [ :drb_port ] = o . to_i
105
125
end
106
126
107
127
parser . on ( '--init' , 'Initialize your project with RSpec.' ) do |_cmd |
108
- initialize_project_and_exit
128
+ options [ :runner ] = -> ( *_args ) do
129
+ initialize_project_and_exit
130
+ end
109
131
end
110
132
111
133
parser . separator ( "\n **** Output ****\n \n " )
@@ -242,7 +264,9 @@ def parser(options)
242
264
parser . separator ( "\n **** Utility ****\n \n " )
243
265
244
266
parser . on ( '-v' , '--version' , 'Display the version.' ) do
245
- print_version_and_exit
267
+ options [ :runner ] = -> ( *_args ) do
268
+ print_version_and_exit
269
+ end
246
270
end
247
271
248
272
# These options would otherwise be confusing to users, so we forcibly
@@ -254,7 +278,9 @@ def parser(options)
254
278
invalid_options = %w[ -d --I ]
255
279
256
280
parser . on_tail ( '-h' , '--help' , "You're looking at it." ) do
257
- print_help_and_exit ( parser , invalid_options )
281
+ options [ :runner ] = -> ( *_args ) do
282
+ print_help_and_exit ( parser , invalid_options )
283
+ end
258
284
end
259
285
260
286
# This prevents usage of the invalid_options.
@@ -282,6 +308,11 @@ def configure_only_failures(options)
282
308
add_tag_filter ( options , :inclusion_filter , :last_run_status , 'failed' )
283
309
end
284
310
311
+ def bisect_formatter_for ( argument )
312
+ return Formatters ::BisectDebugFormatter if argument == "verbose"
313
+ Formatters ::BisectProgressFormatter
314
+ end
315
+
285
316
def initialize_project_and_exit
286
317
RSpec ::Support . require_rspec_core "project_initializer"
287
318
ProjectInitializer . new . run
0 commit comments