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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e815835eed992c081181431f2989b1ab60ec6a0a3c95947c90aafd5db2ebcd3
4
- data.tar.gz: 2b70b55f1d6c8fd5980bd7373cc3d2848ff895223a55f58b669d07fe1aa396e6
3
+ metadata.gz: e291b4184f32301b51269a28e356e8047598be82dfb0549ef40fbe96a0538c1f
4
+ data.tar.gz: a8f8b7d081348692c324842fc31c1678a4cc91383aefc5f03bc008206c51ae75
5
5
  SHA512:
6
- metadata.gz: abbcf1ba23afba1f7d0e055d37f924ba4bd3d3e77c09a4a78a725d17158bb0553daf3ca739c41035c9d3833cd0413a40e304decf05ebe00f453ed35865c90193
7
- data.tar.gz: 4dafcef1701e3584dae080953282b52733066bdc1415fa50aa2dc67bd91f292471dd9ff32939fdef16867226ee46aa94a6272e7705371900f320b1f196e38f95
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
- # either sleep a bit or use a lock for example File.lock
105
- ParallelTests.first_process? ? do_something : sleep(1)
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? does NOT mean last finished process, just last started
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
- ParallelTests.wait_for_other_processes_to_finish
114
- undo_something
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 use as CLI flag:
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 use as CLI flag:
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
- <!-- copy output from bundle exec ./bin/parallel_test -h -->
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. Cannot use with --single, --isolate, or
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 this code parallel and with ENV['TEST_ENV_NUMBER']
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 (for windows set to ~100 to stay below 8192 max command limit, might have bugs from reusing test-env-number and summarizing partial results)
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 kind of code in parallel with -e / --exec
312
+ You can run any command in parallel with `-e` / `--exec`
298
313
 
299
- parallel_test -n 5 -e 'ruby -e "puts %[hello from process #{ENV[:TEST_ENV_NUMBER.to_s].inspect}]"'
300
- hello from process "2"
301
- hello from process ""
302
- hello from process "3"
303
- hello from process "5"
304
- hello from process "4"
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
- <table>
307
- <tr><td></td><td>1 Process</td><td>2 Processes</td><td>4 Processes</td></tr>
308
- <tr><td>RSpec spec-suite</td><td>18s</td><td>14s</td><td>10s</td></tr>
309
- <tr><td>Rails-ActionPack</td><td>88s</td><td>53s</td><td>44s</td></tr>
310
- </table>
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/>
@@ -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 *= (options[:multiply] || 1)
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 = " " * 37
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.rstrip.split("\n").join("\n#{newline_padding}")
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
- opts.on("-m COUNT", "--multiply-processes COUNT", Float, "use given number as a multiplier of processes to run") do |multiply|
224
- options[:multiply] = multiply
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.rstrip.split("\n").join("\n#{newline_padding}")
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. Cannot use with --single, --isolate, or
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.rstrip.split("\n").join("\n#{newline_padding}")
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 this code parallel and with ENV['TEST_ENV_NUMBER']") { |arg| options[:execute] = Shellwords.shellsplit(arg) }
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.rstrip.split("\n").join("\n#{newline_padding}")
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
- opts.on("--test-file-limit LIMIT", Integer, "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)") { |limit| options[:test_file_limit] = limit }
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] && (options.keys & [:single_process, :isolate, :isolate_count]).any?
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
@@ -20,7 +20,7 @@ module ParallelTests
20
20
 
21
21
  # Add our own handler
22
22
  config.on_event :test_run_finished do
23
- return if @failures.empty?
23
+ next if @failures.empty?
24
24
 
25
25
  lock_output do
26
26
  @failures.each do |file, lines|
@@ -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
- cmd = executable
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[:specify_groups].split('|')
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
- cmd = [*executable, *options[:test_options], *color, *spec_opts, *test_files]
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
@@ -6,7 +6,7 @@ module ParallelTests
6
6
  module Tasks
7
7
  class << self
8
8
  def rails_env
9
- 'test'
9
+ ENV['PARALLEL_RAILS_ENV'] || 'test'
10
10
  end
11
11
 
12
12
  def load_lib
@@ -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
- cmd = [
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+)/)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ParallelTests
3
- VERSION = '4.9.1'
3
+ VERSION = '5.4.0'
4
4
  end
@@ -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
- count,
19
- ENV["PARALLEL_TEST_PROCESSORS"],
20
- Parallel.processor_count
21
- ].detect { |c| !c.to_s.strip.empty? }.to_i
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.9.1
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-19 00:00:00.000000000 Z
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/v4.9.1/CHANGELOG.md
73
- documentation_uri: https://github.com/grosser/parallel_tests/blob/v4.9.1/Readme.md
74
- source_code_uri: https://github.com/grosser/parallel_tests/tree/v4.9.1
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.0.0
85
+ version: 3.1.0
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="