simplecov-cobertura 1.4.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17f485d57f75e4ffb86132662c75714f039b493fb03cab4fa1875fe1dd01fd32
4
- data.tar.gz: 5d6b51cfcc1bbe0dec7f8ac0a9a051c9e67064b185b280725bc101667f42ebd7
3
+ metadata.gz: ce7b99ac8380e1a484798858b4b10aecd158c7287b94db50cff33e498bd89239
4
+ data.tar.gz: b014a903090c15eb923fe7056c5d53a4fa8fd447726f26fa4b705bb3e72010db
5
5
  SHA512:
6
- metadata.gz: 996338e8d5fb7ea79e3f912e8734e0ae0795ff3ffe41bf1e00ef722f4ff50b423d8a2e95d3bf7e7cfd18179785d5dcd5bdb4318ed5f91bb912b10341c5b91d78
7
- data.tar.gz: 98adbf973e7c454ac7645556cbf1e83b3c50b9071523e5c536fbdad86f53eb48afbdbcde6212f9e699a692bce226a19b094a0e8823348f2fc0a49f4032150c24
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
@@ -14,4 +14,4 @@
14
14
  mkmf.log
15
15
 
16
16
  *.iml
17
- .idea
17
+ .idea
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.2
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # simplecov-cobertura
2
- [![Build Status](https://travis-ci.com/dashingrocket/simplecov-cobertura.svg?branch=master)](https://travis-ci.com/dashingrocket/simplecov-cobertura) [![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/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)
3
+
3
4
 
4
5
  Produces [Cobertura](http://cobertura.sourceforge.net/) formatted XML from [SimpleCov](https://github.com/colszowka/simplecov).
5
6
 
@@ -32,29 +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
- * Magnus Bergmark
57
- * Peter Leitzen
58
40
 
59
41
  ## Contributing
60
42
 
@@ -65,7 +47,7 @@ Tested in a CI environment against the following Ruby versions:
65
47
  5. Create a new Pull Request
66
48
 
67
49
  ## License
68
- Copyright 2020 Dashing Rocket, Ltd.
50
+ Copyright 2021 Dashing Rocket, Ltd.
69
51
 
70
52
  Licensed under the Apache License, Version 2.0 (the "License");
71
53
  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 = '1.4.2'
4
+ VERSION = '2.0.0'
5
5
  end
6
6
  end
7
7
  end
@@ -28,104 +28,144 @@ module SimpleCov
28
28
  end
29
29
 
30
30
  private
31
- def result_to_xml(result)
32
- doc = REXML::Document.new set_xml_head
33
- doc.context[:attribute_quote] = :quote
34
- doc.add_element REXML::Element.new('coverage')
35
- coverage = doc.root
36
31
 
37
- set_coverage_attributes(coverage, result)
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
38
37
 
39
- coverage.add_element(sources = REXML::Element.new('sources'))
40
- sources.add_element(source = REXML::Element.new('source'))
41
- source.text = SimpleCov.root
38
+ set_coverage_attributes(coverage, result)
42
39
 
43
- coverage.add_element(packages = REXML::Element.new('packages'))
40
+ coverage.add_element(sources = REXML::Element.new('sources'))
41
+ sources.add_element(source = REXML::Element.new('source'))
42
+ source.text = SimpleCov.root
44
43
 
45
- if result.groups.empty?
46
- groups = {File.basename(SimpleCov.root) => result.files}
47
- else
48
- groups = result.groups
49
- end
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
50
51
 
51
- groups.map do |name, files|
52
- packages.add_element(package = REXML::Element.new('package'))
53
- set_package_attributes(package, name, files)
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)
54
56
 
55
- package.add_element(classes = REXML::Element.new('classes'))
57
+ package.add_element(classes = REXML::Element.new('classes'))
56
58
 
57
- files.each do |file|
58
- classes.add_element(class_ = REXML::Element.new('class'))
59
- set_class_attributes(class_, file)
59
+ files.each do |file|
60
+ classes.add_element(class_ = REXML::Element.new('class'))
61
+ set_class_attributes(class_, file)
60
62
 
61
- class_.add_element(REXML::Element.new('methods'))
62
- class_.add_element(lines = REXML::Element.new('lines'))
63
+ class_.add_element(REXML::Element.new('methods'))
64
+ class_.add_element(lines = REXML::Element.new('lines'))
63
65
 
64
- file.lines.each do |file_line|
65
- if file_line.covered? || file_line.missed?
66
- lines.add_element(line = REXML::Element.new('line'))
67
- set_line_attributes(line, file_line)
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
68
75
  end
69
76
  end
70
77
  end
78
+
79
+ doc
71
80
  end
72
81
 
73
- doc
74
- end
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
75
98
 
76
- def set_coverage_attributes(coverage, result)
77
- coverage.attributes['line-rate'] = (result.covered_percent/100).round(2).to_s
78
- coverage.attributes['branch-rate'] = '0'
79
- coverage.attributes['lines-covered'] = result.covered_lines.to_s
80
- coverage.attributes['lines-valid'] = (result.covered_lines + result.missed_lines).to_s
81
- coverage.attributes['branches-covered'] = '0'
82
- coverage.attributes['branches-valid'] = '0'
83
- coverage.attributes['branch-rate'] = '0'
84
- coverage.attributes['complexity'] = '0'
85
- coverage.attributes['version'] = '0'
86
- coverage.attributes['timestamp'] = Time.now.to_i.to_s
87
- end
99
+ def set_package_attributes(package, name, result)
100
+ ls = result.coverage_statistics[:line]
101
+ bs = result.coverage_statistics[:branch]
88
102
 
89
- def set_package_attributes(package, name, result)
90
- package.attributes['name'] = name
91
- package.attributes['line-rate'] = (result.covered_percent/100).round(2).to_s
92
- package.attributes['branch-rate'] = '0'
93
- package.attributes['complexity'] = '0'
94
- end
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
95
110
 
96
- def set_class_attributes(class_, file)
97
- filename = file.filename
98
- class_.attributes['name'] = File.basename(filename, '.*')
99
- class_.attributes['filename'] = resolve_filename(filename)
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
- def set_line_attributes(line, file_line)
106
- line.attributes['number'] = file_line.line_number.to_s
107
- line.attributes['branch'] = 'false'
108
- line.attributes['hits'] = file_line.coverage.to_s
109
- end
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
- def set_xml_head(lines=[])
112
- lines << "<?xml version=\"1.0\"?>"
113
- lines << "<!DOCTYPE coverage SYSTEM \"#{DTD_URL}\">"
114
- lines << "<!-- Generated by simplecov-cobertura version #{VERSION} (https://github.com/dashingrocket/simplecov-cobertura) -->"
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
- def coverage_output(result)
119
- "#{result.covered_lines} / #{result.covered_lines + result.missed_lines} LOC (#{result.covered_percent.round(2)}%) covered."
120
- end
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
121
139
 
122
- def resolve_filename(filename)
123
- Pathname.new(filename).relative_path_from(project_root).to_s
124
- end
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
125
146
 
126
- def project_root
127
- @project_root ||= Pathname.new(SimpleCov.root)
128
- end
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
129
169
  end
130
170
  end
131
171
  end
@@ -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 = '>= 1.9.3'
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.8'
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,14 +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
8
  def setup
11
- @result = SimpleCov::Result.new({ "#{__FILE__}" => [1,2] })
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
+ })
12
24
  @formatter = SimpleCov::Formatter::CoberturaFormatter.new
13
25
  end
14
26
 
@@ -42,12 +54,12 @@ class CoberturaFormatterTest < Test::Unit::TestCase
42
54
  doc = Nokogiri::XML::Document.parse(xml)
43
55
 
44
56
  coverage = doc.xpath '/coverage'
45
- assert_equal '1.0', coverage.attribute('line-rate').value
46
- assert_equal '0', coverage.attribute('branch-rate').value
47
- assert_equal '2', coverage.attribute('lines-covered').value
48
- assert_equal '2', coverage.attribute('lines-valid').value
49
- assert_equal '0', coverage.attribute('branches-covered').value
50
- assert_equal '0', coverage.attribute('branches-valid').value
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
51
63
  assert_equal '0', coverage.attribute('complexity').value
52
64
  assert_equal '0', coverage.attribute('version').value
53
65
  assert_not_empty coverage.attribute('timestamp').value
@@ -60,8 +72,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
60
72
  assert_equal 1, packages.length
61
73
  package = packages.first
62
74
  assert_equal 'simplecov-cobertura', package.attribute('name').value
63
- assert_equal '1.0', package.attribute('line-rate').value
64
- 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
65
77
  assert_equal '0', package.attribute('complexity').value
66
78
 
67
79
  classes = doc.xpath '/coverage/packages/package/classes/class'
@@ -69,20 +81,20 @@ class CoberturaFormatterTest < Test::Unit::TestCase
69
81
  clazz = classes.first
70
82
  assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
71
83
  assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
72
- assert_equal '1.0', clazz.attribute('line-rate').value
73
- 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
74
86
  assert_equal '0', clazz.attribute('complexity').value
75
87
 
76
88
  lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
77
- assert_equal 2, lines.length
89
+ assert_equal 7, lines.length
78
90
  first_line = lines.first
79
91
  assert_equal '1', first_line.attribute('number').value
80
92
  assert_equal 'false', first_line.attribute('branch').value
81
93
  assert_equal '1', first_line.attribute('hits').value
82
94
  last_line = lines.last
83
- assert_equal '2', last_line.attribute('number').value
84
- assert_equal 'false', last_line.attribute('branch').value
85
- assert_equal '2', last_line.attribute('hits').value
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
86
98
  end
87
99
 
88
100
  def test_groups
@@ -92,12 +104,12 @@ class CoberturaFormatterTest < Test::Unit::TestCase
92
104
  doc = Nokogiri::XML::Document.parse(xml)
93
105
 
94
106
  coverage = doc.xpath '/coverage'
95
- assert_equal '1.0', coverage.attribute('line-rate').value
96
- assert_equal '0', coverage.attribute('branch-rate').value
97
- assert_equal '2', coverage.attribute('lines-covered').value
98
- assert_equal '2', coverage.attribute('lines-valid').value
99
- assert_equal '0', coverage.attribute('branches-covered').value
100
- assert_equal '0', coverage.attribute('branches-valid').value
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
101
113
  assert_equal '0', coverage.attribute('complexity').value
102
114
  assert_equal '0', coverage.attribute('version').value
103
115
  assert_not_empty coverage.attribute('timestamp').value
@@ -110,8 +122,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
110
122
  assert_equal 1, packages.length
111
123
  package = packages.first
112
124
  assert_equal 'test_group', package.attribute('name').value
113
- assert_equal '1.0', package.attribute('line-rate').value
114
- 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
115
127
  assert_equal '0', package.attribute('complexity').value
116
128
 
117
129
  classes = doc.xpath '/coverage/packages/package/classes/class'
@@ -119,25 +131,25 @@ class CoberturaFormatterTest < Test::Unit::TestCase
119
131
  clazz = classes.first
120
132
  assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
121
133
  assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
122
- assert_equal '1.0', clazz.attribute('line-rate').value
123
- 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
124
136
  assert_equal '0', clazz.attribute('complexity').value
125
137
 
126
138
  lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
127
- assert_equal 2, lines.length
139
+ assert_equal 7, lines.length
128
140
  first_line = lines.first
129
141
  assert_equal '1', first_line.attribute('number').value
130
142
  assert_equal 'false', first_line.attribute('branch').value
131
143
  assert_equal '1', first_line.attribute('hits').value
132
144
  last_line = lines.last
133
- assert_equal '2', last_line.attribute('number').value
134
- assert_equal 'false', last_line.attribute('branch').value
135
- assert_equal '2', last_line.attribute('hits').value
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
136
148
  end
137
149
 
138
150
  def test_supports_root_project_path
139
151
  old_root = SimpleCov.root
140
- SimpleCov.root('/')
152
+ SimpleCov.root("/tmp")
141
153
  expected_base = old_root[1..-1] # Remove leading "/"
142
154
 
143
155
  xml = @formatter.format(@result)
@@ -147,7 +159,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
147
159
  assert_equal 1, classes.length
148
160
  clazz = classes.first
149
161
  assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
150
- assert_equal "#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
162
+ assert_equal "../#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
151
163
  ensure
152
164
  SimpleCov.root(old_root)
153
165
  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: 1.4.2
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: 2020-11-19 00:00:00.000000000 Z
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: simplecov
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.8'
48
- type: :runtime
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.8'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '13.0'
62
- type: :development
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: '13.0'
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
- - ".travis.yml"
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: 1.9.3
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.2
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
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
-
4
- rvm:
5
- - 2.7
6
- - 2.6
7
- - 2.5
8
- - 2.4
9
- - 2.3
10
- - 2.2
11
- - 2.1
12
- - 2.0
13
- - 1.9