parallel_tests 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea91f62a37f66936e848cdcfadf2d0c0744bfa3b7c2efc36f99d99a6bc39dedc
4
- data.tar.gz: 72da68d7447b2f35c24ae11386c64a643c7f9e70be0690c9a061db94e811d374
3
+ metadata.gz: 630376174bbe4941703500d82264c43c0a8b42c3a490b1df9dbe174de6fb58a3
4
+ data.tar.gz: 2e37c805bb3ef70476ffb9e9e9881d8f6467741bee4146e27a3ab04542c68f23
5
5
  SHA512:
6
- metadata.gz: 41c7ac695777ec7d528fd8fcfca0972d8aadca96e7a2f9e1d6f1929c6b0f299a42d58fa006397ba9d4d5d27e5993cc3b28348be65e85bd564914a09b9674e664
7
- data.tar.gz: 3b2e3cf8dd34afaf2769a766fad72ebe079a1ccb0c30bc7f9a477d4938f9b9326bf4d60ea46cc5740ea39e4b1be393b0e1ea08bc8d464d00a8a8b0dbdea02823
6
+ metadata.gz: 5efe758f85900c7990d52c31b1f1aa3b1f6ab3e2939a3318eeddc275c6efa8d218d7d137efd61cfe5c701a225b3cf74a676690eef949c2033942baa13f6c3972
7
+ data.tar.gz: 434ac657ff8c2f9f5c253cc784ee0de49119391ef195b834a77e9b82b7b485b6f536c9207addfe9e08f09e2026ffd9410db4fdb373498989ff9d5fb1ed003757
data/Readme.md CHANGED
@@ -205,7 +205,9 @@ Options are:
205
205
  default - runtime when runtime log is filled otherwise filesize
206
206
  -m, --multiply-processes [FLOAT] use given number as a multiplier of processes to run
207
207
  -s, --single [PATTERN] Run all matching files in the same process
208
- -i, --isolate Do not run any other tests in the group used by --single(-s)
208
+ -i, --isolate Do not run any other tests in the group used by --single(-s).
209
+ Automatically turned on if --isolate-n is set above 0.
210
+ --isolate-n Number of processes for isolated groups. Default to 1 when --isolate is on.
209
211
  --only-group INT[, INT]
210
212
  -e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUMBER']
211
213
  -o, --test-options '[OPTIONS]' execute test commands with those options
@@ -192,6 +192,12 @@ module ParallelTests
192
192
  options[:isolate] = true
193
193
  end
194
194
 
195
+ opts.on("--isolate-n [PROCESSES]",
196
+ Integer,
197
+ "Use 'isolate' singles with number of processes, default: 1.") do |n|
198
+ options[:isolate_count] = n
199
+ end
200
+
195
201
  opts.on("--only-group INT[, INT]", Array) { |groups| options[:only_group] = groups.map(&:to_i) }
196
202
 
197
203
  opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |path| options[:execute] = path }
@@ -15,19 +15,46 @@ module ParallelTests
15
15
  groups = Array.new(num_groups) { {:items => [], :size => 0} }
16
16
 
17
17
  # add all files that should run in a single process to one group
18
- (options[:single_process] || []).each do |pattern|
19
- matched, items = items.partition { |item, _size| item =~ pattern }
20
- matched.each { |item, size| add_to_group(groups.first, item, size) }
18
+ single_process_patterns = options[:single_process] || []
19
+
20
+ single_items, items = items.partition do |item, _size|
21
+ single_process_patterns.any? { |pattern| item =~ pattern }
21
22
  end
22
23
 
23
- groups_to_fill = (options[:isolate] ? groups[1..-1] : groups)
24
- group_features_by_size(items_to_group(items), groups_to_fill)
24
+ isolate_count = isolate_count(options)
25
+
26
+ if isolate_count >= num_groups
27
+ raise 'Number of isolated processes must be less than total the number of processes'
28
+ end
29
+
30
+ if isolate_count >= 1
31
+ # add all files that should run in a multiple isolated processes to their own groups
32
+ group_features_by_size(items_to_group(single_items), groups[0..(isolate_count - 1)])
33
+ # group the non-isolated by size
34
+ group_features_by_size(items_to_group(items), groups[isolate_count..-1])
35
+ else
36
+ # add all files that should run in a single non-isolated process to first group
37
+ single_items.each { |item, size| add_to_group(groups.first, item, size) }
38
+
39
+ # group all by size
40
+ group_features_by_size(items_to_group(items), groups)
41
+ end
25
42
 
26
43
  groups.map! { |g| g[:items].sort }
27
44
  end
28
45
 
29
46
  private
30
47
 
48
+ def isolate_count(options)
49
+ if options[:isolate_count] && options[:isolate_count] > 1
50
+ options[:isolate_count]
51
+ elsif options[:isolate]
52
+ 1
53
+ else
54
+ 0
55
+ end
56
+ end
57
+
31
58
  def largest_first(files)
32
59
  files.sort_by{|_item, size| size }.reverse
33
60
  end
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '3.2.0'
2
+ VERSION = Version = '3.3.0'
3
3
  end
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: 3.2.0
4
+ version: 3.3.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: 2020-08-28 00:00:00.000000000 Z
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -68,8 +68,8 @@ licenses:
68
68
  - MIT
69
69
  metadata:
70
70
  bug_tracker_uri: https://github.com/grosser/parallel_tests/issues
71
- documentation_uri: https://github.com/grosser/parallel_tests/blob/v3.2.0/Readme.md
72
- source_code_uri: https://github.com/grosser/parallel_tests/tree/v3.2.0
71
+ documentation_uri: https://github.com/grosser/parallel_tests/blob/v3.3.0/Readme.md
72
+ source_code_uri: https://github.com/grosser/parallel_tests/tree/v3.3.0
73
73
  wiki_uri: https://github.com/grosser/parallel_tests/wiki
74
74
  post_install_message:
75
75
  rdoc_options: []