forking_test_runner 1.1.0 → 1.2.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
  SHA1:
3
- metadata.gz: 5ef7231c55483d9984e1bad7c369f8cca20b551f
4
- data.tar.gz: f70d32f37163292c4d8a00cb9c336d58c54ee32d
3
+ metadata.gz: 20b5dbbcbf7a0eccd84759792ee55fc23df3f532
4
+ data.tar.gz: 60bb004e09edc70351417d004c48a744c4ffae5c
5
5
  SHA512:
6
- metadata.gz: 0dc1603b7ce5f9c376675a56ed41951e6d4b3c0cf1a90f0151f2e02de7f77825db8717344a51c145d53ab2daa0b999c84dc0415a21e16c66f4ef88c2826eb62a
7
- data.tar.gz: e71a5e3663de8ebbe739fdd6298691916cb9ca4c7d68d6141e2127e86576caeacdc1cebe5c2c5e337b8d9f37c582944f8e5c33411ff0c6a0539e88bde4fb8338
6
+ metadata.gz: 9805ac39da7d1a475e56c7b3054534d3258509e11d1938c1c2b3a788a822221cd5339124f80348bf0700ddfb7ef809e69d6d6a8995531227ead0185d245b5210
7
+ data.tar.gz: 3e7e2728ed1603e89765e112bd275480364051b88ef080ba5bb45a89958fa7aed1ce90bc491ffead1a1b0c67d3a4230e5faa43e8774ca073138bc5d2002256a9
@@ -13,26 +13,53 @@ module ForkingTestRunner
13
13
  def result
14
14
  original = super
15
15
  return original unless @capture_coverage
16
+ CoverageCapture.merge_coverage(original, @capture_coverage)
17
+ end
16
18
 
17
- merged = original.dup
18
- @capture_coverage.each do |file, coverage|
19
- orig = merged[file]
20
- merged[file] = if orig
21
- merge_coverage(orig, coverage)
22
- else
23
- coverage
19
+ class << self
20
+ def merge_coverage(a, b)
21
+ merged = a.dup
22
+ b.each do |file, coverage|
23
+ orig = merged[file]
24
+ merged[file] = if orig
25
+ if coverage.is_a?(Array)
26
+ merge_lines_coverage(orig, coverage)
27
+ else
28
+ {
29
+ lines: merge_lines_coverage(orig.fetch(:lines), coverage.fetch(:lines)),
30
+ branches: merge_branches_coverage(orig.fetch(:branches), coverage.fetch(:branches))
31
+ }
32
+ end
33
+ else
34
+ coverage
35
+ end
24
36
  end
37
+ merged
25
38
  end
26
- merged
27
- end
28
39
 
29
- private
40
+ private
30
41
 
31
- # [nil,1,0] + [nil,nil,2] -> [nil,1,2]
32
- def merge_coverage(a, b)
33
- b.each_with_index.map do |b_count, i|
34
- a_count = a[i]
35
- (!b_count && !a_count) ? nil : b_count.to_i + a_count.to_i
42
+ # assuming b has same or more keys since it comes from a fork
43
+ # [nil,1,0] + [nil,nil,2] -> [nil,1,2]
44
+ def merge_lines_coverage(a, b)
45
+ b.each_with_index.map do |b_count, i|
46
+ a_count = a[i]
47
+ (a_count.nil? && b_count.nil?) ? nil : a_count.to_i + b_count.to_i
48
+ end
49
+ end
50
+
51
+ # assuming b has same or more keys since it comes from a fork
52
+ # {foo: {bar: 0, baz: 1}} + {foo: {bar: 1, baz: 0}} -> {foo: {bar: 1, baz: 1}}
53
+ def merge_branches_coverage(a, b)
54
+ b.each_with_object({}) do |(branch, v), all|
55
+ vb = v.dup
56
+ if part = a[branch]
57
+ part.each do |nested, a_count|
58
+ vb[nested] = a_count + vb[nested].to_i
59
+ end
60
+ end
61
+ all[branch] = vb
62
+ end
36
63
  end
37
64
  end
38
65
  end
@@ -1,3 +1,3 @@
1
1
  module ForkingTestRunner
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forking_test_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.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: 2017-09-29 00:00:00.000000000 Z
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel_tests
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.5.1
142
+ rubygems_version: 2.6.14
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Run every test in a fork to avoid pollution and get clean output per test