simplecov-cobertura 1.0.4 → 1.1.0.beta.1
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 +8 -8
- data/README.md +2 -5
- data/lib/simplecov-cobertura.rb +24 -15
- data/test/simplecov-cobertura_test.rb +99 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTE5YzQ2MDY0YjBjNmU3Zjg4MDQ1ZDgzYjM5NTk2M2E5NjFlNjBiYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmE3ODhiZjMzODg2NGM2N2Y1MjA3YzM1ZjIzYzliMmYyYzFjMmQzNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDI1YmJkNWQ5OGU4ZDMwMjExMmUxOWViNzZiODIxNGQxOTBkN2Y0NGQ0ZjNh
|
10
|
+
OGRiOGQ5OWVkMDhlMzFkZDczZDlmNTMwZDk0MDY0MGY1NjFjNzNkYWQ5ZDg3
|
11
|
+
ODdiMzRiZDJmZDFkMGM4ODI2OTA3YzVmZmMzYWRjNDc5NWYxODk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDMyNTQ2Mjc1NjMzMzE1MDA2YmU2NDIzMzdkYzdjOTBkYzBiODYzNzI5MzY0
|
14
|
+
YjRiYmM5Yzc4NDU1NDE5ZmViNjA4MWZlZjcwZDI1ZTA0MTk4ODBkN2E3YTli
|
15
|
+
MmNhZTI2ZWUzZTFhNjExNTE4MDc3Y2Q0MDEwZmYxYzlmNDViMmI=
|
data/README.md
CHANGED
@@ -38,18 +38,15 @@ Tested in a CI environment against the following Ruby versions:
|
|
38
38
|
* 2.1
|
39
39
|
* 2.0.0
|
40
40
|
* 1.9
|
41
|
+
* JRuby (1.9 mode)
|
41
42
|
|
42
43
|
## Known Limitations
|
43
44
|
* No support for branch coverage
|
44
45
|
|
45
|
-
## Troubleshooting
|
46
|
-
Testing requres the libxml-ruby gem. If you get an error about not being able to install the libxml-ruby gem, do the following
|
47
|
-
|
48
|
-
$ sudo apt-get install libxml2-dev
|
49
|
-
|
50
46
|
## Contributors
|
51
47
|
* Jesse Bowes
|
52
48
|
* Sean Clemmer
|
49
|
+
* Ivailo Petrov
|
53
50
|
|
54
51
|
## Contributing
|
55
52
|
|
data/lib/simplecov-cobertura.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rexml/element'
|
|
4
4
|
module SimpleCov
|
5
5
|
module Formatter
|
6
6
|
class CoberturaFormatter
|
7
|
-
VERSION = '1.0.
|
7
|
+
VERSION = '1.1.0.beta.1'
|
8
8
|
|
9
9
|
RESULT_FILE_NAME = 'coverage.xml'
|
10
10
|
DTD_URL = 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'
|
@@ -37,22 +37,31 @@ module SimpleCov
|
|
37
37
|
source.text = SimpleCov.root
|
38
38
|
|
39
39
|
coverage.add_element(packages = REXML::Element.new('packages'))
|
40
|
-
packages.add_element(package = REXML::Element.new('package'))
|
41
|
-
set_package_attributes(package, result)
|
42
40
|
|
43
|
-
|
41
|
+
if result.groups.empty?
|
42
|
+
groups = {File.basename(SimpleCov.root) => result.files}
|
43
|
+
else
|
44
|
+
groups = result.groups
|
45
|
+
end
|
46
|
+
|
47
|
+
groups.map do |name, files|
|
48
|
+
packages.add_element(package = REXML::Element.new('package'))
|
49
|
+
set_package_attributes(package, name, files)
|
50
|
+
|
51
|
+
package.add_element(classes = REXML::Element.new('classes'))
|
44
52
|
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
files.each do |file|
|
54
|
+
classes.add_element(class_ = REXML::Element.new('class'))
|
55
|
+
set_class_attributes(class_, file)
|
48
56
|
|
49
|
-
|
50
|
-
|
57
|
+
class_.add_element(REXML::Element.new('methods'))
|
58
|
+
class_.add_element(lines = REXML::Element.new('lines'))
|
51
59
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
file.lines.each do |file_line|
|
61
|
+
if file_line.covered? || file_line.missed?
|
62
|
+
lines.add_element(line = REXML::Element.new('line'))
|
63
|
+
set_line_attributes(line, file_line)
|
64
|
+
end
|
56
65
|
end
|
57
66
|
end
|
58
67
|
end
|
@@ -73,8 +82,8 @@ module SimpleCov
|
|
73
82
|
coverage.attributes['timestamp'] = Time.now.to_i.to_s
|
74
83
|
end
|
75
84
|
|
76
|
-
def set_package_attributes(package, result)
|
77
|
-
package.attributes['name'] =
|
85
|
+
def set_package_attributes(package, name, result)
|
86
|
+
package.attributes['name'] = name
|
78
87
|
package.attributes['line-rate'] = (result.covered_percent/100).round(2).to_s
|
79
88
|
package.attributes['branch-rate'] = '0'
|
80
89
|
package.attributes['complexity'] = '0'
|
@@ -14,7 +14,7 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def teardown
|
17
|
-
|
17
|
+
SimpleCov.groups.clear
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_format_save_file
|
@@ -30,4 +30,102 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
30
30
|
doc = Nokogiri::XML::Document.parse(xml, nil, nil, options)
|
31
31
|
assert_empty doc.external_subset.validate(doc)
|
32
32
|
end
|
33
|
+
|
34
|
+
def test_no_groups
|
35
|
+
xml = @formatter.format(@result)
|
36
|
+
doc = Nokogiri::XML::Document.parse(xml)
|
37
|
+
|
38
|
+
coverage = doc.xpath '/coverage'
|
39
|
+
assert_equal '1.0', coverage.attribute('line-rate').value
|
40
|
+
assert_equal '0', coverage.attribute('branch-rate').value
|
41
|
+
assert_equal '2', coverage.attribute('lines-covered').value
|
42
|
+
assert_equal '2', coverage.attribute('lines-valid').value
|
43
|
+
assert_equal '0', coverage.attribute('branches-covered').value
|
44
|
+
assert_equal '0', coverage.attribute('branches-valid').value
|
45
|
+
assert_equal '0', coverage.attribute('complexity').value
|
46
|
+
assert_equal '0', coverage.attribute('version').value
|
47
|
+
assert_not_empty coverage.attribute('timestamp').value
|
48
|
+
|
49
|
+
sources = doc.xpath '/coverage/sources/source'
|
50
|
+
assert_equal 1, sources.length
|
51
|
+
assert_equal 'simplecov-cobertura', File.basename(sources.first.text)
|
52
|
+
|
53
|
+
packages = doc.xpath '/coverage/packages/package'
|
54
|
+
assert_equal 1, packages.length
|
55
|
+
package = packages.first
|
56
|
+
assert_equal 'simplecov-cobertura', package.attribute('name').value
|
57
|
+
assert_equal '1.0', package.attribute('line-rate').value
|
58
|
+
assert_equal '0', package.attribute('branch-rate').value
|
59
|
+
assert_equal '0', package.attribute('complexity').value
|
60
|
+
|
61
|
+
classes = doc.xpath '/coverage/packages/package/classes/class'
|
62
|
+
assert_equal 1, classes.length
|
63
|
+
clazz = classes.first
|
64
|
+
assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
|
65
|
+
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
|
66
|
+
assert_equal '1.0', clazz.attribute('line-rate').value
|
67
|
+
assert_equal '0', clazz.attribute('branch-rate').value
|
68
|
+
assert_equal '0', clazz.attribute('complexity').value
|
69
|
+
|
70
|
+
lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
|
71
|
+
assert_equal 2, lines.length
|
72
|
+
first_line = lines.first
|
73
|
+
assert_equal '1', first_line.attribute('number').value
|
74
|
+
assert_equal 'false', first_line.attribute('branch').value
|
75
|
+
assert_equal '1', first_line.attribute('hits').value
|
76
|
+
last_line = lines.last
|
77
|
+
assert_equal '2', last_line.attribute('number').value
|
78
|
+
assert_equal 'false', last_line.attribute('branch').value
|
79
|
+
assert_equal '2', last_line.attribute('hits').value
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_groups
|
83
|
+
SimpleCov.add_group('test_group', 'test/')
|
84
|
+
|
85
|
+
xml = @formatter.format(@result)
|
86
|
+
doc = Nokogiri::XML::Document.parse(xml)
|
87
|
+
|
88
|
+
coverage = doc.xpath '/coverage'
|
89
|
+
assert_equal '1.0', coverage.attribute('line-rate').value
|
90
|
+
assert_equal '0', coverage.attribute('branch-rate').value
|
91
|
+
assert_equal '2', coverage.attribute('lines-covered').value
|
92
|
+
assert_equal '2', coverage.attribute('lines-valid').value
|
93
|
+
assert_equal '0', coverage.attribute('branches-covered').value
|
94
|
+
assert_equal '0', coverage.attribute('branches-valid').value
|
95
|
+
assert_equal '0', coverage.attribute('complexity').value
|
96
|
+
assert_equal '0', coverage.attribute('version').value
|
97
|
+
assert_not_empty coverage.attribute('timestamp').value
|
98
|
+
|
99
|
+
sources = doc.xpath '/coverage/sources/source'
|
100
|
+
assert_equal 1, sources.length
|
101
|
+
assert_equal 'simplecov-cobertura', File.basename(sources.first.text)
|
102
|
+
|
103
|
+
packages = doc.xpath '/coverage/packages/package'
|
104
|
+
assert_equal 1, packages.length
|
105
|
+
package = packages.first
|
106
|
+
assert_equal 'test_group', package.attribute('name').value
|
107
|
+
assert_equal '1.0', package.attribute('line-rate').value
|
108
|
+
assert_equal '0', package.attribute('branch-rate').value
|
109
|
+
assert_equal '0', package.attribute('complexity').value
|
110
|
+
|
111
|
+
classes = doc.xpath '/coverage/packages/package/classes/class'
|
112
|
+
assert_equal 1, classes.length
|
113
|
+
clazz = classes.first
|
114
|
+
assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
|
115
|
+
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
|
116
|
+
assert_equal '1.0', clazz.attribute('line-rate').value
|
117
|
+
assert_equal '0', clazz.attribute('branch-rate').value
|
118
|
+
assert_equal '0', clazz.attribute('complexity').value
|
119
|
+
|
120
|
+
lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
|
121
|
+
assert_equal 2, lines.length
|
122
|
+
first_line = lines.first
|
123
|
+
assert_equal '1', first_line.attribute('number').value
|
124
|
+
assert_equal 'false', first_line.attribute('branch').value
|
125
|
+
assert_equal '1', first_line.attribute('hits').value
|
126
|
+
last_line = lines.last
|
127
|
+
assert_equal '2', last_line.attribute('number').value
|
128
|
+
assert_equal 'false', last_line.attribute('branch').value
|
129
|
+
assert_equal '2', last_line.attribute('hits').value
|
130
|
+
end
|
33
131
|
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.0.
|
4
|
+
version: 1.1.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Bowes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,9 +111,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: 1.9.3
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - ! '
|
114
|
+
- - ! '>'
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
116
|
+
version: 1.3.1
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
119
|
rubygems_version: 2.4.6
|