simplecov-cobertura 2.0.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: ce7b99ac8380e1a484798858b4b10aecd158c7287b94db50cff33e498bd89239
4
- data.tar.gz: b014a903090c15eb923fe7056c5d53a4fa8fd447726f26fa4b705bb3e72010db
3
+ metadata.gz: 7f4e823da3eaf503a2ba1f94202b474e87e1461864d60df99fbef33f55b877d2
4
+ data.tar.gz: 21969345160bc14566b87f3d457f89bb0b27b9f9cc4607cd5a1b7bd658d7b176
5
5
  SHA512:
6
- metadata.gz: 3902717d69048539f0b1ffc2a4bcab3df384976745ffdafb308d3242232ca588f09aa6c7c954c6719a8899666038248caa208b279608fb4d063ead92019b03c1
7
- data.tar.gz: e2170d9b3ceb19976b091a3519965ddd3ad4b88aa85519c67802edd27a3f18ddfcafa27471caf516d6088a95d2aba0941157b6cb10ff7a2710910cc4ee8256e9
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.0.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'
@@ -12,9 +10,13 @@ module SimpleCov
12
10
  RESULT_FILE_NAME = 'coverage.xml'
13
11
  DTD_URL = 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'
14
12
 
13
+ def initialize(result_file_name: RESULT_FILE_NAME)
14
+ @result_file_name = result_file_name
15
+ end
16
+
15
17
  def format(result)
16
18
  xml_doc = result_to_xml result
17
- result_path = File.join(SimpleCov.coverage_path, RESULT_FILE_NAME)
19
+ result_path = File.join(SimpleCov.coverage_path, @result_file_name)
18
20
 
19
21
  formatter = REXML::Formatters::Pretty.new
20
22
  formatter.compact = true
@@ -23,7 +25,8 @@ module SimpleCov
23
25
 
24
26
  xml_str = string_io.string
25
27
  File.write(result_path, xml_str)
26
- puts "Coverage report generated for #{result.command_name} to #{result_path}. #{coverage_output(result)}"
28
+ puts output_message(result, result_path)
29
+
27
30
  xml_str
28
31
  end
29
32
 
@@ -113,7 +116,7 @@ module SimpleCov
113
116
  bs = file.coverage_statistics[:branch]
114
117
 
115
118
  filename = file.filename
116
- class_.attributes['name'] = File.basename(filename, '.*')
119
+ class_.attributes['name'] = resolve_filename(filename)
117
120
  class_.attributes['filename'] = resolve_filename(filename)
118
121
  class_.attributes['line-rate'] = extract_rate(ls.percent)
119
122
  if SimpleCov.branch_coverage?
@@ -140,20 +143,17 @@ module SimpleCov
140
143
  def set_xml_head(lines=[])
141
144
  lines << "<?xml version=\"1.0\"?>"
142
145
  lines << "<!DOCTYPE coverage SYSTEM \"#{DTD_URL}\">"
143
- 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) -->"
144
147
  lines.join("\n")
145
148
  end
146
149
 
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
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
157
157
 
158
158
  def resolve_filename(filename)
159
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
 
@@ -35,19 +35,30 @@ class CoberturaFormatterTest < Test::Unit::TestCase
35
35
  assert_equal(xml, IO.read(result_path))
36
36
  end
37
37
 
38
+ def test_format_save_custom_filename
39
+ xml = SimpleCov::Formatter::CoberturaFormatter.new(result_file_name: 'cobertura.xml').format(@result)
40
+ result_path = File.join(SimpleCov.coverage_path, 'cobertura.xml')
41
+ assert_not_empty(xml)
42
+ assert_equal(xml, IO.read(result_path))
43
+ end
44
+
38
45
  def test_terminal_output
39
46
  output, _ = capture_output { @formatter.format(@result) }
40
47
  result_path = File.join(SimpleCov.coverage_path, SimpleCov::Formatter::CoberturaFormatter::RESULT_FILE_NAME)
41
- 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: (.*)/
42
49
  assert_match(output_regex, output)
43
50
  end
44
51
 
45
- def test_format_dtd_validates
46
- xml = @formatter.format(@result)
47
- options = Nokogiri::XML::ParseOptions::DTDLOAD
48
- doc = Nokogiri::XML::Document.parse(xml, nil, nil, options)
49
- assert_empty doc.external_subset.validate(doc)
50
- 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
51
62
 
52
63
  def test_no_groups
53
64
  xml = @formatter.format(@result)
@@ -79,7 +90,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
79
90
  classes = doc.xpath '/coverage/packages/package/classes/class'
80
91
  assert_equal 1, classes.length
81
92
  clazz = classes.first
82
- assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
93
+ assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('name').value
83
94
  assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
84
95
  assert_equal '0.86', clazz.attribute('line-rate').value
85
96
  assert_equal '0.5', clazz.attribute('branch-rate').value
@@ -129,7 +140,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
129
140
  classes = doc.xpath '/coverage/packages/package/classes/class'
130
141
  assert_equal 1, classes.length
131
142
  clazz = classes.first
132
- assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
143
+ assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('name').value
133
144
  assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
134
145
  assert_equal '0.86', clazz.attribute('line-rate').value
135
146
  assert_equal '0.5', clazz.attribute('branch-rate').value
@@ -158,7 +169,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
158
169
  classes = doc.xpath '/coverage/packages/package/classes/class'
159
170
  assert_equal 1, classes.length
160
171
  clazz = classes.first
161
- assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
172
+ assert_equal "../#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('name').value
162
173
  assert_equal "../#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
163
174
  ensure
164
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.0.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-11-24 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,14 +81,13 @@ 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: []
89
88
  files:
90
89
  - ".github/workflows/build.yml"
91
90
  - ".gitignore"
92
- - ".ruby-version"
93
91
  - Gemfile
94
92
  - LICENSE
95
93
  - README.md
@@ -97,13 +95,11 @@ files:
97
95
  - lib/simplecov-cobertura.rb
98
96
  - lib/simplecov-cobertura/version.rb
99
97
  - simplecov-cobertura.gemspec
100
- - test/coverage/coverage.xml
101
98
  - test/simplecov-cobertura_test.rb
102
- homepage: https://github.com/dashingrocket/simplecov-cobertura
99
+ homepage: https://github.com/jessebs/simplecov-cobertura
103
100
  licenses:
104
101
  - Apache-2.0
105
102
  metadata: {}
106
- post_install_message:
107
103
  rdoc_options: []
108
104
  require_paths:
109
105
  - lib
@@ -118,10 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
114
  - !ruby/object:Gem::Version
119
115
  version: '0'
120
116
  requirements: []
121
- rubygems_version: 3.1.6
122
- signing_key:
117
+ rubygems_version: 3.6.7
123
118
  specification_version: 4
124
119
  summary: SimpleCov Cobertura Formatter
125
120
  test_files:
126
- - test/coverage/coverage.xml
127
121
  - test/simplecov-cobertura_test.rb
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.0.2
@@ -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>