File tree 5 files changed +47
-1
lines changed
5 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
### Added
8
8
9
+ - Allow processor multiplier (flag: ` -m ` or ` --multiply-processes ` ) to be set via the environment variable ` PARALLEL_TEST_MULTIPLE `
10
+
9
11
### Fixed
10
12
11
13
## 4.9.1 - 2025-02-19
Original file line number Diff line number Diff line change 335
335
e.g. ` config.cache_store = ..., namespace: "test_#{ENV['TEST_ENV_NUMBER']}" `
336
336
- Debug errors that only happen with multiple files using ` --verbose ` and [ cleanser] ( https://github.com/grosser/cleanser )
337
337
- ` export PARALLEL_TEST_PROCESSORS=13 ` to override default processor count
338
+ - ` export PARALLEL_TEST_MULTIPLE=.5 ` to override default processor multiplier
338
339
- Shell alias: ` alias prspec='parallel_rspec -m 2 --' `
339
340
- [ 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
341
- ` --first-is-1 ` will make the first environment be ` 1 ` , so you can test while running your full suite.<br />
Original file line number Diff line number Diff line change 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_MULTIPLE = 1.0
9
10
10
11
autoload :CLI , "parallel_tests/cli"
11
12
autoload :VERSION , "parallel_tests/version"
@@ -21,6 +22,14 @@ def determine_number_of_processes(count)
21
22
] . detect { |c | !c . to_s . strip . empty? } . to_i
22
23
end
23
24
25
+ def determine_multiple ( multiple )
26
+ [
27
+ multiple ,
28
+ ENV [ "PARALLEL_TEST_MULTIPLE" ] ,
29
+ DEFAULT_MULTIPLE ,
30
+ ] . detect { |c | !c . to_s . strip . empty? } . to_f
31
+ end
32
+
24
33
def with_pid_file
25
34
Tempfile . open ( 'parallel_tests-pidfile' ) do |f |
26
35
ENV [ 'PARALLEL_PID_FILE' ] = f . path
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def run(argv)
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 *= ParallelTests . determine_multiple ( options [ :multiply ] )
19
19
20
20
options [ :first_is_1 ] ||= first_is_1?
21
21
Original file line number Diff line number Diff line change @@ -34,6 +34,40 @@ def call(count)
34
34
end
35
35
end
36
36
37
+ describe ".determine_multiple" do
38
+ let ( :default_multiple ) { 1.0 }
39
+
40
+ before do
41
+ allow ( Parallel ) . to receive ( :multiple ) . and_return ( default_multiple )
42
+ end
43
+
44
+ def call ( multiple )
45
+ ParallelTests . determine_multiple ( multiple )
46
+ end
47
+
48
+ it "uses the given multiple if set" do
49
+ expect ( call ( '.5' ) ) . to eq ( 0.5 )
50
+ end
51
+
52
+ it "uses the processor multiple from Parallel" do
53
+ expect ( call ( nil ) ) . to eq ( default_multiple )
54
+ end
55
+
56
+ it "uses the processor multiple from ENV before Parallel" do
57
+ ENV [ 'PARALLEL_TEST_MULTIPLE' ] = '0.75'
58
+ expect ( call ( nil ) ) . to eq ( 0.75 )
59
+ end
60
+
61
+ it "does not use blank multiple" do
62
+ expect ( call ( ' ' ) ) . to eq ( default_multiple )
63
+ end
64
+
65
+ it "does not use blank env" do
66
+ ENV [ 'PARALLEL_TEST_MULTIPLE' ] = ' '
67
+ expect ( call ( nil ) ) . to eq ( default_multiple )
68
+ end
69
+ end
70
+
37
71
describe ".bundler_enabled?" do
38
72
before do
39
73
allow ( Object ) . to receive ( :const_defined? ) . with ( :Bundler ) . and_return false
You can’t perform that action at this time.
0 commit comments