simplecov-cobertura 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +28 -0
- data/.gitignore +1 -1
- data/.ruby-version +1 -0
- data/README.md +4 -20
- data/lib/simplecov-cobertura/version.rb +1 -1
- data/lib/simplecov-cobertura.rb +119 -71
- data/simplecov-cobertura.gemspec +4 -11
- data/test/coverage/coverage.xml +21 -0
- data/test/simplecov-cobertura_test.rb +60 -32
- metadata +30 -13
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ce7b99ac8380e1a484798858b4b10aecd158c7287b94db50cff33e498bd89239
|
|
4
|
+
data.tar.gz: b014a903090c15eb923fe7056c5d53a4fa8fd447726f26fa4b705bb3e72010db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3902717d69048539f0b1ffc2a4bcab3df384976745ffdafb308d3242232ca588f09aa6c7c954c6719a8899666038248caa208b279608fb4d063ead92019b03c1
|
|
7
|
+
data.tar.gz: e2170d9b3ceb19976b091a3519965ddd3ad4b88aa85519c67802edd27a3f18ddfcafa27471caf516d6088a95d2aba0941157b6cb10ff7a2710910cc4ee8256e9
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
+
# They are provided by a third-party and are governed by
|
|
3
|
+
# separate terms of service, privacy policy, and support
|
|
4
|
+
# documentation.
|
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
+
|
|
8
|
+
name: Build
|
|
9
|
+
|
|
10
|
+
on: [push, pull_request]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
ruby-version: [2.5, 2.6, 2.7, 3.0]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v2
|
|
22
|
+
- name: Set up Ruby
|
|
23
|
+
uses: ruby/setup-ruby@v1
|
|
24
|
+
with:
|
|
25
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
26
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
27
|
+
- name: Run tests
|
|
28
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.2
|
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# simplecov-cobertura
|
|
2
|
-
[](https://github.com/dashingrocket/simplecov-cobertura/actions/workflows/build.yml) [](http://badge.fury.io/rb/simplecov-cobertura) [](https://rubygems.org/gems/simplecov-cobertura)
|
|
3
|
+
|
|
3
4
|
|
|
4
5
|
Produces [Cobertura](http://cobertura.sourceforge.net/) formatted XML from [SimpleCov](https://github.com/colszowka/simplecov).
|
|
5
6
|
|
|
@@ -32,27 +33,10 @@ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
|
|
32
33
|
|
|
33
34
|
## Continuous Integration
|
|
34
35
|
Tested in a CI environment against the following Ruby versions:
|
|
36
|
+
* 3.0
|
|
35
37
|
* 2.7
|
|
36
38
|
* 2.6
|
|
37
39
|
* 2.5
|
|
38
|
-
* 2.4
|
|
39
|
-
* 2.3
|
|
40
|
-
* 2.2
|
|
41
|
-
* 2.1
|
|
42
|
-
* 2.0
|
|
43
|
-
* 1.9
|
|
44
|
-
|
|
45
|
-
## Known Limitations
|
|
46
|
-
* No support for branch coverage
|
|
47
|
-
|
|
48
|
-
## Contributors
|
|
49
|
-
* Jesse Bowes
|
|
50
|
-
* Sean Clemmer
|
|
51
|
-
* Ivailo Petrov
|
|
52
|
-
* Rob Lester
|
|
53
|
-
* Denis <Zaratan> Pasin
|
|
54
|
-
* Jesper Rønn-Jensen
|
|
55
|
-
* Pramod Shinde
|
|
56
40
|
|
|
57
41
|
## Contributing
|
|
58
42
|
|
|
@@ -63,7 +47,7 @@ Tested in a CI environment against the following Ruby versions:
|
|
|
63
47
|
5. Create a new Pull Request
|
|
64
48
|
|
|
65
49
|
## License
|
|
66
|
-
Copyright
|
|
50
|
+
Copyright 2021 Dashing Rocket, Ltd.
|
|
67
51
|
|
|
68
52
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
69
53
|
you may not use this file except in compliance with the License.
|
data/lib/simplecov-cobertura.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'simplecov'
|
|
|
2
2
|
|
|
3
3
|
require 'rexml/document'
|
|
4
4
|
require 'rexml/element'
|
|
5
|
+
require 'pathname'
|
|
5
6
|
|
|
6
7
|
require_relative 'simplecov-cobertura/version'
|
|
7
8
|
|
|
@@ -27,97 +28,144 @@ module SimpleCov
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
private
|
|
30
|
-
def result_to_xml(result)
|
|
31
|
-
doc = REXML::Document.new set_xml_head
|
|
32
|
-
doc.context[:attribute_quote] = :quote
|
|
33
|
-
doc.add_element REXML::Element.new('coverage')
|
|
34
|
-
coverage = doc.root
|
|
35
31
|
|
|
36
|
-
|
|
32
|
+
def result_to_xml(result)
|
|
33
|
+
doc = REXML::Document.new set_xml_head
|
|
34
|
+
doc.context[:attribute_quote] = :quote
|
|
35
|
+
doc.add_element REXML::Element.new('coverage')
|
|
36
|
+
coverage = doc.root
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
sources.add_element(source = REXML::Element.new('source'))
|
|
40
|
-
source.text = SimpleCov.root
|
|
38
|
+
set_coverage_attributes(coverage, result)
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
coverage.add_element(sources = REXML::Element.new('sources'))
|
|
41
|
+
sources.add_element(source = REXML::Element.new('source'))
|
|
42
|
+
source.text = SimpleCov.root
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
coverage.add_element(packages = REXML::Element.new('packages'))
|
|
45
|
+
|
|
46
|
+
if result.groups.empty?
|
|
47
|
+
groups = {File.basename(SimpleCov.root) => result.files}
|
|
48
|
+
else
|
|
49
|
+
groups = result.groups
|
|
50
|
+
end
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
groups.each do |name, files|
|
|
53
|
+
next if files.empty?
|
|
54
|
+
packages.add_element(package = REXML::Element.new('package'))
|
|
55
|
+
set_package_attributes(package, name, files)
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
package.add_element(classes = REXML::Element.new('classes'))
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
files.each do |file|
|
|
60
|
+
classes.add_element(class_ = REXML::Element.new('class'))
|
|
61
|
+
set_class_attributes(class_, file)
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
class_.add_element(REXML::Element.new('methods'))
|
|
64
|
+
class_.add_element(lines = REXML::Element.new('lines'))
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
branched_lines = file.branches.map(&:start_line)
|
|
67
|
+
branched_lines_covered = file.covered_branches.map(&:start_line)
|
|
68
|
+
|
|
69
|
+
file.lines.each do |file_line|
|
|
70
|
+
if file_line.covered? || file_line.missed?
|
|
71
|
+
lines.add_element(line = REXML::Element.new('line'))
|
|
72
|
+
set_line_attributes(line, file_line)
|
|
73
|
+
set_branch_attributes(line, file_line, branched_lines, branched_lines_covered) if SimpleCov.branch_coverage?
|
|
74
|
+
end
|
|
67
75
|
end
|
|
68
76
|
end
|
|
69
77
|
end
|
|
78
|
+
|
|
79
|
+
doc
|
|
70
80
|
end
|
|
71
81
|
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
def set_coverage_attributes(coverage, result)
|
|
83
|
+
ls = result.coverage_statistics[:line]
|
|
84
|
+
bs = result.coverage_statistics[:branch]
|
|
85
|
+
|
|
86
|
+
coverage.attributes['line-rate'] = extract_rate(ls.percent)
|
|
87
|
+
coverage.attributes['lines-covered'] = ls.covered.to_s.to_s
|
|
88
|
+
coverage.attributes['lines-valid'] = ls.total.to_s.to_s
|
|
89
|
+
if SimpleCov.branch_coverage?
|
|
90
|
+
coverage.attributes['branches-covered'] = bs.covered.to_s
|
|
91
|
+
coverage.attributes['branches-valid'] = bs.total.to_s
|
|
92
|
+
coverage.attributes['branch-rate'] = extract_rate(bs.percent)
|
|
93
|
+
end
|
|
94
|
+
coverage.attributes['complexity'] = '0'
|
|
95
|
+
coverage.attributes['version'] = '0'
|
|
96
|
+
coverage.attributes['timestamp'] = Time.now.to_i.to_s
|
|
97
|
+
end
|
|
74
98
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
coverage.attributes['lines-covered'] = result.covered_lines.to_s
|
|
79
|
-
coverage.attributes['lines-valid'] = (result.covered_lines + result.missed_lines).to_s
|
|
80
|
-
coverage.attributes['branches-covered'] = '0'
|
|
81
|
-
coverage.attributes['branches-valid'] = '0'
|
|
82
|
-
coverage.attributes['branch-rate'] = '0'
|
|
83
|
-
coverage.attributes['complexity'] = '0'
|
|
84
|
-
coverage.attributes['version'] = '0'
|
|
85
|
-
coverage.attributes['timestamp'] = Time.now.to_i.to_s
|
|
86
|
-
end
|
|
99
|
+
def set_package_attributes(package, name, result)
|
|
100
|
+
ls = result.coverage_statistics[:line]
|
|
101
|
+
bs = result.coverage_statistics[:branch]
|
|
87
102
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
package.attributes['name'] = name
|
|
104
|
+
package.attributes['line-rate'] = extract_rate(ls.percent)
|
|
105
|
+
if SimpleCov.branch_coverage?
|
|
106
|
+
package.attributes['branch-rate'] = extract_rate(bs.percent)
|
|
107
|
+
end
|
|
108
|
+
package.attributes['complexity'] = '0'
|
|
109
|
+
end
|
|
94
110
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
class_.attributes['name'] = File.basename(filename, '.*')
|
|
99
|
-
class_.attributes['filename'] = path
|
|
100
|
-
class_.attributes['line-rate'] = (file.covered_percent/100).round(2).to_s
|
|
101
|
-
class_.attributes['branch-rate'] = '0'
|
|
102
|
-
class_.attributes['complexity'] = '0'
|
|
103
|
-
end
|
|
111
|
+
def set_class_attributes(class_, file)
|
|
112
|
+
ls = file.coverage_statistics[:line]
|
|
113
|
+
bs = file.coverage_statistics[:branch]
|
|
104
114
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
filename = file.filename
|
|
116
|
+
class_.attributes['name'] = File.basename(filename, '.*')
|
|
117
|
+
class_.attributes['filename'] = resolve_filename(filename)
|
|
118
|
+
class_.attributes['line-rate'] = extract_rate(ls.percent)
|
|
119
|
+
if SimpleCov.branch_coverage?
|
|
120
|
+
class_.attributes['branch-rate'] = extract_rate(bs.percent)
|
|
121
|
+
end
|
|
122
|
+
class_.attributes['complexity'] = '0'
|
|
123
|
+
end
|
|
110
124
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
lines.join("\n")
|
|
116
|
-
end
|
|
125
|
+
def set_line_attributes(line, file_line)
|
|
126
|
+
line.attributes['number'] = file_line.line_number.to_s
|
|
127
|
+
line.attributes['hits'] = file_line.coverage.to_s
|
|
128
|
+
end
|
|
117
129
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
def set_branch_attributes(line, file_line, branched_lines, branched_lines_covered)
|
|
131
|
+
if branched_lines.include? file_line.number
|
|
132
|
+
pct_coverage, branches_covered = branched_lines_covered.include?(file_line.number) ? [100, '1/1'] : [0, '0/1']
|
|
133
|
+
line.attributes['branch'] = 'true'
|
|
134
|
+
line.attributes['condition-coverage'] = "#{pct_coverage}% (#{branches_covered})"
|
|
135
|
+
else
|
|
136
|
+
line.attributes['branch'] = 'false'
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def set_xml_head(lines=[])
|
|
141
|
+
lines << "<?xml version=\"1.0\"?>"
|
|
142
|
+
lines << "<!DOCTYPE coverage SYSTEM \"#{DTD_URL}\">"
|
|
143
|
+
lines << "<!-- Generated by simplecov-cobertura version #{VERSION} (https://github.com/dashingrocket/simplecov-cobertura) -->"
|
|
144
|
+
lines.join("\n")
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def coverage_output(result)
|
|
148
|
+
ls = result.coverage_statistics[:line]
|
|
149
|
+
bs = result.coverage_statistics[:branch]
|
|
150
|
+
|
|
151
|
+
if SimpleCov.branch_coverage?
|
|
152
|
+
"%d / %d LOC (%.2f%%) covered; %d / %d BC (%.2f%%) covered" % [ls.covered, ls.total, ls.percent, bs.covered, bs.total, bs.percent]
|
|
153
|
+
else
|
|
154
|
+
"%d / %d LOC (%.2f%%) covered" % [ls.covered, ls.total, ls.percent]
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def resolve_filename(filename)
|
|
159
|
+
Pathname.new(filename).relative_path_from(project_root).to_s
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def extract_rate(percent)
|
|
163
|
+
(percent / 100).round(2).to_s
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def project_root
|
|
167
|
+
@project_root ||= Pathname.new(SimpleCov.root)
|
|
168
|
+
end
|
|
121
169
|
end
|
|
122
170
|
end
|
|
123
171
|
end
|
data/simplecov-cobertura.gemspec
CHANGED
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.description = 'Produces Cobertura XML formatted output from SimpleCov'
|
|
14
14
|
spec.homepage = 'https://github.com/dashingrocket/simplecov-cobertura'
|
|
15
15
|
spec.license = 'Apache-2.0'
|
|
16
|
-
spec.required_ruby_version = '>=
|
|
16
|
+
spec.required_ruby_version = '>= 2.5.0'
|
|
17
17
|
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0")
|
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
@@ -22,15 +22,8 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
|
|
23
23
|
spec.add_development_dependency 'test-unit', '~> 3.2'
|
|
24
24
|
spec.add_development_dependency 'nokogiri', '~> 1.0'
|
|
25
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
25
26
|
|
|
26
|
-
spec.add_dependency 'simplecov', '~> 0.
|
|
27
|
-
|
|
28
|
-
if RUBY_VERSION < '2.0'
|
|
29
|
-
spec.add_dependency 'json', '< 2.3.0'
|
|
30
|
-
spec.add_development_dependency 'rake', '~> 12.0', '< 12.3'
|
|
31
|
-
elsif RUBY_VERSION < '2.2'
|
|
32
|
-
spec.add_development_dependency 'rake', '~> 12.0'
|
|
33
|
-
else
|
|
34
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
|
35
|
-
end
|
|
27
|
+
spec.add_dependency 'simplecov', '~> 0.19'
|
|
28
|
+
spec.add_dependency 'rexml'
|
|
36
29
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?xml version='1.0'?>
|
|
2
|
+
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
|
|
3
|
+
<!-- Generated by simplecov-cobertura version 1.4.3-dev (https://github.com/dashingrocket/simplecov-cobertura) -->
|
|
4
|
+
<coverage line-rate="1.0" branch-rate="0" lines-covered="2" lines-valid="2" branches-covered="0" branches-valid="0" complexity="0" version="0" timestamp="1636204971">
|
|
5
|
+
<sources>
|
|
6
|
+
<source>/Users/st0012/projects/simplecov-cobertura/test</source>
|
|
7
|
+
</sources>
|
|
8
|
+
<packages>
|
|
9
|
+
<package name="test" line-rate="1.0" branch-rate="0" complexity="0">
|
|
10
|
+
<classes>
|
|
11
|
+
<class name="simplecov-cobertura_test" filename="simplecov-cobertura_test.rb" line-rate="1.0" branch-rate="0" complexity="0">
|
|
12
|
+
<methods/>
|
|
13
|
+
<lines>
|
|
14
|
+
<line number="1" branch="false" hits="1"/>
|
|
15
|
+
<line number="2" branch="false" hits="2"/>
|
|
16
|
+
</lines>
|
|
17
|
+
</class>
|
|
18
|
+
</classes>
|
|
19
|
+
</package>
|
|
20
|
+
</packages>
|
|
21
|
+
</coverage>
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
require 'test/unit'
|
|
2
|
-
|
|
3
2
|
require 'nokogiri'
|
|
4
|
-
|
|
5
3
|
require 'open-uri'
|
|
6
4
|
require 'simplecov'
|
|
7
5
|
require 'simplecov-cobertura'
|
|
8
6
|
|
|
9
7
|
class CoberturaFormatterTest < Test::Unit::TestCase
|
|
10
|
-
|
|
11
8
|
def setup
|
|
12
|
-
|
|
9
|
+
SimpleCov.enable_coverage :branch
|
|
10
|
+
SimpleCov.coverage_dir "tmp"
|
|
11
|
+
@result = SimpleCov::Result.new({
|
|
12
|
+
"#{__FILE__}" => {
|
|
13
|
+
"lines" => [1, 1, 1, nil, 1, nil, 1, 0, nil, 1, nil, nil, nil],
|
|
14
|
+
"branches" => {
|
|
15
|
+
[:if, 0, 3, 4, 3, 21] =>
|
|
16
|
+
{[:then, 1, 3, 4, 3, 10] => 0, [:else, 2, 3, 4, 3, 21] => 1},
|
|
17
|
+
[:if, 3, 5, 4, 5, 26] =>
|
|
18
|
+
{[:then, 4, 5, 16, 5, 20] => 1, [:else, 5, 5, 23, 5, 26] => 0},
|
|
19
|
+
[:if, 6, 7, 4, 11, 7] =>
|
|
20
|
+
{[:then, 7, 8, 6, 8, 10] => 0, [:else, 8, 10, 6, 10, 9] => 1}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})
|
|
13
24
|
@formatter = SimpleCov::Formatter::CoberturaFormatter.new
|
|
14
25
|
end
|
|
15
26
|
|
|
@@ -43,12 +54,12 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
|
43
54
|
doc = Nokogiri::XML::Document.parse(xml)
|
|
44
55
|
|
|
45
56
|
coverage = doc.xpath '/coverage'
|
|
46
|
-
assert_equal '
|
|
47
|
-
assert_equal '0', coverage.attribute('branch-rate').value
|
|
48
|
-
assert_equal '
|
|
49
|
-
assert_equal '
|
|
50
|
-
assert_equal '
|
|
51
|
-
assert_equal '
|
|
57
|
+
assert_equal '0.86', coverage.attribute('line-rate').value
|
|
58
|
+
assert_equal '0.5', coverage.attribute('branch-rate').value
|
|
59
|
+
assert_equal '6', coverage.attribute('lines-covered').value
|
|
60
|
+
assert_equal '7', coverage.attribute('lines-valid').value
|
|
61
|
+
assert_equal '3', coverage.attribute('branches-covered').value
|
|
62
|
+
assert_equal '6', coverage.attribute('branches-valid').value
|
|
52
63
|
assert_equal '0', coverage.attribute('complexity').value
|
|
53
64
|
assert_equal '0', coverage.attribute('version').value
|
|
54
65
|
assert_not_empty coverage.attribute('timestamp').value
|
|
@@ -61,8 +72,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
|
61
72
|
assert_equal 1, packages.length
|
|
62
73
|
package = packages.first
|
|
63
74
|
assert_equal 'simplecov-cobertura', package.attribute('name').value
|
|
64
|
-
assert_equal '
|
|
65
|
-
assert_equal '0', package.attribute('branch-rate').value
|
|
75
|
+
assert_equal '0.86', package.attribute('line-rate').value
|
|
76
|
+
assert_equal '0.5', package.attribute('branch-rate').value
|
|
66
77
|
assert_equal '0', package.attribute('complexity').value
|
|
67
78
|
|
|
68
79
|
classes = doc.xpath '/coverage/packages/package/classes/class'
|
|
@@ -70,20 +81,20 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
|
70
81
|
clazz = classes.first
|
|
71
82
|
assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
|
|
72
83
|
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
|
|
73
|
-
assert_equal '
|
|
74
|
-
assert_equal '0', clazz.attribute('branch-rate').value
|
|
84
|
+
assert_equal '0.86', clazz.attribute('line-rate').value
|
|
85
|
+
assert_equal '0.5', clazz.attribute('branch-rate').value
|
|
75
86
|
assert_equal '0', clazz.attribute('complexity').value
|
|
76
87
|
|
|
77
88
|
lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
|
|
78
|
-
assert_equal
|
|
89
|
+
assert_equal 7, lines.length
|
|
79
90
|
first_line = lines.first
|
|
80
91
|
assert_equal '1', first_line.attribute('number').value
|
|
81
92
|
assert_equal 'false', first_line.attribute('branch').value
|
|
82
93
|
assert_equal '1', first_line.attribute('hits').value
|
|
83
94
|
last_line = lines.last
|
|
84
|
-
assert_equal '
|
|
85
|
-
assert_equal '
|
|
86
|
-
assert_equal '
|
|
95
|
+
assert_equal '10', last_line.attribute('number').value
|
|
96
|
+
assert_equal 'true', last_line.attribute('branch').value
|
|
97
|
+
assert_equal '1', last_line.attribute('hits').value
|
|
87
98
|
end
|
|
88
99
|
|
|
89
100
|
def test_groups
|
|
@@ -93,12 +104,12 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
|
93
104
|
doc = Nokogiri::XML::Document.parse(xml)
|
|
94
105
|
|
|
95
106
|
coverage = doc.xpath '/coverage'
|
|
96
|
-
assert_equal '
|
|
97
|
-
assert_equal '0', coverage.attribute('branch-rate').value
|
|
98
|
-
assert_equal '
|
|
99
|
-
assert_equal '
|
|
100
|
-
assert_equal '
|
|
101
|
-
assert_equal '
|
|
107
|
+
assert_equal '0.86', coverage.attribute('line-rate').value
|
|
108
|
+
assert_equal '0.5', coverage.attribute('branch-rate').value
|
|
109
|
+
assert_equal '6', coverage.attribute('lines-covered').value
|
|
110
|
+
assert_equal '7', coverage.attribute('lines-valid').value
|
|
111
|
+
assert_equal '3', coverage.attribute('branches-covered').value
|
|
112
|
+
assert_equal '6', coverage.attribute('branches-valid').value
|
|
102
113
|
assert_equal '0', coverage.attribute('complexity').value
|
|
103
114
|
assert_equal '0', coverage.attribute('version').value
|
|
104
115
|
assert_not_empty coverage.attribute('timestamp').value
|
|
@@ -111,8 +122,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
|
111
122
|
assert_equal 1, packages.length
|
|
112
123
|
package = packages.first
|
|
113
124
|
assert_equal 'test_group', package.attribute('name').value
|
|
114
|
-
assert_equal '
|
|
115
|
-
assert_equal '0', package.attribute('branch-rate').value
|
|
125
|
+
assert_equal '0.86', package.attribute('line-rate').value
|
|
126
|
+
assert_equal '0.5', package.attribute('branch-rate').value
|
|
116
127
|
assert_equal '0', package.attribute('complexity').value
|
|
117
128
|
|
|
118
129
|
classes = doc.xpath '/coverage/packages/package/classes/class'
|
|
@@ -120,19 +131,36 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
|
120
131
|
clazz = classes.first
|
|
121
132
|
assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
|
|
122
133
|
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
|
|
123
|
-
assert_equal '
|
|
124
|
-
assert_equal '0', clazz.attribute('branch-rate').value
|
|
134
|
+
assert_equal '0.86', clazz.attribute('line-rate').value
|
|
135
|
+
assert_equal '0.5', clazz.attribute('branch-rate').value
|
|
125
136
|
assert_equal '0', clazz.attribute('complexity').value
|
|
126
137
|
|
|
127
138
|
lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
|
|
128
|
-
assert_equal
|
|
139
|
+
assert_equal 7, lines.length
|
|
129
140
|
first_line = lines.first
|
|
130
141
|
assert_equal '1', first_line.attribute('number').value
|
|
131
142
|
assert_equal 'false', first_line.attribute('branch').value
|
|
132
143
|
assert_equal '1', first_line.attribute('hits').value
|
|
133
144
|
last_line = lines.last
|
|
134
|
-
assert_equal '
|
|
135
|
-
assert_equal '
|
|
136
|
-
assert_equal '
|
|
145
|
+
assert_equal '10', last_line.attribute('number').value
|
|
146
|
+
assert_equal 'true', last_line.attribute('branch').value
|
|
147
|
+
assert_equal '1', last_line.attribute('hits').value
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_supports_root_project_path
|
|
151
|
+
old_root = SimpleCov.root
|
|
152
|
+
SimpleCov.root("/tmp")
|
|
153
|
+
expected_base = old_root[1..-1] # Remove leading "/"
|
|
154
|
+
|
|
155
|
+
xml = @formatter.format(@result)
|
|
156
|
+
doc = Nokogiri::XML::Document.parse(xml)
|
|
157
|
+
|
|
158
|
+
classes = doc.xpath '/coverage/packages/package/classes/class'
|
|
159
|
+
assert_equal 1, classes.length
|
|
160
|
+
clazz = classes.first
|
|
161
|
+
assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
|
|
162
|
+
assert_equal "../#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
|
|
163
|
+
ensure
|
|
164
|
+
SimpleCov.root(old_root)
|
|
137
165
|
end
|
|
138
166
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simplecov-cobertura
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jesse Bowes
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-11-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-unit
|
|
@@ -39,33 +39,47 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '1.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0
|
|
48
|
-
type: :
|
|
47
|
+
version: '13.0'
|
|
48
|
+
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0
|
|
54
|
+
version: '13.0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: simplecov
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
62
|
-
type: :
|
|
61
|
+
version: '0.19'
|
|
62
|
+
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
68
|
+
version: '0.19'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rexml
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
69
83
|
description: Produces Cobertura XML formatted output from SimpleCov
|
|
70
84
|
email:
|
|
71
85
|
- jbowes@dashingrocket.com
|
|
@@ -73,8 +87,9 @@ executables: []
|
|
|
73
87
|
extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
|
75
89
|
files:
|
|
90
|
+
- ".github/workflows/build.yml"
|
|
76
91
|
- ".gitignore"
|
|
77
|
-
- ".
|
|
92
|
+
- ".ruby-version"
|
|
78
93
|
- Gemfile
|
|
79
94
|
- LICENSE
|
|
80
95
|
- README.md
|
|
@@ -82,6 +97,7 @@ files:
|
|
|
82
97
|
- lib/simplecov-cobertura.rb
|
|
83
98
|
- lib/simplecov-cobertura/version.rb
|
|
84
99
|
- simplecov-cobertura.gemspec
|
|
100
|
+
- test/coverage/coverage.xml
|
|
85
101
|
- test/simplecov-cobertura_test.rb
|
|
86
102
|
homepage: https://github.com/dashingrocket/simplecov-cobertura
|
|
87
103
|
licenses:
|
|
@@ -95,16 +111,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
95
111
|
requirements:
|
|
96
112
|
- - ">="
|
|
97
113
|
- !ruby/object:Gem::Version
|
|
98
|
-
version:
|
|
114
|
+
version: 2.5.0
|
|
99
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
116
|
requirements:
|
|
101
117
|
- - ">="
|
|
102
118
|
- !ruby/object:Gem::Version
|
|
103
119
|
version: '0'
|
|
104
120
|
requirements: []
|
|
105
|
-
rubygems_version: 3.1.
|
|
121
|
+
rubygems_version: 3.1.6
|
|
106
122
|
signing_key:
|
|
107
123
|
specification_version: 4
|
|
108
124
|
summary: SimpleCov Cobertura Formatter
|
|
109
125
|
test_files:
|
|
126
|
+
- test/coverage/coverage.xml
|
|
110
127
|
- test/simplecov-cobertura_test.rb
|