simplecov-cobertura 2.1.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c2d0c9eebf10fae25ce491aa5b33fd744cb72c8bd3b9645706e8b6f35495e88
4
- data.tar.gz: 8890ee7ca2a87b49a4f37ee049bbb6d9375f5ead377bc2e3e32ee793883f56a4
3
+ metadata.gz: 7f4e823da3eaf503a2ba1f94202b474e87e1461864d60df99fbef33f55b877d2
4
+ data.tar.gz: 21969345160bc14566b87f3d457f89bb0b27b9f9cc4607cd5a1b7bd658d7b176
5
5
  SHA512:
6
- metadata.gz: ce64fbbd3eb2986a45d90800573739d5f558162a8a66223007926a799e0ba082c4393a7eae1974fe8f40c7b1a22b1f3bebe3adb696805a29a2206c7c5a0b6a21
7
- data.tar.gz: ed1e556b151833e2db0eeb4a2e8a0539946f80af3a3a85429e708a119065def438032eb660437367f1bd34c91eb1d75d7636ca3958844ca83249ef433080eb6d
6
+ metadata.gz: b857a2943394c10dfe3afaf3cfc2bc9c9e809e7aec136503e9ec75f8815008c9f519e7bd6b7f34901905ce92c35bc1b953ca601f74392ff1941fa3b983c5e833
7
+ data.tar.gz: 278a3e88e3429d000688a334dc83202af4d084601ceee911d3a8a4e17e1a53ae4eab370b39f2722ffdb28947e2f01bb7e4724adf0ee7c2cb98949b2770c4f12f
@@ -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
@@ -15,3 +15,4 @@ mkmf.log
15
15
 
16
16
  *.iml
17
17
  .idea
18
+ .ruby-*
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # simplecov-cobertura
2
- [![Build](https://github.com/dashingrocket/simplecov-cobertura/actions/workflows/build.yml/badge.svg)](https://github.com/dashingrocket/simplecov-cobertura/actions/workflows/build.yml) [![Gem Version](https://badge.fury.io/rb/simplecov-cobertura.svg)](http://badge.fury.io/rb/simplecov-cobertura) [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/simplecov-cobertura?type=total)](https://rubygems.org/gems/simplecov-cobertura)
2
+ [![Build](https://github.com/jessebs/simplecov-cobertura/actions/workflows/build.yml/badge.svg)](https://github.com/jessebs/simplecov-cobertura/actions/workflows/build.yml) [![Gem Version](https://badge.fury.io/rb/simplecov-cobertura.svg)](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/dashingrocket/simplecov-cobertura/fork )
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 2021 Dashing Rocket, Ltd.
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.
@@ -1,7 +1,7 @@
1
1
  module SimpleCov
2
2
  module Formatter
3
3
  class CoberturaFormatter
4
- VERSION = '2.1.0'
4
+ VERSION = '3.0.0'
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,3 @@
1
- require 'simplecov'
2
-
3
1
  require 'rexml/document'
4
2
  require 'rexml/element'
5
3
  require 'pathname'
@@ -27,7 +25,8 @@ module SimpleCov
27
25
 
28
26
  xml_str = string_io.string
29
27
  File.write(result_path, xml_str)
30
- puts "Coverage report generated for #{result.command_name} to #{result_path}. #{coverage_output(result)}"
28
+ puts output_message(result, result_path)
29
+
31
30
  xml_str
32
31
  end
33
32
 
@@ -117,7 +116,7 @@ module SimpleCov
117
116
  bs = file.coverage_statistics[:branch]
118
117
 
119
118
  filename = file.filename
120
- class_.attributes['name'] = File.basename(filename, '.*')
119
+ class_.attributes['name'] = resolve_filename(filename)
121
120
  class_.attributes['filename'] = resolve_filename(filename)
122
121
  class_.attributes['line-rate'] = extract_rate(ls.percent)
123
122
  if SimpleCov.branch_coverage?
@@ -144,20 +143,17 @@ module SimpleCov
144
143
  def set_xml_head(lines=[])
145
144
  lines << "<?xml version=\"1.0\"?>"
146
145
  lines << "<!DOCTYPE coverage SYSTEM \"#{DTD_URL}\">"
147
- lines << "<!-- Generated by simplecov-cobertura version #{VERSION} (https://github.com/dashingrocket/simplecov-cobertura) -->"
146
+ lines << "<!-- Generated by simplecov-cobertura version #{VERSION} (https://github.com/jessebs/simplecov-cobertura) -->"
148
147
  lines.join("\n")
149
148
  end
150
149
 
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
150
+ # Roughly mirrors private method SimpleCov::Formatter::HTMLFormatter#output_coverage
151
+ def output_message(result, output_path)
152
+ output = "Coverage report generated for #{result.command_name} to #{output_path}."
153
+ output += "\nLine Coverage: #{result.covered_percent.round(2)}% (#{result.covered_lines} / #{result.total_lines})"
154
+ output += "\nBranch Coverage: #{result.coverage_statistics[:branch].percent.round(2)}% (#{result.covered_branches} / #{result.total_branches})" if SimpleCov.branch_coverage?
155
+ output
156
+ end
161
157
 
162
158
  def resolve_filename(filename)
163
159
  Pathname.new(filename).relative_path_from(project_root).to_s
@@ -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 = ['jbowes@dashingrocket.com']
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/dashingrocket/simplecov-cobertura'
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
 
@@ -45,16 +45,20 @@ class CoberturaFormatterTest < Test::Unit::TestCase
45
45
  def test_terminal_output
46
46
  output, _ = capture_output { @formatter.format(@result) }
47
47
  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}. (.*) covered./
48
+ output_regex = /Coverage report generated for #{@result.command_name} to #{result_path}.\nLine Coverage: (.*)\nBranch Coverage: (.*)/
49
49
  assert_match(output_regex, output)
50
50
  end
51
51
 
52
- def test_format_dtd_validates
53
- xml = @formatter.format(@result)
54
- options = Nokogiri::XML::ParseOptions::DTDLOAD
55
- doc = Nokogiri::XML::Document.parse(xml, nil, nil, options)
56
- assert_empty doc.external_subset.validate(doc)
57
- end
52
+ # Rather than support HTTPS the HTTP client was removed from libxml2 / xmllint:
53
+ # https://gitlab.gnome.org/GNOME/libxml2/-/issues/160
54
+ # I am not sure what this means for Nokogiri or this issue, but it certainly means something will change soon.
55
+ # Disable this test until it becomes clear what the new behavior should be.
56
+ # def test_format_dtd_validates
57
+ # xml = @formatter.format(@result)
58
+ # options = Nokogiri::XML::ParseOptions::DTDLOAD
59
+ # doc = Nokogiri::XML::Document.parse(xml, nil, nil, options)
60
+ # assert_empty doc.external_subset.validate(doc)
61
+ # end
58
62
 
59
63
  def test_no_groups
60
64
  xml = @formatter.format(@result)
@@ -86,7 +90,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
86
90
  classes = doc.xpath '/coverage/packages/package/classes/class'
87
91
  assert_equal 1, classes.length
88
92
  clazz = classes.first
89
- assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
93
+ assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('name').value
90
94
  assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
91
95
  assert_equal '0.86', clazz.attribute('line-rate').value
92
96
  assert_equal '0.5', clazz.attribute('branch-rate').value
@@ -136,7 +140,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
136
140
  classes = doc.xpath '/coverage/packages/package/classes/class'
137
141
  assert_equal 1, classes.length
138
142
  clazz = classes.first
139
- assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
143
+ assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('name').value
140
144
  assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
141
145
  assert_equal '0.86', clazz.attribute('line-rate').value
142
146
  assert_equal '0.5', clazz.attribute('branch-rate').value
@@ -165,7 +169,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
165
169
  classes = doc.xpath '/coverage/packages/package/classes/class'
166
170
  assert_equal 1, classes.length
167
171
  clazz = classes.first
168
- assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
172
+ assert_equal "../#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('name').value
169
173
  assert_equal "../#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
170
174
  ensure
171
175
  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: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Bowes
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-12-14 00:00:00.000000000 Z
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
- - jbowes@dashingrocket.com
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/dashingrocket/simplecov-cobertura
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.2.22
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
@@ -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>