Skip to content

Commit ff4fd65

Browse files
authored
Grosser/cli (grosser#983)
* make cli options have more meaningful arg names + remove unreachable empty group code * fix broken integration test
1 parent d582779 commit ff4fd65

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

Readme.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -238,36 +238,37 @@ Setup for non-rails
238238

239239
Options are:
240240
<!-- copy output from bundle exec ./bin/parallel_test -h -->
241-
-n [PROCESSES] How many processes to use, default: available CPUs
242-
-p, --pattern [PATTERN] run tests matching this regex pattern
243-
--exclude-pattern [PATTERN] exclude tests matching this regex pattern
244-
--group-by [TYPE] group tests by:
241+
-n PROCESSES How many processes to use, default: available CPUs
242+
-p, --pattern PATTERN run tests matching this regex pattern
243+
--exclude-pattern PATTERN exclude tests matching this regex pattern
244+
--group-by TYPE group tests by:
245245
found - order of finding files
246246
steps - number of cucumber/spinach steps
247247
scenarios - individual cucumber scenarios
248248
filesize - by size of the file
249249
runtime - info from runtime log
250250
default - runtime when runtime log is filled otherwise filesize
251-
-m, --multiply-processes [FLOAT] use given number as a multiplier of processes to run
252-
-s, --single [PATTERN] Run all matching files in the same process
251+
-m, --multiply-processes COUNT use given number as a multiplier of processes to run
252+
-s, --single PATTERN Run all matching files in the same process
253253
-i, --isolate Do not run any other tests in the group used by --single(-s)
254-
--isolate-n [PROCESSES] Use 'isolate' singles with number of processes, default: 1
254+
--isolate-n PROCESSES Use 'isolate' singles with number of processes, default: 1
255255
--highest-exit-status Exit with the highest exit status provided by test run(s)
256-
--failure-exit-code [INT] Specify the exit code to use when tests fail
257-
--specify-groups [SPECS] Use 'specify-groups' if you want to specify multiple specs running in multiple
256+
--failure-exit-code INT Specify the exit code to use when tests fail
257+
--specify-groups SPECS Use 'specify-groups' if you want to specify multiple specs running in multiple
258258
processes in a specific formation. Commas indicate specs in the same process,
259259
pipes indicate specs in a new process. Cannot use with --single, --isolate, or
260260
--isolate-n. Ex.
261261
$ parallel_tests -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb'
262262
Process 1 will contain 1_spec.rb and 2_spec.rb
263263
Process 2 will contain 3_spec.rb
264264
Process 3 will contain all other specs
265-
--only-group INT[,INT] Only run the given group numbers.
265+
--only-group GROUP_INDEX[,GROUP_INDEX]
266+
Only run the given group numbers.
266267
Changes `--group-by` default to 'filesize'.
267-
-e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUMBER']
268-
-o, --test-options '[OPTIONS]' execute test commands with those options
269-
-t, --type [TYPE] test(default) / rspec / cucumber / spinach
270-
--suffix [PATTERN] override built in test file pattern (should match suffix):
268+
-e, --exec COMMAND execute this code parallel and with ENV['TEST_ENV_NUMBER']
269+
-o, --test-options 'OPTIONS' execute test commands with those options
270+
-t, --type TYPE test(default) / rspec / cucumber / spinach
271+
--suffix PATTERN override built in test file pattern (should match suffix):
271272
'_spec.rb$' - matches rspec files
272273
'_(test|spec).rb$' - matches test or spec files
273274
--serialize-stdout Serialize stdout output, nothing will be written until everything is done
@@ -276,14 +277,15 @@ Options are:
276277
--combine-stderr Combine stderr into stdout, useful in conjunction with --serialize-stdout
277278
--non-parallel execute same commands but do not in parallel, needs --exec
278279
--no-symlinks Do not traverse symbolic links to find test files
279-
--ignore-tags [PATTERN] When counting steps ignore scenarios with tags that match this pattern
280+
--ignore-tags PATTERN When counting steps ignore scenarios with tags that match this pattern
280281
--nice execute test commands with low priority.
281-
--runtime-log [PATH] Location of previously recorded test runtimes
282-
--allowed-missing [INT] Allowed percentage of missing runtimes (default = 50)
282+
--runtime-log PATH Location of previously recorded test runtimes
283+
--allowed-missing COUNT Allowed percentage of missing runtimes (default = 50)
283284
--allow-duplicates When detecting files to run, allow duplicates
284-
--unknown-runtime [FLOAT] Use given number as unknown runtime (otherwise use average time)
285+
--unknown-runtime SECONDS Use given number as unknown runtime (otherwise use average time)
285286
--first-is-1 Use "1" as TEST_ENV_NUMBER to not reuse the default test environment
286287
--fail-fast Stop all groups when one group fails (best used with --test-options '--fail-fast' if supported
288+
--test-file-limit LIMIT Limit to this number of files per test run by batching (for windows set to ~100 to stay below 8192 max command limit, might have bugs from reusing test-env-number and summarizing partial results)
287289
--verbose Print debug output
288290
--verbose-command Combines options --verbose-process-command and --verbose-rerun-command
289291
--verbose-process-command Print the command that will be executed by each process before it begins

lib/parallel_tests/cli.rb

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,7 @@ def run_tests_in_parallel(num_processes, options)
109109
end
110110

111111
def run_tests(group, process_number, num_processes, options)
112-
if group.empty?
113-
{ stdout: '', exit_status: 0, command: nil, seed: nil }
114-
else
115-
@runner.run_tests(group, process_number, num_processes, options)
116-
end
112+
@runner.run_tests(group, process_number, num_processes, options)
117113
end
118114

119115
def reprint_output(result, lockfile)
@@ -194,11 +190,11 @@ def parse_options!(argv)
194190
195191
Options are:
196192
BANNER
197-
opts.on("-n [PROCESSES]", Integer, "How many processes to use, default: available CPUs") { |n| options[:count] = n }
198-
opts.on("-p", "--pattern [PATTERN]", "run tests matching this regex pattern") { |pattern| options[:pattern] = /#{pattern}/ }
199-
opts.on("--exclude-pattern", "--exclude-pattern [PATTERN]", "exclude tests matching this regex pattern") { |pattern| options[:exclude_pattern] = /#{pattern}/ }
193+
opts.on("-n PROCESSES", Integer, "How many processes to use, default: available CPUs") { |n| options[:count] = n }
194+
opts.on("-p", "--pattern PATTERN", "run tests matching this regex pattern") { |pattern| options[:pattern] = /#{pattern}/ }
195+
opts.on("--exclude-pattern", "--exclude-pattern PATTERN", "exclude tests matching this regex pattern") { |pattern| options[:exclude_pattern] = /#{pattern}/ }
200196
opts.on(
201-
"--group-by [TYPE]",
197+
"--group-by TYPE",
202198
<<~TEXT.rstrip.split("\n").join("\n#{newline_padding}")
203199
group tests by:
204200
found - order of finding files
@@ -209,11 +205,11 @@ def parse_options!(argv)
209205
default - runtime when runtime log is filled otherwise filesize
210206
TEXT
211207
) { |type| options[:group_by] = type.to_sym }
212-
opts.on("-m [FLOAT]", "--multiply-processes [FLOAT]", Float, "use given number as a multiplier of processes to run") do |multiply|
208+
opts.on("-m COUNT", "--multiply-processes COUNT", Float, "use given number as a multiplier of processes to run") do |multiply|
213209
options[:multiply] = multiply
214210
end
215211

216-
opts.on("-s [PATTERN]", "--single [PATTERN]", "Run all matching files in the same process") do |pattern|
212+
opts.on("-s PATTERN", "--single PATTERN", "Run all matching files in the same process") do |pattern|
217213
(options[:single_process] ||= []) << /#{pattern}/
218214
end
219215

@@ -222,7 +218,7 @@ def parse_options!(argv)
222218
end
223219

224220
opts.on(
225-
"--isolate-n [PROCESSES]",
221+
"--isolate-n PROCESSES",
226222
Integer,
227223
"Use 'isolate' singles with number of processes, default: 1"
228224
) { |n| options[:isolate_count] = n }
@@ -233,13 +229,13 @@ def parse_options!(argv)
233229
) { options[:highest_exit_status] = true }
234230

235231
opts.on(
236-
"--failure-exit-code [INT]",
232+
"--failure-exit-code INT",
237233
Integer,
238234
"Specify the exit code to use when tests fail"
239235
) { |code| options[:failure_exit_code] = code }
240236

241237
opts.on(
242-
"--specify-groups [SPECS]",
238+
"--specify-groups SPECS",
243239
<<~TEXT.rstrip.split("\n").join("\n#{newline_padding}")
244240
Use 'specify-groups' if you want to specify multiple specs running in multiple
245241
processes in a specific formation. Commas indicate specs in the same process,
@@ -253,24 +249,24 @@ def parse_options!(argv)
253249
) { |groups| options[:specify_groups] = groups }
254250

255251
opts.on(
256-
"--only-group INT[,INT]",
252+
"--only-group GROUP_INDEX[,GROUP_INDEX]",
257253
Array,
258254
<<~TEXT.rstrip.split("\n").join("\n#{newline_padding}")
259255
Only run the given group numbers.
260256
Changes `--group-by` default to 'filesize'.
261257
TEXT
262258
) { |groups| options[:only_group] = groups.map(&:to_i) }
263259

264-
opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |arg| options[:execute] = Shellwords.shellsplit(arg) }
265-
opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = Shellwords.shellsplit(arg) }
266-
opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber / spinach") do |type|
260+
opts.on("-e", "--exec COMMAND", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |arg| options[:execute] = Shellwords.shellsplit(arg) }
261+
opts.on("-o", "--test-options 'OPTIONS'", "execute test commands with those options") { |arg| options[:test_options] = Shellwords.shellsplit(arg) }
262+
opts.on("-t", "--type TYPE", "test(default) / rspec / cucumber / spinach") do |type|
267263
@runner = load_runner(type)
268264
rescue NameError, LoadError => e
269265
puts "Runner for `#{type}` type has not been found! (#{e})"
270266
abort
271267
end
272268
opts.on(
273-
"--suffix [PATTERN]",
269+
"--suffix PATTERN",
274270
<<~TEXT.rstrip.split("\n").join("\n#{newline_padding}")
275271
override built in test file pattern (should match suffix):
276272
'_spec.rb$' - matches rspec files
@@ -282,12 +278,12 @@ def parse_options!(argv)
282278
opts.on("--combine-stderr", "Combine stderr into stdout, useful in conjunction with --serialize-stdout") { options[:combine_stderr] = true }
283279
opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec") { options[:non_parallel] = true }
284280
opts.on("--no-symlinks", "Do not traverse symbolic links to find test files") { options[:symlinks] = false }
285-
opts.on('--ignore-tags [PATTERN]', 'When counting steps ignore scenarios with tags that match this pattern') { |arg| options[:ignore_tag_pattern] = arg }
281+
opts.on('--ignore-tags PATTERN', 'When counting steps ignore scenarios with tags that match this pattern') { |arg| options[:ignore_tag_pattern] = arg }
286282
opts.on("--nice", "execute test commands with low priority.") { options[:nice] = true }
287-
opts.on("--runtime-log [PATH]", "Location of previously recorded test runtimes") { |path| options[:runtime_log] = path }
288-
opts.on("--allowed-missing [INT]", Integer, "Allowed percentage of missing runtimes (default = 50)") { |percent| options[:allowed_missing_percent] = percent }
283+
opts.on("--runtime-log PATH", "Location of previously recorded test runtimes") { |path| options[:runtime_log] = path }
284+
opts.on("--allowed-missing COUNT", Integer, "Allowed percentage of missing runtimes (default = 50)") { |percent| options[:allowed_missing_percent] = percent }
289285
opts.on('--allow-duplicates', 'When detecting files to run, allow duplicates') { options[:allow_duplicates] = true }
290-
opts.on("--unknown-runtime [FLOAT]", Float, "Use given number as unknown runtime (otherwise use average time)") { |time| options[:unknown_runtime] = time }
286+
opts.on("--unknown-runtime SECONDS", Float, "Use given number as unknown runtime (otherwise use average time)") { |time| options[:unknown_runtime] = time }
291287
opts.on("--first-is-1", "Use \"1\" as TEST_ENV_NUMBER to not reuse the default test environment") { options[:first_is_1] = true }
292288
opts.on("--fail-fast", "Stop all groups when one group fails (best used with --test-options '--fail-fast' if supported") { options[:fail_fast] = true }
293289
opts.on("--verbose", "Print debug output") { options[:verbose] = true }

lib/parallel_tests/rspec/runtime_logger.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def example_group_finished(notification)
2525
super if defined?(super)
2626
end
2727

28+
def seed(*); end
29+
2830
def dump_summary(*); end
2931

3032
def dump_failures(*); end

0 commit comments

Comments
 (0)