simplecov-cobertura 2.1.0 → 3.1.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 +2 -2
- data/.gitignore +1 -0
- data/README.md +5 -7
- data/lib/simplecov-cobertura/version.rb +1 -1
- data/lib/simplecov-cobertura.rb +15 -23
- data/simplecov-cobertura.gemspec +2 -2
- data/test/simplecov-cobertura_test.rb +37 -27
- metadata +5 -10
- data/test/coverage/coverage.xml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04ae07cb7f6bb85ad36640169b7d630c985ca1d3d067ef3485ea531b7b775209
|
4
|
+
data.tar.gz: 42f5899bf07710880548d48a27d8d59d2eef1b4d10a05374c44e4344f8f0ac54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e35c59ec78263fe81826f47b83ff5e160e08bf8aa4e01a01b943d1671974c853737e4742e5073997e4ac40d77f54f4f29a1f3d29b17a8e93021432c3f7814fc1
|
7
|
+
data.tar.gz: b320d8920cfb8a354031628b045077387474fb07511547cc14f277a00362fcd34ef9974dfb0464cda308f5f167e0c3c3c4bbf932b3608e463bc948dbeb0696da
|
data/.github/workflows/build.yml
CHANGED
@@ -15,7 +15,7 @@ jobs:
|
|
15
15
|
runs-on: ubuntu-latest
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
ruby-version: [2.5, 2.6, 2.7, 3.0]
|
18
|
+
ruby-version: [2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, 3.4]
|
19
19
|
|
20
20
|
steps:
|
21
21
|
- uses: actions/checkout@v2
|
@@ -25,4 +25,4 @@ jobs:
|
|
25
25
|
ruby-version: ${{ matrix.ruby-version }}
|
26
26
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
27
27
|
- name: Run tests
|
28
|
-
run: bundle exec rake
|
28
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# simplecov-cobertura
|
2
|
-
[](https://github.com/jessebs/simplecov-cobertura/actions/workflows/build.yml) [](http://badge.fury.io/rb/simplecov-cobertura)
|
3
3
|
|
4
4
|
|
5
5
|
Produces [Cobertura](http://cobertura.sourceforge.net/) formatted XML from [SimpleCov](https://github.com/colszowka/simplecov).
|
@@ -33,21 +33,19 @@ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
|
33
33
|
|
34
34
|
## Continuous Integration
|
35
35
|
Tested in a CI environment against the following Ruby versions:
|
36
|
-
* 3.0
|
37
|
-
* 2.7
|
38
|
-
* 2.6
|
39
|
-
* 2.5
|
36
|
+
* 3.0 - 3.4
|
37
|
+
* 2.5 - 2.7
|
40
38
|
|
41
39
|
## Contributing
|
42
40
|
|
43
|
-
1. Fork it ( https://github.com/
|
41
|
+
1. Fork it ( https://github.com/jessebs/simplecov-cobertura/fork )
|
44
42
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
43
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
44
|
4. Push to the branch (`git push origin my-new-feature`)
|
47
45
|
5. Create a new Pull Request
|
48
46
|
|
49
47
|
## License
|
50
|
-
Copyright
|
48
|
+
Copyright 2025 Jesse Bowes
|
51
49
|
|
52
50
|
Licensed under the Apache License, Version 2.0 (the "License");
|
53
51
|
you may not use this file except in compliance with the License.
|
data/lib/simplecov-cobertura.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
|
3
1
|
require 'rexml/document'
|
4
2
|
require 'rexml/element'
|
5
3
|
require 'pathname'
|
@@ -27,15 +25,19 @@ module SimpleCov
|
|
27
25
|
|
28
26
|
xml_str = string_io.string
|
29
27
|
File.write(result_path, xml_str)
|
30
|
-
puts
|
28
|
+
puts output_message(result, result_path)
|
29
|
+
|
31
30
|
xml_str
|
32
31
|
end
|
33
32
|
|
34
33
|
private
|
35
34
|
|
36
35
|
def result_to_xml(result)
|
37
|
-
doc = REXML::Document.new
|
36
|
+
doc = REXML::Document.new
|
38
37
|
doc.context[:attribute_quote] = :quote
|
38
|
+
doc << REXML::XMLDecl.new('1.0')
|
39
|
+
doc << REXML::DocType.new('coverage', "SYSTEM \"#{DTD_URL}\"")
|
40
|
+
doc << REXML::Comment.new("Generated by simplecov-cobertura version #{VERSION} (https://github.com/jessebs/simplecov-cobertura)")
|
39
41
|
doc.add_element REXML::Element.new('coverage')
|
40
42
|
coverage = doc.root
|
41
43
|
|
@@ -117,7 +119,7 @@ module SimpleCov
|
|
117
119
|
bs = file.coverage_statistics[:branch]
|
118
120
|
|
119
121
|
filename = file.filename
|
120
|
-
class_.attributes['name'] =
|
122
|
+
class_.attributes['name'] = resolve_filename(filename)
|
121
123
|
class_.attributes['filename'] = resolve_filename(filename)
|
122
124
|
class_.attributes['line-rate'] = extract_rate(ls.percent)
|
123
125
|
if SimpleCov.branch_coverage?
|
@@ -141,30 +143,20 @@ module SimpleCov
|
|
141
143
|
end
|
142
144
|
end
|
143
145
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
def coverage_output(result)
|
152
|
-
ls = result.coverage_statistics[:line]
|
153
|
-
bs = result.coverage_statistics[:branch]
|
154
|
-
|
155
|
-
if SimpleCov.branch_coverage?
|
156
|
-
"%d / %d LOC (%.2f%%) covered; %d / %d BC (%.2f%%) covered" % [ls.covered, ls.total, ls.percent, bs.covered, bs.total, bs.percent]
|
157
|
-
else
|
158
|
-
"%d / %d LOC (%.2f%%) covered" % [ls.covered, ls.total, ls.percent]
|
159
|
-
end
|
160
|
-
end
|
146
|
+
# Roughly mirrors private method SimpleCov::Formatter::HTMLFormatter#output_coverage
|
147
|
+
def output_message(result, output_path)
|
148
|
+
output = "Coverage report generated for #{result.command_name} to #{output_path}."
|
149
|
+
output += "\nLine Coverage: #{result.covered_percent.round(2)}% (#{result.covered_lines} / #{result.total_lines})"
|
150
|
+
output += "\nBranch Coverage: #{result.coverage_statistics[:branch].percent.round(2)}% (#{result.covered_branches} / #{result.total_branches})" if SimpleCov.branch_coverage?
|
151
|
+
output
|
152
|
+
end
|
161
153
|
|
162
154
|
def resolve_filename(filename)
|
163
155
|
Pathname.new(filename).relative_path_from(project_root).to_s
|
164
156
|
end
|
165
157
|
|
166
158
|
def extract_rate(percent)
|
167
|
-
(percent / 100).round(
|
159
|
+
(percent / 100).round(4).to_s
|
168
160
|
end
|
169
161
|
|
170
162
|
def project_root
|
data/simplecov-cobertura.gemspec
CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = 'simplecov-cobertura'
|
9
9
|
spec.version = SimpleCov::Formatter::CoberturaFormatter::VERSION
|
10
10
|
spec.authors = ['Jesse Bowes']
|
11
|
-
spec.email = ['
|
11
|
+
spec.email = ['jessebowes@acm.org']
|
12
12
|
spec.summary = 'SimpleCov Cobertura Formatter'
|
13
13
|
spec.description = 'Produces Cobertura XML formatted output from SimpleCov'
|
14
|
-
spec.homepage = 'https://github.com/
|
14
|
+
spec.homepage = 'https://github.com/jessebs/simplecov-cobertura'
|
15
15
|
spec.license = 'Apache-2.0'
|
16
16
|
spec.required_ruby_version = '>= 2.5.0'
|
17
17
|
|
@@ -17,7 +17,13 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
17
17
|
[:if, 3, 5, 4, 5, 26] =>
|
18
18
|
{[:then, 4, 5, 16, 5, 20] => 1, [:else, 5, 5, 23, 5, 26] => 0},
|
19
19
|
[:if, 6, 7, 4, 11, 7] =>
|
20
|
-
{[:then, 7, 8, 6, 8, 10] => 0, [:else, 8, 10, 6, 10, 9] => 1}
|
20
|
+
{[:then, 7, 8, 6, 8, 10] => 0, [:else, 8, 10, 6, 10, 9] => 1},
|
21
|
+
[:if, 9, 12, 4, 12, 15] =>
|
22
|
+
{[:then, 10, 12, 6, 12, 10] => 1, [:else, 11, 12, 13, 12, 15] => 0},
|
23
|
+
[:if, 12, 13, 4, 13, 20] =>
|
24
|
+
{[:then, 13, 13, 6, 13, 15] => 1, [:else, 14, 13, 18, 13, 20] => 0},
|
25
|
+
[:if, 15, 15, 4, 15, 25] =>
|
26
|
+
{[:then, 16, 15, 6, 15, 20] => 0, [:else, 17, 15, 23, 15, 25] => 0}
|
21
27
|
}
|
22
28
|
}
|
23
29
|
})
|
@@ -45,28 +51,32 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
45
51
|
def test_terminal_output
|
46
52
|
output, _ = capture_output { @formatter.format(@result) }
|
47
53
|
result_path = File.join(SimpleCov.coverage_path, SimpleCov::Formatter::CoberturaFormatter::RESULT_FILE_NAME)
|
48
|
-
output_regex = /Coverage report generated for #{@result.command_name} to #{result_path}
|
54
|
+
output_regex = /Coverage report generated for #{@result.command_name} to #{result_path}.\nLine Coverage: (.*)\nBranch Coverage: (.*)/
|
49
55
|
assert_match(output_regex, output)
|
50
56
|
end
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
# Rather than support HTTPS the HTTP client was removed from libxml2 / xmllint:
|
59
|
+
# https://gitlab.gnome.org/GNOME/libxml2/-/issues/160
|
60
|
+
# I am not sure what this means for Nokogiri or this issue, but it certainly means something will change soon.
|
61
|
+
# Disable this test until it becomes clear what the new behavior should be.
|
62
|
+
# def test_format_dtd_validates
|
63
|
+
# xml = @formatter.format(@result)
|
64
|
+
# options = Nokogiri::XML::ParseOptions::DTDLOAD
|
65
|
+
# doc = Nokogiri::XML::Document.parse(xml, nil, nil, options)
|
66
|
+
# assert_empty doc.external_subset.validate(doc)
|
67
|
+
# end
|
58
68
|
|
59
69
|
def test_no_groups
|
60
70
|
xml = @formatter.format(@result)
|
61
71
|
doc = Nokogiri::XML::Document.parse(xml)
|
62
72
|
|
63
73
|
coverage = doc.xpath '/coverage'
|
64
|
-
assert_equal '0.
|
65
|
-
assert_equal '0.
|
74
|
+
assert_equal '0.8571', coverage.attribute('line-rate').value
|
75
|
+
assert_equal '0.4167', coverage.attribute('branch-rate').value
|
66
76
|
assert_equal '6', coverage.attribute('lines-covered').value
|
67
77
|
assert_equal '7', coverage.attribute('lines-valid').value
|
68
|
-
assert_equal '
|
69
|
-
assert_equal '
|
78
|
+
assert_equal '5', coverage.attribute('branches-covered').value
|
79
|
+
assert_equal '12', coverage.attribute('branches-valid').value
|
70
80
|
assert_equal '0', coverage.attribute('complexity').value
|
71
81
|
assert_equal '0', coverage.attribute('version').value
|
72
82
|
assert_not_empty coverage.attribute('timestamp').value
|
@@ -79,17 +89,17 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
79
89
|
assert_equal 1, packages.length
|
80
90
|
package = packages.first
|
81
91
|
assert_equal 'simplecov-cobertura', package.attribute('name').value
|
82
|
-
assert_equal '0.
|
83
|
-
assert_equal '0.
|
92
|
+
assert_equal '0.8571', package.attribute('line-rate').value
|
93
|
+
assert_equal '0.4167', package.attribute('branch-rate').value
|
84
94
|
assert_equal '0', package.attribute('complexity').value
|
85
95
|
|
86
96
|
classes = doc.xpath '/coverage/packages/package/classes/class'
|
87
97
|
assert_equal 1, classes.length
|
88
98
|
clazz = classes.first
|
89
|
-
assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
|
99
|
+
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('name').value
|
90
100
|
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
|
91
|
-
assert_equal '0.
|
92
|
-
assert_equal '0.
|
101
|
+
assert_equal '0.8571', clazz.attribute('line-rate').value
|
102
|
+
assert_equal '0.4167', clazz.attribute('branch-rate').value
|
93
103
|
assert_equal '0', clazz.attribute('complexity').value
|
94
104
|
|
95
105
|
lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
|
@@ -111,12 +121,12 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
111
121
|
doc = Nokogiri::XML::Document.parse(xml)
|
112
122
|
|
113
123
|
coverage = doc.xpath '/coverage'
|
114
|
-
assert_equal '0.
|
115
|
-
assert_equal '0.
|
124
|
+
assert_equal '0.8571', coverage.attribute('line-rate').value
|
125
|
+
assert_equal '0.4167', coverage.attribute('branch-rate').value
|
116
126
|
assert_equal '6', coverage.attribute('lines-covered').value
|
117
127
|
assert_equal '7', coverage.attribute('lines-valid').value
|
118
|
-
assert_equal '
|
119
|
-
assert_equal '
|
128
|
+
assert_equal '5', coverage.attribute('branches-covered').value
|
129
|
+
assert_equal '12', coverage.attribute('branches-valid').value
|
120
130
|
assert_equal '0', coverage.attribute('complexity').value
|
121
131
|
assert_equal '0', coverage.attribute('version').value
|
122
132
|
assert_not_empty coverage.attribute('timestamp').value
|
@@ -129,17 +139,17 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
129
139
|
assert_equal 1, packages.length
|
130
140
|
package = packages.first
|
131
141
|
assert_equal 'test_group', package.attribute('name').value
|
132
|
-
assert_equal '0.
|
133
|
-
assert_equal '0.
|
142
|
+
assert_equal '0.8571', package.attribute('line-rate').value
|
143
|
+
assert_equal '0.4167', package.attribute('branch-rate').value
|
134
144
|
assert_equal '0', package.attribute('complexity').value
|
135
145
|
|
136
146
|
classes = doc.xpath '/coverage/packages/package/classes/class'
|
137
147
|
assert_equal 1, classes.length
|
138
148
|
clazz = classes.first
|
139
|
-
assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
|
149
|
+
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('name').value
|
140
150
|
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
|
141
|
-
assert_equal '0.
|
142
|
-
assert_equal '0.
|
151
|
+
assert_equal '0.8571', clazz.attribute('line-rate').value
|
152
|
+
assert_equal '0.4167', clazz.attribute('branch-rate').value
|
143
153
|
assert_equal '0', clazz.attribute('complexity').value
|
144
154
|
|
145
155
|
lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
|
@@ -165,7 +175,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
165
175
|
classes = doc.xpath '/coverage/packages/package/classes/class'
|
166
176
|
assert_equal 1, classes.length
|
167
177
|
clazz = classes.first
|
168
|
-
assert_equal
|
178
|
+
assert_equal "../#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('name').value
|
169
179
|
assert_equal "../#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
|
170
180
|
ensure
|
171
181
|
SimpleCov.root(old_root)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov-cobertura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Bowes
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: test-unit
|
@@ -82,7 +81,7 @@ dependencies:
|
|
82
81
|
version: '0'
|
83
82
|
description: Produces Cobertura XML formatted output from SimpleCov
|
84
83
|
email:
|
85
|
-
-
|
84
|
+
- jessebowes@acm.org
|
86
85
|
executables: []
|
87
86
|
extensions: []
|
88
87
|
extra_rdoc_files: []
|
@@ -96,13 +95,11 @@ files:
|
|
96
95
|
- lib/simplecov-cobertura.rb
|
97
96
|
- lib/simplecov-cobertura/version.rb
|
98
97
|
- simplecov-cobertura.gemspec
|
99
|
-
- test/coverage/coverage.xml
|
100
98
|
- test/simplecov-cobertura_test.rb
|
101
|
-
homepage: https://github.com/
|
99
|
+
homepage: https://github.com/jessebs/simplecov-cobertura
|
102
100
|
licenses:
|
103
101
|
- Apache-2.0
|
104
102
|
metadata: {}
|
105
|
-
post_install_message:
|
106
103
|
rdoc_options: []
|
107
104
|
require_paths:
|
108
105
|
- lib
|
@@ -117,10 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
114
|
- !ruby/object:Gem::Version
|
118
115
|
version: '0'
|
119
116
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
121
|
-
signing_key:
|
117
|
+
rubygems_version: 3.6.7
|
122
118
|
specification_version: 4
|
123
119
|
summary: SimpleCov Cobertura Formatter
|
124
120
|
test_files:
|
125
|
-
- test/coverage/coverage.xml
|
126
121
|
- test/simplecov-cobertura_test.rb
|
data/test/coverage/coverage.xml
DELETED
@@ -1,21 +0,0 @@
|
|
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>
|