single_cov 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/single_cov/version.rb +1 -1
- data/lib/single_cov.rb +29 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ff56ca222179db97c40135c3a77650bdb0e50d1
|
4
|
+
data.tar.gz: b5f22da478910a07fbefe85a0beec998ebea7838
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0abece5122f6edfa54926df42c59c6fea6e015fd6771a3f73a0dcc1633bf67785fed005578df3dc6e0e1db88c43b3c2fe39c0cebe3ffe9265a685c3560e0372
|
7
|
+
data.tar.gz: e42f89fd4233535a7b9fe6efe6d2a111bab0b6cf13987c25ea19bba559f0ce29f554a9b06d8f1a5b25e2e56f8479fd598a85b207b5ea6278dd5b34f03072664e
|
data/lib/single_cov/version.rb
CHANGED
data/lib/single_cov.rb
CHANGED
@@ -20,7 +20,13 @@ module SingleCov
|
|
20
20
|
def all_covered?(result)
|
21
21
|
errors = COVERAGES.map do |file, expected_uncovered|
|
22
22
|
if coverage = result["#{root}/#{file}"]
|
23
|
-
|
23
|
+
lines = (coverage.is_a?(Hash) ? coverage.fetch(:lines) : coverage)
|
24
|
+
uncovered_lines = line_coverage(file, lines)
|
25
|
+
|
26
|
+
if branches = (coverage.is_a?(Hash) && coverage[:branches])
|
27
|
+
uncovered_lines += branch_coverage(file, branches)
|
28
|
+
end
|
29
|
+
|
24
30
|
next if uncovered_lines.size == expected_uncovered
|
25
31
|
warn_about_bad_coverage(file, expected_uncovered, uncovered_lines)
|
26
32
|
else
|
@@ -58,10 +64,16 @@ module SingleCov
|
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
61
|
-
def setup(framework, root: nil)
|
67
|
+
def setup(framework, root: nil, branches: false)
|
62
68
|
if defined?(SimpleCov)
|
63
69
|
raise "Load SimpleCov after SingleCov"
|
64
70
|
end
|
71
|
+
if branches && RUBY_VERSION < "2.5.0"
|
72
|
+
warn "Branch coverage needs ruby 2.5.0"
|
73
|
+
@branches = false
|
74
|
+
else
|
75
|
+
@branches = branches
|
76
|
+
end
|
65
77
|
|
66
78
|
@root = root if root
|
67
79
|
|
@@ -89,6 +101,16 @@ module SingleCov
|
|
89
101
|
|
90
102
|
private
|
91
103
|
|
104
|
+
def line_coverage(file, coverage)
|
105
|
+
coverage.each_with_index.map { |c, i| "#{file}:#{i + 1}" if c == 0 }.compact
|
106
|
+
end
|
107
|
+
|
108
|
+
def branch_coverage(file, coverage)
|
109
|
+
coverage.each_value.flat_map do |branch_part|
|
110
|
+
branch_part.select { |_k, v| v == 0 }.map { |k, _| "#{file}:#{k[2]}:#{k[3]+1}-#{k[4]}:#{k[5]+1}" }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
92
114
|
def default_tests
|
93
115
|
glob("{test,spec}/**/*_{test,spec}.rb")
|
94
116
|
end
|
@@ -110,7 +132,11 @@ module SingleCov
|
|
110
132
|
# SimpleCov might start coverage again, but that does not hurt ...
|
111
133
|
def start_coverage_recording
|
112
134
|
require 'coverage'
|
113
|
-
|
135
|
+
if @branches
|
136
|
+
Coverage.start(lines: true, branches: true)
|
137
|
+
else
|
138
|
+
Coverage.start
|
139
|
+
end
|
114
140
|
end
|
115
141
|
|
116
142
|
# not running rake or a whole folder
|
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: 0.
|
4
|
+
version: 0.8.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:
|
11
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
41
|
rubyforge_project:
|
42
|
-
rubygems_version: 2.
|
42
|
+
rubygems_version: 2.6.14
|
43
43
|
signing_key:
|
44
44
|
specification_version: 4
|
45
45
|
summary: Actionable code coverage.
|