parallel_tests 4.9.1 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Readme.md +55 -27
- data/lib/parallel_tests/cli.rb +43 -12
- data/lib/parallel_tests/cucumber/failures_logger.rb +1 -1
- data/lib/parallel_tests/gherkin/runner.rb +10 -5
- data/lib/parallel_tests/grouper.rb +8 -1
- data/lib/parallel_tests/rspec/runner.rb +5 -3
- data/lib/parallel_tests/tasks.rb +1 -1
- data/lib/parallel_tests/test/runner.rb +21 -9
- data/lib/parallel_tests/version.rb +1 -1
- data/lib/parallel_tests.rb +19 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e291b4184f32301b51269a28e356e8047598be82dfb0549ef40fbe96a0538c1f
|
4
|
+
data.tar.gz: a8f8b7d081348692c324842fc31c1678a4cc91383aefc5f03bc008206c51ae75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc7c9e41c2f81f01b4d4fee20287d0fb2c7ec3eff5262fe8039b4d9c8421a50778e358e1fccaca3393c4e4b7c769c3013f352262c047df0556ce2e3aa0d91fe0
|
7
|
+
data.tar.gz: e0d5de320982072fb9ac14b5b6f25f055853d77b9c11d782cff4c63e8037513dbff4959cef02e14ab05dd632e2e7168265fabe2e69bc48ebc28590eeff26e325
|
data/Readme.md
CHANGED
@@ -101,17 +101,23 @@ require "parallel_tests"
|
|
101
101
|
|
102
102
|
# preparation:
|
103
103
|
# affected by race-condition: first process may boot slower than the second
|
104
|
-
#
|
105
|
-
|
104
|
+
# the Process.ppid will be the pod of the process that started the parallel tests
|
105
|
+
# when not using TEST_ENV_NUMBER we use a unique file per process because ppid would be the users shell
|
106
|
+
done = "/tmp/parallel-setup-done-#{ENV['TEST_ENV_NUMBER'] ? Process.ppid : Process.pid}"
|
107
|
+
if ParallelTests.first_process?
|
108
|
+
do_something
|
109
|
+
File.write done, "true"
|
110
|
+
else
|
111
|
+
sleep 0.1 until File.exist?(done)
|
112
|
+
end
|
106
113
|
|
107
114
|
# cleanup:
|
108
|
-
# last_process?
|
109
|
-
ParallelTests.last_process? ? do_something : sleep(1)
|
110
|
-
|
115
|
+
# could also use last_process? but that is just the last process to start, not the last to finish
|
111
116
|
at_exit do
|
112
117
|
if ParallelTests.first_process?
|
113
|
-
|
114
|
-
|
118
|
+
File.unlink done
|
119
|
+
ParallelTests.wait_for_other_processes_to_finish
|
120
|
+
undo_something
|
115
121
|
end
|
116
122
|
end
|
117
123
|
```
|
@@ -129,7 +135,7 @@ Test groups will often run for different times, making the full test run as slow
|
|
129
135
|
|
130
136
|
### RSpec
|
131
137
|
|
132
|
-
Rspec: Add to your `.rspec_parallel` (or `.rspec`)
|
138
|
+
Rspec: Add to your `.rspec_parallel` (or `.rspec`), but can also be used via `--test-options='--format x'`:
|
133
139
|
|
134
140
|
--format progress
|
135
141
|
--format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log
|
@@ -154,7 +160,7 @@ RSpec: SummaryLogger
|
|
154
160
|
|
155
161
|
Log the test output without the different processes overwriting each other.
|
156
162
|
|
157
|
-
Add the following to your `.rspec_parallel` (or `.rspec`)
|
163
|
+
Add the following to your `.rspec_parallel` (or `.rspec`), but can also be used via `--test-options='--format x'`:
|
158
164
|
|
159
165
|
--format progress
|
160
166
|
--format ParallelTests::RSpec::SummaryLogger --out tmp/spec_summary.log
|
@@ -168,7 +174,7 @@ Produce pasteable command-line snippets for each failed example. For example:
|
|
168
174
|
rspec /path/to/my_spec.rb:123 # should do something
|
169
175
|
```
|
170
176
|
|
171
|
-
Add to `.rspec_parallel` or
|
177
|
+
Add the following to your `.rspec_parallel` (or `.rspec`), but can also be used via `--test-options='--format x'`:
|
172
178
|
|
173
179
|
--format progress
|
174
180
|
--format ParallelTests::RSpec::FailuresLogger --out tmp/failing_specs.log
|
@@ -188,7 +194,7 @@ Prints a single line for starting and finishing each example, to see what is cur
|
|
188
194
|
[14402] [1] [PASSED] Bar bar
|
189
195
|
```
|
190
196
|
|
191
|
-
Add to `.rspec_parallel` or
|
197
|
+
Add the following to your `.rspec_parallel` (or `.rspec`), but can also be used via `--test-options='--format x'`:
|
192
198
|
|
193
199
|
--format ParallelTests::RSpec::VerboseLogger
|
194
200
|
|
@@ -206,6 +212,8 @@ Or add the formatter to the `parallel:` profile of your `cucumber.yml`:
|
|
206
212
|
|
207
213
|
parallel: --format progress --format ParallelTests::Cucumber::FailuresLogger --out tmp/cucumber_failures.log
|
208
214
|
|
215
|
+
but can also be used via `--test-options='--format x'`:
|
216
|
+
|
209
217
|
Note if your `cucumber.yml` default profile uses `<%= std_opts %>` you may need to insert this as follows `parallel: <%= std_opts %> --format progress...`
|
210
218
|
|
211
219
|
To rerun failures:
|
@@ -237,7 +245,7 @@ Setup for non-rails
|
|
237
245
|
`parallel_cucumber -n 2 -o '-p foo_profile --tags @only_this_tag or @only_that_tag --format summary'`
|
238
246
|
|
239
247
|
Options are:
|
240
|
-
<!--
|
248
|
+
<!-- rake readme -->
|
241
249
|
-n PROCESSES How many processes to use, default: available CPUs
|
242
250
|
-p, --pattern PATTERN run tests matching this regex pattern
|
243
251
|
--exclude-pattern PATTERN exclude tests matching this regex pattern
|
@@ -256,7 +264,8 @@ Options are:
|
|
256
264
|
--failure-exit-code INT Specify the exit code to use when tests fail
|
257
265
|
--specify-groups SPECS Use 'specify-groups' if you want to specify multiple specs running in multiple
|
258
266
|
processes in a specific formation. Commas indicate specs in the same process,
|
259
|
-
pipes indicate specs in a new process.
|
267
|
+
pipes indicate specs in a new process. If SPECS is a '-' the value for this
|
268
|
+
option is read from STDIN instead. Cannot use with --single, --isolate, or
|
260
269
|
--isolate-n. Ex.
|
261
270
|
$ parallel_tests -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb'
|
262
271
|
Process 1 will contain 1_spec.rb and 2_spec.rb
|
@@ -265,7 +274,10 @@ Options are:
|
|
265
274
|
--only-group GROUP_INDEX[,GROUP_INDEX]
|
266
275
|
Only run the given group numbers.
|
267
276
|
Changes `--group-by` default to 'filesize'.
|
268
|
-
-e, --exec COMMAND execute
|
277
|
+
-e, --exec COMMAND execute COMMAND in parallel and with ENV['TEST_ENV_NUMBER']
|
278
|
+
--exec-args COMMAND execute COMMAND in parallel with test files as arguments, for example:
|
279
|
+
$ parallel_tests --exec-args echo
|
280
|
+
> echo spec/a_spec.rb spec/b_spec.rb
|
269
281
|
-o, --test-options 'OPTIONS' execute test commands with those options
|
270
282
|
-t, --type TYPE test(default) / rspec / cucumber / spinach
|
271
283
|
--suffix PATTERN override built in test file pattern (should match suffix):
|
@@ -285,7 +297,9 @@ Options are:
|
|
285
297
|
--unknown-runtime SECONDS Use given number as unknown runtime (otherwise use average time)
|
286
298
|
--first-is-1 Use "1" as TEST_ENV_NUMBER to not reuse the default test environment
|
287
299
|
--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
|
300
|
+
--test-file-limit LIMIT Limit to this number of files per test run by batching
|
301
|
+
(for windows set to ~100 to stay below 8192 max command limit, might have bugs from reusing test-env-number
|
302
|
+
and summarizing partial results)
|
289
303
|
--verbose Print debug output
|
290
304
|
--verbose-command Combines options --verbose-process-command and --verbose-rerun-command
|
291
305
|
--verbose-process-command Print the command that will be executed by each process before it begins
|
@@ -293,21 +307,31 @@ Options are:
|
|
293
307
|
--quiet Print only tests output
|
294
308
|
-v, --version Show Version
|
295
309
|
-h, --help Show this.
|
310
|
+
<!-- rake readme -->
|
296
311
|
|
297
|
-
You can run any
|
312
|
+
You can run any command in parallel with `-e` / `--exec`
|
298
313
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
314
|
+
```bash
|
315
|
+
parallel_test -n 3 -e 'ruby -e "puts %[hello from process #{ENV[:TEST_ENV_NUMBER.to_s].inspect}]"'
|
316
|
+
hello from process "2"
|
317
|
+
hello from process ""
|
318
|
+
hello from process "3"
|
319
|
+
```
|
305
320
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
321
|
+
and pass arguments to a command with `--exec-args`
|
322
|
+
|
323
|
+
```bash
|
324
|
+
parallel_test -n 3 --exec-args echo
|
325
|
+
spec/a_spec.rb spec/b_spec.rb
|
326
|
+
spec/c_spec.rb spec/d_spec.rb
|
327
|
+
spec/e_spec.rb
|
328
|
+
```
|
329
|
+
|
330
|
+
and run multiple commands by using `sh` and `--exec-args`
|
331
|
+
|
332
|
+
```bash
|
333
|
+
parallel_test -n 3 --exec-args "sh -c \"echo 'hello world' && rspec \$@\" --"
|
334
|
+
```
|
311
335
|
|
312
336
|
TIPS
|
313
337
|
====
|
@@ -335,6 +359,8 @@ TIPS
|
|
335
359
|
e.g. `config.cache_store = ..., namespace: "test_#{ENV['TEST_ENV_NUMBER']}"`
|
336
360
|
- Debug errors that only happen with multiple files using `--verbose` and [cleanser](https://github.com/grosser/cleanser)
|
337
361
|
- `export PARALLEL_TEST_PROCESSORS=13` to override default processor count
|
362
|
+
- `export PARALLEL_TEST_MULTIPLY_PROCESSES=.5` to override default processor multiplier
|
363
|
+
- `export PARALLEL_RAILS_ENV=environment_name` to override the default `test` environment
|
338
364
|
- Shell alias: `alias prspec='parallel_rspec -m 2 --'`
|
339
365
|
- [Spring] Add the [spring-commands-parallel-tests](https://github.com/DocSpring/spring-commands-parallel-tests) gem to your `Gemfile` to get `parallel_tests` working with Spring.
|
340
366
|
- `--first-is-1` will make the first environment be `1`, so you can test while running your full suite.<br/>
|
@@ -448,6 +474,8 @@ inspired by [pivotal labs](https://blog.pivotal.io/labs/labs/parallelize-your-rs
|
|
448
474
|
- [Jay Dorsey](https://github.com/jaydorsey)
|
449
475
|
- [hatsu](https://github.com/hatsu38)
|
450
476
|
- [Mark Huk](https://github.com/vimutter)
|
477
|
+
- [Johannes Vetter](https://github.com/johvet)
|
478
|
+
- [Michel Filipe](https://github.com/mfilipe)
|
451
479
|
|
452
480
|
[Michael Grosser](http://grosser.it)<br/>
|
453
481
|
michael@grosser.it<br/>
|
data/lib/parallel_tests/cli.rb
CHANGED
@@ -15,7 +15,7 @@ module ParallelTests
|
|
15
15
|
ENV['DISABLE_SPRING'] ||= '1'
|
16
16
|
|
17
17
|
num_processes = ParallelTests.determine_number_of_processes(options[:count])
|
18
|
-
num_processes
|
18
|
+
num_processes = (num_processes * ParallelTests.determine_multiple(options[:multiply_processes])).round
|
19
19
|
|
20
20
|
options[:first_is_1] ||= first_is_1?
|
21
21
|
|
@@ -191,8 +191,9 @@ module ParallelTests
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def parse_options!(argv)
|
194
|
-
newline_padding =
|
194
|
+
newline_padding = 37 # poor man's way of getting a decent table like layout for -h output on 120 char width terminal
|
195
195
|
options = {}
|
196
|
+
|
196
197
|
OptionParser.new do |opts|
|
197
198
|
opts.banner = <<~BANNER
|
198
199
|
Run all tests in parallel, giving each process ENV['TEST_ENV_NUMBER'] ('', '2', '3', ...)
|
@@ -205,12 +206,14 @@ module ParallelTests
|
|
205
206
|
|
206
207
|
Options are:
|
207
208
|
BANNER
|
209
|
+
|
208
210
|
opts.on("-n PROCESSES", Integer, "How many processes to use, default: available CPUs") { |n| options[:count] = n }
|
209
211
|
opts.on("-p", "--pattern PATTERN", "run tests matching this regex pattern") { |pattern| options[:pattern] = /#{pattern}/ }
|
210
212
|
opts.on("--exclude-pattern", "--exclude-pattern PATTERN", "exclude tests matching this regex pattern") { |pattern| options[:exclude_pattern] = /#{pattern}/ }
|
213
|
+
|
211
214
|
opts.on(
|
212
215
|
"--group-by TYPE",
|
213
|
-
<<~TEXT
|
216
|
+
heredoc(<<~TEXT, newline_padding)
|
214
217
|
group tests by:
|
215
218
|
found - order of finding files
|
216
219
|
steps - number of cucumber/spinach steps
|
@@ -220,8 +223,9 @@ module ParallelTests
|
|
220
223
|
default - runtime when runtime log is filled otherwise filesize
|
221
224
|
TEXT
|
222
225
|
) { |type| options[:group_by] = type.to_sym }
|
223
|
-
|
224
|
-
|
226
|
+
|
227
|
+
opts.on("-m COUNT", "--multiply-processes COUNT", Float, "use given number as a multiplier of processes to run") do |m|
|
228
|
+
options[:multiply_processes] = m
|
225
229
|
end
|
226
230
|
|
227
231
|
opts.on("-s PATTERN", "--single PATTERN", "Run all matching files in the same process") do |pattern|
|
@@ -251,10 +255,11 @@ module ParallelTests
|
|
251
255
|
|
252
256
|
opts.on(
|
253
257
|
"--specify-groups SPECS",
|
254
|
-
<<~TEXT
|
258
|
+
heredoc(<<~TEXT, newline_padding)
|
255
259
|
Use 'specify-groups' if you want to specify multiple specs running in multiple
|
256
260
|
processes in a specific formation. Commas indicate specs in the same process,
|
257
|
-
pipes indicate specs in a new process.
|
261
|
+
pipes indicate specs in a new process. If SPECS is a '-' the value for this
|
262
|
+
option is read from STDIN instead. Cannot use with --single, --isolate, or
|
258
263
|
--isolate-n. Ex.
|
259
264
|
$ parallel_tests -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb'
|
260
265
|
Process 1 will contain 1_spec.rb and 2_spec.rb
|
@@ -266,28 +271,40 @@ module ParallelTests
|
|
266
271
|
opts.on(
|
267
272
|
"--only-group GROUP_INDEX[,GROUP_INDEX]",
|
268
273
|
Array,
|
269
|
-
<<~TEXT
|
274
|
+
heredoc(<<~TEXT, newline_padding)
|
270
275
|
Only run the given group numbers.
|
271
276
|
Changes `--group-by` default to 'filesize'.
|
272
277
|
TEXT
|
273
278
|
) { |groups| options[:only_group] = groups.map(&:to_i) }
|
274
279
|
|
275
|
-
opts.on("-e", "--exec COMMAND", "execute
|
280
|
+
opts.on("-e", "--exec COMMAND", "execute COMMAND in parallel and with ENV['TEST_ENV_NUMBER']") { |arg| options[:execute] = Shellwords.shellsplit(arg) }
|
281
|
+
opts.on(
|
282
|
+
"--exec-args COMMAND",
|
283
|
+
heredoc(<<~TEXT, newline_padding)
|
284
|
+
execute COMMAND in parallel with test files as arguments, for example:
|
285
|
+
$ parallel_tests --exec-args echo
|
286
|
+
> echo spec/a_spec.rb spec/b_spec.rb
|
287
|
+
TEXT
|
288
|
+
) { |arg| options[:execute_args] = Shellwords.shellsplit(arg) }
|
289
|
+
|
276
290
|
opts.on("-o", "--test-options 'OPTIONS'", "execute test commands with those options") { |arg| options[:test_options] = Shellwords.shellsplit(arg) }
|
291
|
+
|
277
292
|
opts.on("-t", "--type TYPE", "test(default) / rspec / cucumber / spinach") do |type|
|
278
293
|
@runner = load_runner(type)
|
279
294
|
rescue NameError, LoadError => e
|
280
295
|
puts "Runner for `#{type}` type has not been found! (#{e})"
|
281
296
|
abort
|
282
297
|
end
|
298
|
+
|
283
299
|
opts.on(
|
284
300
|
"--suffix PATTERN",
|
285
|
-
<<~TEXT
|
301
|
+
heredoc(<<~TEXT, newline_padding)
|
286
302
|
override built in test file pattern (should match suffix):
|
287
303
|
'_spec.rb$' - matches rspec files
|
288
304
|
'_(test|spec).rb$' - matches test or spec files
|
289
305
|
TEXT
|
290
306
|
) { |pattern| options[:suffix] = /#{pattern}/ }
|
307
|
+
|
291
308
|
opts.on("--serialize-stdout", "Serialize stdout output, nothing will be written until everything is done") { options[:serialize_stdout] = true }
|
292
309
|
opts.on("--prefix-output-with-test-env-number", "Prefixes test env number to the output when not using --serialize-stdout") { options[:prefix_output_with_test_env_number] = true }
|
293
310
|
opts.on("--combine-stderr", "Combine stderr into stdout, useful in conjunction with --serialize-stdout") { options[:combine_stderr] = true }
|
@@ -301,7 +318,17 @@ module ParallelTests
|
|
301
318
|
opts.on("--unknown-runtime SECONDS", Float, "Use given number as unknown runtime (otherwise use average time)") { |time| options[:unknown_runtime] = time }
|
302
319
|
opts.on("--first-is-1", "Use \"1\" as TEST_ENV_NUMBER to not reuse the default test environment") { options[:first_is_1] = true }
|
303
320
|
opts.on("--fail-fast", "Stop all groups when one group fails (best used with --test-options '--fail-fast' if supported") { options[:fail_fast] = true }
|
304
|
-
|
321
|
+
|
322
|
+
opts.on(
|
323
|
+
"--test-file-limit LIMIT",
|
324
|
+
Integer,
|
325
|
+
heredoc(<<~TEXT, newline_padding)
|
326
|
+
Limit to this number of files per test run by batching
|
327
|
+
(for windows set to ~100 to stay below 8192 max command limit, might have bugs from reusing test-env-number
|
328
|
+
and summarizing partial results)
|
329
|
+
TEXT
|
330
|
+
) { |limit| options[:test_file_limit] = limit }
|
331
|
+
|
305
332
|
opts.on("--verbose", "Print debug output") { options[:verbose] = true }
|
306
333
|
opts.on("--verbose-command", "Combines options --verbose-process-command and --verbose-rerun-command") { options.merge! verbose_process_command: true, verbose_rerun_command: true }
|
307
334
|
opts.on("--verbose-process-command", "Print the command that will be executed by each process before it begins") { options[:verbose_process_command] = true }
|
@@ -349,7 +376,7 @@ module ParallelTests
|
|
349
376
|
raise "--group-by #{allowed.join(" or ")} is required for --only-group"
|
350
377
|
end
|
351
378
|
|
352
|
-
if options[:specify_groups] &&
|
379
|
+
if options[:specify_groups] && options.keys.intersect?([:single_process, :isolate, :isolate_count])
|
353
380
|
raise "Can't pass --specify-groups with any of these keys: --single, --isolate, or --isolate-n"
|
354
381
|
end
|
355
382
|
|
@@ -451,5 +478,9 @@ module ParallelTests
|
|
451
478
|
yield
|
452
479
|
end
|
453
480
|
end
|
481
|
+
|
482
|
+
def heredoc(text, newline_padding)
|
483
|
+
text.rstrip.gsub("\n", "\n#{' ' * newline_padding}")
|
484
|
+
end
|
454
485
|
end
|
455
486
|
end
|
@@ -18,11 +18,7 @@ module ParallelTests
|
|
18
18
|
options[:env] ||= {}
|
19
19
|
options[:env] = options[:env].merge({ 'AUTOTEST' => '1' }) if $stdout.tty?
|
20
20
|
|
21
|
-
|
22
|
-
cmd += runtime_logging if File.directory?(File.dirname(runtime_log))
|
23
|
-
cmd += combined_scenarios
|
24
|
-
cmd += cucumber_opts(options[:test_options])
|
25
|
-
execute_command(cmd, process_number, num_processes, options)
|
21
|
+
execute_command(build_command(combined_scenarios, options), process_number, num_processes, options)
|
26
22
|
end
|
27
23
|
|
28
24
|
def test_file_name
|
@@ -41,6 +37,15 @@ module ParallelTests
|
|
41
37
|
line =~ /^\d+ (steps?|scenarios?)/
|
42
38
|
end
|
43
39
|
|
40
|
+
def build_test_command(file_list, options)
|
41
|
+
[
|
42
|
+
*executable,
|
43
|
+
*(runtime_logging if File.directory?(File.dirname(runtime_log))),
|
44
|
+
*file_list,
|
45
|
+
*cucumber_opts(options[:test_options])
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
44
49
|
# cucumber has 2 result lines per test run, that cannot be added
|
45
50
|
# 1 scenario (1 failed)
|
46
51
|
# 1 step (1 failed)
|
@@ -48,8 +48,15 @@ module ParallelTests
|
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
+
def specified_groups(options)
|
52
|
+
groups = options[:specify_groups]
|
53
|
+
return groups if groups != '-'
|
54
|
+
|
55
|
+
$stdin.read.chomp
|
56
|
+
end
|
57
|
+
|
51
58
|
def specify_groups(items, num_groups, options, groups)
|
52
|
-
specify_test_process_groups = options
|
59
|
+
specify_test_process_groups = specified_groups(options).split('|')
|
53
60
|
if specify_test_process_groups.count > num_groups
|
54
61
|
raise 'Number of processes separated by pipe must be less than or equal to the total number of processes'
|
55
62
|
end
|
@@ -4,11 +4,9 @@ require "parallel_tests/test/runner"
|
|
4
4
|
module ParallelTests
|
5
5
|
module RSpec
|
6
6
|
class Runner < ParallelTests::Test::Runner
|
7
|
-
DEV_NULL = (WINDOWS ? "NUL" : "/dev/null")
|
8
7
|
class << self
|
9
8
|
def run_tests(test_files, process_number, num_processes, options)
|
10
|
-
|
11
|
-
execute_command(cmd, process_number, num_processes, options)
|
9
|
+
execute_command(build_command(test_files, options), process_number, num_processes, options)
|
12
10
|
end
|
13
11
|
|
14
12
|
def determine_executable
|
@@ -43,6 +41,10 @@ module ParallelTests
|
|
43
41
|
line =~ /\d+ examples?, \d+ failures?/
|
44
42
|
end
|
45
43
|
|
44
|
+
def build_test_command(file_list, options)
|
45
|
+
[*executable, *options[:test_options], *color, *spec_opts, *file_list]
|
46
|
+
end
|
47
|
+
|
46
48
|
# remove old seed and add new seed
|
47
49
|
# --seed 1234
|
48
50
|
# --order rand
|
data/lib/parallel_tests/tasks.rb
CHANGED
@@ -28,15 +28,7 @@ module ParallelTests
|
|
28
28
|
|
29
29
|
def run_tests(test_files, process_number, num_processes, options)
|
30
30
|
require_list = test_files.map { |file| file.gsub(" ", "\\ ") }.join(" ")
|
31
|
-
|
32
|
-
*executable,
|
33
|
-
'-Itest',
|
34
|
-
'-e',
|
35
|
-
"%w[#{require_list}].each { |f| require %{./\#{f}} }",
|
36
|
-
'--',
|
37
|
-
*options[:test_options]
|
38
|
-
]
|
39
|
-
execute_command(cmd, process_number, num_processes, options)
|
31
|
+
execute_command(build_command(require_list, options), process_number, num_processes, options)
|
40
32
|
end
|
41
33
|
|
42
34
|
# ignores other commands runner noise
|
@@ -168,6 +160,26 @@ module ParallelTests
|
|
168
160
|
["ruby"]
|
169
161
|
end
|
170
162
|
|
163
|
+
def build_command(file_list, options)
|
164
|
+
if options[:execute_args]
|
165
|
+
options[:execute_args] + file_list
|
166
|
+
else
|
167
|
+
build_test_command(file_list, options)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# load all test files, to be overwritten by other runners
|
172
|
+
def build_test_command(file_list, options)
|
173
|
+
[
|
174
|
+
*executable,
|
175
|
+
'-Itest', # adding ./test directory to the load path for compatibility to common setups
|
176
|
+
'-e',
|
177
|
+
"%w[#{file_list}].each { |f| require %{./\#{f}} }", # using %w to keep things readable
|
178
|
+
'--',
|
179
|
+
*options[:test_options]
|
180
|
+
]
|
181
|
+
end
|
182
|
+
|
171
183
|
def sum_up_results(results)
|
172
184
|
results = results.join(' ').gsub(/s\b/, '') # combine and singularize results
|
173
185
|
counts = results.scan(/(\d+) (\w+)/)
|
data/lib/parallel_tests.rb
CHANGED
@@ -6,6 +6,7 @@ require "rbconfig"
|
|
6
6
|
module ParallelTests
|
7
7
|
WINDOWS = (RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
|
8
8
|
RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
9
|
+
DEFAULT_MULTIPLY_PROCESSES = 1.0
|
9
10
|
|
10
11
|
autoload :CLI, "parallel_tests/cli"
|
11
12
|
autoload :VERSION, "parallel_tests/version"
|
@@ -13,12 +14,25 @@ module ParallelTests
|
|
13
14
|
autoload :Pids, "parallel_tests/pids"
|
14
15
|
|
15
16
|
class << self
|
17
|
+
# used by external libraries, do not rename or change api
|
16
18
|
def determine_number_of_processes(count)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
Integer(
|
20
|
+
[
|
21
|
+
count,
|
22
|
+
ENV["PARALLEL_TEST_PROCESSORS"],
|
23
|
+
Parallel.processor_count
|
24
|
+
].detect { |c| !c.to_s.strip.empty? }
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def determine_multiple(multiple)
|
29
|
+
Float(
|
30
|
+
[
|
31
|
+
multiple,
|
32
|
+
ENV["PARALLEL_TEST_MULTIPLY_PROCESSES"],
|
33
|
+
DEFAULT_MULTIPLY_PROCESSES
|
34
|
+
].detect { |c| !c.to_s.strip.empty? }
|
35
|
+
)
|
22
36
|
end
|
23
37
|
|
24
38
|
def with_pid_file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_tests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 5.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02
|
11
|
+
date: 2025-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -69,9 +69,9 @@ licenses:
|
|
69
69
|
- MIT
|
70
70
|
metadata:
|
71
71
|
bug_tracker_uri: https://github.com/grosser/parallel_tests/issues
|
72
|
-
changelog_uri: https://github.com/grosser/parallel_tests/blob/
|
73
|
-
documentation_uri: https://github.com/grosser/parallel_tests/blob/
|
74
|
-
source_code_uri: https://github.com/grosser/parallel_tests/tree/
|
72
|
+
changelog_uri: https://github.com/grosser/parallel_tests/blob/v5.4.0/CHANGELOG.md
|
73
|
+
documentation_uri: https://github.com/grosser/parallel_tests/blob/v5.4.0/Readme.md
|
74
|
+
source_code_uri: https://github.com/grosser/parallel_tests/tree/v5.4.0
|
75
75
|
wiki_uri: https://github.com/grosser/parallel_tests/wiki
|
76
76
|
rubygems_mfa_required: 'true'
|
77
77
|
post_install_message:
|
@@ -82,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
82
|
requirements:
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 3.
|
85
|
+
version: 3.1.0
|
86
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|