single_cov 1.2.0 → 1.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: 310e80976c5b117b3cfa36b082ca4c2b3fdbaf55733891cb450c33bc9b28636e
4
- data.tar.gz: f50cc1ddb095a99ff9d0b2f9aba410ec02dddf499895dae228b252a728eb2d55
3
+ metadata.gz: f2cf305464b1da18b681573d4e895ba407a3205665d17b2a6ebb344dfcf53d0c
4
+ data.tar.gz: baaf64ed79b78aaea3b4d19a60d4f068f38bee2473dae5ec7ac7a85392e8b05d
5
5
  SHA512:
6
- metadata.gz: 0d1741d4b3823b2c3d703ab400a4a11f6738321a73c0463aa5590cdd1a2bd1fe97e31c561e1d8745f75908f4bef62bcc4916242ff76c18b633b64de8fa29b1e6
7
- data.tar.gz: 8566b0b3f4a36ba63849bbbb0ca51f13c3e4e23820ff155213563fded10915441d5be66137b5c4e44fa7c01a33fe7209a2c39cc8d0c1a900f186cc24b1d9696e
6
+ metadata.gz: 9c78ebf762c39a959945fba05bea127029d9594dcdf973e146e47ad9a5d1070e1db4196c2deac23e1c8ce44c886547b25e5f092f19f7b2643fe3b8611f67afab
7
+ data.tar.gz: 96633f2c63bd2e512a57e45130ce71aacc5d16f4e1636f77be274bfe405be9526728c69ab4d6d14bf9db5a13805cd30ccb6e47690f73db522df52c450d7c7ee2
@@ -1,3 +1,3 @@
1
1
  module SingleCov
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
data/lib/single_cov.rb CHANGED
@@ -12,11 +12,13 @@ module SingleCov
12
12
  end
13
13
 
14
14
  def not_covered!
15
+ store_pid
15
16
  end
16
17
 
17
18
  def covered!(file: nil, uncovered: 0)
18
19
  file = guess_and_check_covered_file(file)
19
20
  COVERAGES << [file, uncovered]
21
+ store_pid
20
22
  end
21
23
 
22
24
  def all_covered?(result)
@@ -27,7 +29,7 @@ module SingleCov
27
29
  branch_coverage = (coverage.is_a?(Hash) && coverage[:branches])
28
30
 
29
31
  if branch_coverage
30
- uncovered.concat uncovered_branches(file, branch_coverage, uncovered)
32
+ uncovered.concat uncovered_branches(branch_coverage, uncovered)
31
33
  end
32
34
 
33
35
  next if uncovered.size == expected_uncovered
@@ -110,7 +112,7 @@ module SingleCov
110
112
  start_coverage_recording
111
113
 
112
114
  override_at_exit do |status, _exception|
113
- exit 1 if (!defined?(@disabled) || !@disabled) && status == 0 && !SingleCov.all_covered?(coverage_results)
115
+ exit 1 if enabled? && main_process? && status == 0 && !SingleCov.all_covered?(coverage_results)
114
116
  end
115
117
  end
116
118
 
@@ -121,7 +123,19 @@ module SingleCov
121
123
 
122
124
  private
123
125
 
124
- def uncovered_branches(file, coverage, uncovered_lines)
126
+ def enabled?
127
+ (!defined?(@disabled) || !@disabled)
128
+ end
129
+
130
+ def store_pid
131
+ @pid = Process.pid
132
+ end
133
+
134
+ def main_process?
135
+ (!defined?(@pid) || @pid == Process.pid)
136
+ end
137
+
138
+ def uncovered_branches(coverage, uncovered_lines)
125
139
  # {[branch_id] => {[branch_part] => coverage}} --> {branch_part -> sum-of-coverage}
126
140
  sum = Hash.new(0)
127
141
  coverage.each_value do |branch|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: single_cov
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.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: 2018-10-27 00:00:00.000000000 Z
11
+ date: 2018-12-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it