simplecov-cobertura 3.0.0 → 3.1.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 +4 -4
- data/lib/simplecov-cobertura/version.rb +1 -1
- data/lib/simplecov-cobertura.rb +5 -9
- data/test/simplecov-cobertura_test.rb +23 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04ae07cb7f6bb85ad36640169b7d630c985ca1d3d067ef3485ea531b7b775209
|
4
|
+
data.tar.gz: 42f5899bf07710880548d48a27d8d59d2eef1b4d10a05374c44e4344f8f0ac54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e35c59ec78263fe81826f47b83ff5e160e08bf8aa4e01a01b943d1671974c853737e4742e5073997e4ac40d77f54f4f29a1f3d29b17a8e93021432c3f7814fc1
|
7
|
+
data.tar.gz: b320d8920cfb8a354031628b045077387474fb07511547cc14f277a00362fcd34ef9974dfb0464cda308f5f167e0c3c3c4bbf932b3608e463bc948dbeb0696da
|
data/lib/simplecov-cobertura.rb
CHANGED
@@ -33,8 +33,11 @@ module SimpleCov
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def result_to_xml(result)
|
36
|
-
doc = REXML::Document.new
|
36
|
+
doc = REXML::Document.new
|
37
37
|
doc.context[:attribute_quote] = :quote
|
38
|
+
doc << REXML::XMLDecl.new('1.0')
|
39
|
+
doc << REXML::DocType.new('coverage', "SYSTEM \"#{DTD_URL}\"")
|
40
|
+
doc << REXML::Comment.new("Generated by simplecov-cobertura version #{VERSION} (https://github.com/jessebs/simplecov-cobertura)")
|
38
41
|
doc.add_element REXML::Element.new('coverage')
|
39
42
|
coverage = doc.root
|
40
43
|
|
@@ -140,13 +143,6 @@ module SimpleCov
|
|
140
143
|
end
|
141
144
|
end
|
142
145
|
|
143
|
-
def set_xml_head(lines=[])
|
144
|
-
lines << "<?xml version=\"1.0\"?>"
|
145
|
-
lines << "<!DOCTYPE coverage SYSTEM \"#{DTD_URL}\">"
|
146
|
-
lines << "<!-- Generated by simplecov-cobertura version #{VERSION} (https://github.com/jessebs/simplecov-cobertura) -->"
|
147
|
-
lines.join("\n")
|
148
|
-
end
|
149
|
-
|
150
146
|
# Roughly mirrors private method SimpleCov::Formatter::HTMLFormatter#output_coverage
|
151
147
|
def output_message(result, output_path)
|
152
148
|
output = "Coverage report generated for #{result.command_name} to #{output_path}."
|
@@ -160,7 +156,7 @@ module SimpleCov
|
|
160
156
|
end
|
161
157
|
|
162
158
|
def extract_rate(percent)
|
163
|
-
(percent / 100).round(
|
159
|
+
(percent / 100).round(4).to_s
|
164
160
|
end
|
165
161
|
|
166
162
|
def project_root
|
@@ -17,7 +17,13 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
17
17
|
[:if, 3, 5, 4, 5, 26] =>
|
18
18
|
{[:then, 4, 5, 16, 5, 20] => 1, [:else, 5, 5, 23, 5, 26] => 0},
|
19
19
|
[:if, 6, 7, 4, 11, 7] =>
|
20
|
-
{[:then, 7, 8, 6, 8, 10] => 0, [:else, 8, 10, 6, 10, 9] => 1}
|
20
|
+
{[:then, 7, 8, 6, 8, 10] => 0, [:else, 8, 10, 6, 10, 9] => 1},
|
21
|
+
[:if, 9, 12, 4, 12, 15] =>
|
22
|
+
{[:then, 10, 12, 6, 12, 10] => 1, [:else, 11, 12, 13, 12, 15] => 0},
|
23
|
+
[:if, 12, 13, 4, 13, 20] =>
|
24
|
+
{[:then, 13, 13, 6, 13, 15] => 1, [:else, 14, 13, 18, 13, 20] => 0},
|
25
|
+
[:if, 15, 15, 4, 15, 25] =>
|
26
|
+
{[:then, 16, 15, 6, 15, 20] => 0, [:else, 17, 15, 23, 15, 25] => 0}
|
21
27
|
}
|
22
28
|
}
|
23
29
|
})
|
@@ -65,12 +71,12 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
65
71
|
doc = Nokogiri::XML::Document.parse(xml)
|
66
72
|
|
67
73
|
coverage = doc.xpath '/coverage'
|
68
|
-
assert_equal '0.
|
69
|
-
assert_equal '0.
|
74
|
+
assert_equal '0.8571', coverage.attribute('line-rate').value
|
75
|
+
assert_equal '0.4167', coverage.attribute('branch-rate').value
|
70
76
|
assert_equal '6', coverage.attribute('lines-covered').value
|
71
77
|
assert_equal '7', coverage.attribute('lines-valid').value
|
72
|
-
assert_equal '
|
73
|
-
assert_equal '
|
78
|
+
assert_equal '5', coverage.attribute('branches-covered').value
|
79
|
+
assert_equal '12', coverage.attribute('branches-valid').value
|
74
80
|
assert_equal '0', coverage.attribute('complexity').value
|
75
81
|
assert_equal '0', coverage.attribute('version').value
|
76
82
|
assert_not_empty coverage.attribute('timestamp').value
|
@@ -83,8 +89,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
83
89
|
assert_equal 1, packages.length
|
84
90
|
package = packages.first
|
85
91
|
assert_equal 'simplecov-cobertura', package.attribute('name').value
|
86
|
-
assert_equal '0.
|
87
|
-
assert_equal '0.
|
92
|
+
assert_equal '0.8571', package.attribute('line-rate').value
|
93
|
+
assert_equal '0.4167', package.attribute('branch-rate').value
|
88
94
|
assert_equal '0', package.attribute('complexity').value
|
89
95
|
|
90
96
|
classes = doc.xpath '/coverage/packages/package/classes/class'
|
@@ -92,8 +98,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
92
98
|
clazz = classes.first
|
93
99
|
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('name').value
|
94
100
|
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
|
95
|
-
assert_equal '0.
|
96
|
-
assert_equal '0.
|
101
|
+
assert_equal '0.8571', clazz.attribute('line-rate').value
|
102
|
+
assert_equal '0.4167', clazz.attribute('branch-rate').value
|
97
103
|
assert_equal '0', clazz.attribute('complexity').value
|
98
104
|
|
99
105
|
lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
|
@@ -115,12 +121,12 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
115
121
|
doc = Nokogiri::XML::Document.parse(xml)
|
116
122
|
|
117
123
|
coverage = doc.xpath '/coverage'
|
118
|
-
assert_equal '0.
|
119
|
-
assert_equal '0.
|
124
|
+
assert_equal '0.8571', coverage.attribute('line-rate').value
|
125
|
+
assert_equal '0.4167', coverage.attribute('branch-rate').value
|
120
126
|
assert_equal '6', coverage.attribute('lines-covered').value
|
121
127
|
assert_equal '7', coverage.attribute('lines-valid').value
|
122
|
-
assert_equal '
|
123
|
-
assert_equal '
|
128
|
+
assert_equal '5', coverage.attribute('branches-covered').value
|
129
|
+
assert_equal '12', coverage.attribute('branches-valid').value
|
124
130
|
assert_equal '0', coverage.attribute('complexity').value
|
125
131
|
assert_equal '0', coverage.attribute('version').value
|
126
132
|
assert_not_empty coverage.attribute('timestamp').value
|
@@ -133,8 +139,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
133
139
|
assert_equal 1, packages.length
|
134
140
|
package = packages.first
|
135
141
|
assert_equal 'test_group', package.attribute('name').value
|
136
|
-
assert_equal '0.
|
137
|
-
assert_equal '0.
|
142
|
+
assert_equal '0.8571', package.attribute('line-rate').value
|
143
|
+
assert_equal '0.4167', package.attribute('branch-rate').value
|
138
144
|
assert_equal '0', package.attribute('complexity').value
|
139
145
|
|
140
146
|
classes = doc.xpath '/coverage/packages/package/classes/class'
|
@@ -142,8 +148,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
142
148
|
clazz = classes.first
|
143
149
|
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('name').value
|
144
150
|
assert_equal 'test/simplecov-cobertura_test.rb', clazz.attribute('filename').value
|
145
|
-
assert_equal '0.
|
146
|
-
assert_equal '0.
|
151
|
+
assert_equal '0.8571', clazz.attribute('line-rate').value
|
152
|
+
assert_equal '0.4167', clazz.attribute('branch-rate').value
|
147
153
|
assert_equal '0', clazz.attribute('complexity').value
|
148
154
|
|
149
155
|
lines = doc.xpath '/coverage/packages/package/classes/class/lines/line'
|