simplecov-cobertura 1.1.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZGUzMWJmNmI4YTIyN2NhYTVkNzM2YTczY2EyMjJmZGIyZjZkODVmMQ==
5
- data.tar.gz: !binary |-
6
- ODhhYzkyNWI4MWFiMDc4ZWMwNzM4NTU0ZmMzOTFkNTRjNzg3NjE4Mg==
2
+ SHA256:
3
+ metadata.gz: e4a11c2c152ba855cb63e6df239c4a184bda9da9a2ead876fbc27d39e66b7f77
4
+ data.tar.gz: 74a55b1d64b191ac6fc09c0fd5850bf3808515deb0a854a26c1227f979350d21
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- N2VjNmVlN2UzZmZhOWViZDEzMGI1ZjkyYjc3YzdhYzQ0NGMyYzdkMGU2Yzg4
10
- Njk4MzE3OWRmMTIxNTIxYjE2N2ZkNmMyNjZjOTM3OGQwNGU5MDA2NWIxNmQw
11
- YWYyOTc5M2E0YzRlNWZmMjNmNmMzYjE0ZWNjYzZjZDVlNjY0OTQ=
12
- data.tar.gz: !binary |-
13
- OTQ4NDcxZmViMDAyMzhkOTBiODBjMGMxMDM1NzI2NDE4NWYyOTk1M2FkMzZj
14
- OTIwMDJhZWYyYmVjNjA2MWE2YTUzMGI0MmRlYmRmN2YxODJiMzQwOTQzOGY4
15
- OTFiNzkwZWQ3MjU4YWFlZjA5MTVkNzhmYjRiYjZjN2Q5NWVlODE=
6
+ metadata.gz: 9875b3bd65b54edccde1c463a2fc60ba72d5b43096a4b0a83b2daa2ed62396b1ef21b13609aa2a0ed4ecbe2cb1c895be022b09deb6e614f4b050b62cac920ea9
7
+ data.tar.gz: 1d3cd10afc26cb1a5564b7c7d570bb38b940a2609945d40009fba9f15de9c10be86cd3ed86bbcc9fafcb3d42bfbeb3299db2fa7928f9ee3e8b9e3d9d3a6c311a
@@ -0,0 +1,13 @@
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
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # simplecov-cobertura
2
- [![Build Status](https://api.shippable.com/projects/549b1fbbd46935d5fbc0f9f3/badge?branchName=master)](https://app.shippable.com/projects/549b1fbbd46935d5fbc0f9f3/builds/latest) [![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 Status](https://travis-ci.org/dashingrocket/simplecov-cobertura.svg?branch=master)](https://travis-ci.org/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)
3
3
 
4
4
  Produces [Cobertura](http://cobertura.sourceforge.net/) formatted XML from [SimpleCov](https://github.com/colszowka/simplecov).
5
5
 
@@ -32,13 +32,15 @@ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
32
32
 
33
33
  ## Continuous Integration
34
34
  Tested in a CI environment against the following Ruby versions:
35
- * ruby-head
35
+ * 2.7
36
+ * 2.6
37
+ * 2.5
38
+ * 2.4
36
39
  * 2.3
37
40
  * 2.2
38
41
  * 2.1
39
- * 2.0.0
42
+ * 2.0
40
43
  * 1.9
41
- * JRuby (1.9 mode)
42
44
 
43
45
  ## Known Limitations
44
46
  * No support for branch coverage
@@ -47,6 +49,10 @@ Tested in a CI environment against the following Ruby versions:
47
49
  * Jesse Bowes
48
50
  * Sean Clemmer
49
51
  * Ivailo Petrov
52
+ * Rob Lester
53
+ * Denis <Zaratan> Pasin
54
+ * Jesper Rønn-Jensen
55
+ * Pramod Shinde
50
56
 
51
57
  ## Contributing
52
58
 
@@ -57,7 +63,7 @@ Tested in a CI environment against the following Ruby versions:
57
63
  5. Create a new Pull Request
58
64
 
59
65
  ## License
60
- Copyright 2016 Dashing Rocket, Ltd.
66
+ Copyright 2020 Dashing Rocket, Ltd.
61
67
 
62
68
  Licensed under the Apache License, Version 2.0 (the "License");
63
69
  you may not use this file except in compliance with the License.
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
- require 'ci/reporter/rake/test_unit'
4
3
 
5
4
  Rake::TestTask.new do |t|
6
5
  t.libs << 'test'
@@ -8,4 +7,4 @@ Rake::TestTask.new do |t|
8
7
  end
9
8
 
10
9
  desc 'Run tests'
11
- task :default => ['ci:setup:testunit', :test]
10
+ task :default => [:test]
@@ -1,11 +1,14 @@
1
+ require 'simplecov'
2
+
1
3
  require 'rexml/document'
2
4
  require 'rexml/element'
5
+ require 'pathname'
6
+
7
+ require_relative 'simplecov-cobertura/version'
3
8
 
4
9
  module SimpleCov
5
10
  module Formatter
6
11
  class CoberturaFormatter
7
- VERSION = '1.1.0'
8
-
9
12
  RESULT_FILE_NAME = 'coverage.xml'
10
13
  DTD_URL = 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'
11
14
 
@@ -20,13 +23,14 @@ module SimpleCov
20
23
 
21
24
  xml_str = string_io.string
22
25
  File.write(result_path, xml_str)
23
- puts "Coverage report generated for #{result.command_name} to #{result_path}"
26
+ puts "Coverage report generated for #{result.command_name} to #{result_path}. #{coverage_output(result)}"
24
27
  xml_str
25
28
  end
26
29
 
27
30
  private
28
31
  def result_to_xml(result)
29
32
  doc = REXML::Document.new set_xml_head
33
+ doc.context[:attribute_quote] = :quote
30
34
  doc.add_element REXML::Element.new('coverage')
31
35
  coverage = doc.root
32
36
 
@@ -91,9 +95,8 @@ module SimpleCov
91
95
 
92
96
  def set_class_attributes(class_, file)
93
97
  filename = file.filename
94
- path = filename[SimpleCov.root.length+1..-1]
95
98
  class_.attributes['name'] = File.basename(filename, '.*')
96
- class_.attributes['filename'] = path
99
+ class_.attributes['filename'] = resolve_filename(filename)
97
100
  class_.attributes['line-rate'] = (file.covered_percent/100).round(2).to_s
98
101
  class_.attributes['branch-rate'] = '0'
99
102
  class_.attributes['complexity'] = '0'
@@ -106,11 +109,23 @@ module SimpleCov
106
109
  end
107
110
 
108
111
  def set_xml_head(lines=[])
112
+ lines << "<?xml version=\"1.0\"?>"
109
113
  lines << "<!DOCTYPE coverage SYSTEM \"#{DTD_URL}\">"
110
114
  lines << "<!-- Generated by simplecov-cobertura version #{VERSION} (https://github.com/dashingrocket/simplecov-cobertura) -->"
111
115
  lines.join("\n")
112
116
  end
117
+
118
+ def coverage_output(result)
119
+ "#{result.covered_lines} / #{result.covered_lines + result.missed_lines} LOC (#{result.covered_percent.round(2)}%) covered."
120
+ end
121
+
122
+ def resolve_filename(filename)
123
+ Pathname.new(filename).relative_path_from(project_root).to_s
124
+ end
125
+
126
+ def project_root
127
+ @project_root ||= Pathname.new(SimpleCov.root)
128
+ end
113
129
  end
114
130
  end
115
131
  end
116
-
@@ -0,0 +1,7 @@
1
+ module SimpleCov
2
+ module Formatter
3
+ class CoberturaFormatter
4
+ VERSION = '1.4.1'
5
+ end
6
+ end
7
+ end
@@ -2,7 +2,7 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
- require 'simplecov-cobertura'
5
+ require 'simplecov-cobertura/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'simplecov-cobertura'
@@ -20,10 +20,17 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_development_dependency 'bundler', '~> 1.7'
24
- spec.add_development_dependency 'rake', '~> 10.0'
25
- spec.add_development_dependency 'ci_reporter_test_unit', '~> 1.0'
26
- spec.add_development_dependency 'nokogiri', '~> 1.6'
23
+ spec.add_development_dependency 'test-unit', '~> 3.2'
24
+ spec.add_development_dependency 'nokogiri', '~> 1.0'
27
25
 
28
- spec.add_runtime_dependency 'simplecov', '~> 0.8'
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
29
36
  end
@@ -24,6 +24,13 @@ class CoberturaFormatterTest < Test::Unit::TestCase
24
24
  assert_equal(xml, IO.read(result_path))
25
25
  end
26
26
 
27
+ def test_terminal_output
28
+ output, _ = capture_output { @formatter.format(@result) }
29
+ result_path = File.join(SimpleCov.coverage_path, SimpleCov::Formatter::CoberturaFormatter::RESULT_FILE_NAME)
30
+ output_regex = /Coverage report generated for #{@result.command_name} to #{result_path}. (.*) covered./
31
+ assert_match(output_regex, output)
32
+ end
33
+
27
34
  def test_format_dtd_validates
28
35
  xml = @formatter.format(@result)
29
36
  options = Nokogiri::XML::ParseOptions::DTDLOAD
@@ -128,4 +135,21 @@ class CoberturaFormatterTest < Test::Unit::TestCase
128
135
  assert_equal 'false', last_line.attribute('branch').value
129
136
  assert_equal '2', last_line.attribute('hits').value
130
137
  end
131
- end
138
+
139
+ def test_supports_root_project_path
140
+ old_root = SimpleCov.root
141
+ SimpleCov.root('/')
142
+ expected_base = old_root[1..-1] # Remove leading "/"
143
+
144
+ xml = @formatter.format(@result)
145
+ doc = Nokogiri::XML::Document.parse(xml)
146
+
147
+ classes = doc.xpath '/coverage/packages/package/classes/class'
148
+ assert_equal 1, classes.length
149
+ clazz = classes.first
150
+ assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
151
+ assert_equal "#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
152
+ ensure
153
+ SimpleCov.root(old_root)
154
+ end
155
+ end
metadata CHANGED
@@ -1,85 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov-cobertura
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Bowes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-26 00:00:00.000000000 Z
11
+ date: 2020-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: test-unit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '3.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: ci_reporter_test_unit
28
+ name: nokogiri
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ~>
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
33
  version: '1.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ~>
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
40
  version: '1.0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: nokogiri
42
+ name: simplecov
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ~>
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1.6'
62
- type: :development
47
+ version: '0.8'
48
+ type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ~>
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '1.6'
54
+ version: '0.8'
69
55
  - !ruby/object:Gem::Dependency
70
- name: simplecov
56
+ name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - ~>
59
+ - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '0.8'
76
- type: :runtime
61
+ version: '13.0'
62
+ type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ~>
66
+ - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '0.8'
68
+ version: '13.0'
83
69
  description: Produces Cobertura XML formatted output from SimpleCov
84
70
  email:
85
71
  - jbowes@dashingrocket.com
@@ -87,37 +73,37 @@ executables: []
87
73
  extensions: []
88
74
  extra_rdoc_files: []
89
75
  files:
90
- - .gitignore
76
+ - ".gitignore"
77
+ - ".travis.yml"
91
78
  - Gemfile
92
79
  - LICENSE
93
80
  - README.md
94
81
  - Rakefile
95
82
  - lib/simplecov-cobertura.rb
96
- - shippable.yml
83
+ - lib/simplecov-cobertura/version.rb
97
84
  - simplecov-cobertura.gemspec
98
85
  - test/simplecov-cobertura_test.rb
99
86
  homepage: https://github.com/dashingrocket/simplecov-cobertura
100
87
  licenses:
101
88
  - Apache-2.0
102
89
  metadata: {}
103
- post_install_message:
90
+ post_install_message:
104
91
  rdoc_options: []
105
92
  require_paths:
106
93
  - lib
107
94
  required_ruby_version: !ruby/object:Gem::Requirement
108
95
  requirements:
109
- - - ! '>='
96
+ - - ">="
110
97
  - !ruby/object:Gem::Version
111
98
  version: 1.9.3
112
99
  required_rubygems_version: !ruby/object:Gem::Requirement
113
100
  requirements:
114
- - - ! '>='
101
+ - - ">="
115
102
  - !ruby/object:Gem::Version
116
103
  version: '0'
117
104
  requirements: []
118
- rubyforge_project:
119
- rubygems_version: 2.4.6
120
- signing_key:
105
+ rubygems_version: 3.1.2
106
+ signing_key:
121
107
  specification_version: 4
122
108
  summary: SimpleCov Cobertura Formatter
123
109
  test_files:
@@ -1,22 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - ruby-head
5
- - 2.3.0
6
- - 2.2.0
7
- - 2.1.5
8
- - 2.0.0
9
- - 1.9.3
10
- - jruby-19mode
11
-
12
- env:
13
- - CI_REPORTS=shippable/testresults COVERAGE_REPORTS=shippable/codecoverage
14
-
15
- cache: true
16
-
17
- notifications:
18
- email:
19
- recipients:
20
- - jbowes@dashingrocket.com
21
- on_success: change
22
- on_failure: always