danger-junit 0.7.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +12 -10
- data/lib/junit/gem_version.rb +1 -1
- data/lib/junit/plugin.rb +35 -11
- data/spec/junit_spec.rb +30 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a77f977d090351e161a00681133882722b68f9bb6b28ac4cbebff16c2e36828e
|
4
|
+
data.tar.gz: 43c9a8ed5b86acfe14408d24da7555d396a2495c5ac4eac891390c843e3e4465
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2592d04156cdab05b89e5462b018ad9fededda320c544d05bea486a468cc6bf30ded2b20c503de339004b3bb588707a39e83d57494ec56b6bc7bd7fbcde35c5
|
7
|
+
data.tar.gz: b58ab5044bee356598b5f7458d76c40e319e8aa9103087825d3612bffa0a3b6ab022661660d89edca3113da3df67dfbe9ab4e9bde6695cb3b7c47f40668e70d3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-junit (0.
|
4
|
+
danger-junit (1.0.0)
|
5
5
|
danger (> 2.0)
|
6
6
|
ox (~> 2.0)
|
7
7
|
|
@@ -21,25 +21,26 @@ GEM
|
|
21
21
|
colored2 (3.1.2)
|
22
22
|
cork (0.3.0)
|
23
23
|
colored2 (~> 3.1)
|
24
|
-
danger (5.
|
24
|
+
danger (5.9.0)
|
25
25
|
claide (~> 1.0)
|
26
26
|
claide-plugins (>= 0.9.2)
|
27
27
|
colored2 (~> 3.1)
|
28
28
|
cork (~> 0.1)
|
29
29
|
faraday (~> 0.9)
|
30
30
|
faraday-http-cache (~> 1.0)
|
31
|
-
git (~> 1)
|
31
|
+
git (~> 1.5)
|
32
32
|
kramdown (~> 1.5)
|
33
|
+
no_proxy_fix
|
33
34
|
octokit (~> 4.7)
|
34
35
|
terminal-table (~> 1)
|
35
36
|
diff-lcs (1.2.5)
|
36
|
-
faraday (0.
|
37
|
+
faraday (0.15.4)
|
37
38
|
multipart-post (>= 1.2, < 3)
|
38
39
|
faraday-http-cache (1.3.1)
|
39
40
|
faraday (~> 0.8)
|
40
41
|
ffi (1.9.14)
|
41
42
|
formatador (0.2.5)
|
42
|
-
git (1.
|
43
|
+
git (1.5.0)
|
43
44
|
guard (2.14.0)
|
44
45
|
formatador (>= 0.2.4)
|
45
46
|
listen (>= 2.7, < 4.0)
|
@@ -54,7 +55,7 @@ GEM
|
|
54
55
|
guard (~> 2.1)
|
55
56
|
guard-compat (~> 1.1)
|
56
57
|
rspec (>= 2.99.0, < 4.0)
|
57
|
-
kramdown (1.
|
58
|
+
kramdown (1.17.0)
|
58
59
|
listen (3.0.7)
|
59
60
|
rb-fsevent (>= 0.9.3)
|
60
61
|
rb-inotify (>= 0.9.7)
|
@@ -63,13 +64,14 @@ GEM
|
|
63
64
|
multipart-post (2.0.0)
|
64
65
|
nap (1.1.0)
|
65
66
|
nenv (0.3.0)
|
67
|
+
no_proxy_fix (0.1.2)
|
66
68
|
notiffany (0.1.1)
|
67
69
|
nenv (~> 0.1)
|
68
70
|
shellany (~> 0.0)
|
69
|
-
octokit (4.
|
71
|
+
octokit (4.13.0)
|
70
72
|
sawyer (~> 0.8.0, >= 0.5.3)
|
71
73
|
open4 (1.3.4)
|
72
|
-
ox (2.
|
74
|
+
ox (2.10.0)
|
73
75
|
parser (2.3.1.2)
|
74
76
|
ast (~> 2.2)
|
75
77
|
powerpack (0.1.1)
|
@@ -77,7 +79,7 @@ GEM
|
|
77
79
|
coderay (~> 1.1.0)
|
78
80
|
method_source (~> 0.8.1)
|
79
81
|
slop (~> 3.4)
|
80
|
-
public_suffix (
|
82
|
+
public_suffix (3.0.3)
|
81
83
|
rainbow (2.1.0)
|
82
84
|
rake (10.5.0)
|
83
85
|
rb-fsevent (0.9.7)
|
@@ -134,4 +136,4 @@ DEPENDENCIES
|
|
134
136
|
yard (~> 0.8)
|
135
137
|
|
136
138
|
BUNDLED WITH
|
137
|
-
1.
|
139
|
+
1.16.3
|
data/lib/junit/gem_version.rb
CHANGED
data/lib/junit/plugin.rb
CHANGED
@@ -14,6 +14,16 @@ module Danger
|
|
14
14
|
# junit.parse "/path/to/output.xml"
|
15
15
|
# junit.report
|
16
16
|
#
|
17
|
+
# @example Parse multiple XML files by passing multiple file names
|
18
|
+
#
|
19
|
+
# junit.parse_files "/path/to/integration-tests.xml", "/path/to/unit-tests.xml"
|
20
|
+
# junit.report
|
21
|
+
#
|
22
|
+
# @example Parse multiple XML files by passing an array
|
23
|
+
# result_files = %w(/path/to/integration-tests.xml /path/to/unit-tests.xml)
|
24
|
+
# junit.parse_files result_files
|
25
|
+
# junit.report
|
26
|
+
#
|
17
27
|
# @example Let the plugin parse the XML file, and report yourself
|
18
28
|
#
|
19
29
|
# junit.parse "/path/to/output.xml"
|
@@ -76,7 +86,8 @@ module Danger
|
|
76
86
|
attr_accessor :show_skipped_tests
|
77
87
|
|
78
88
|
# An array of symbols that become the columns of your tests,
|
79
|
-
# if `nil`, the default, it will be all of the attributes
|
89
|
+
# if `nil`, the default, it will be all of the attributes for a single parse
|
90
|
+
# or all of the common attributes between multiple files
|
80
91
|
#
|
81
92
|
# @return [Array<Symbol>]
|
82
93
|
attr_accessor :headers
|
@@ -85,17 +96,29 @@ module Danger
|
|
85
96
|
# will `raise` for errors
|
86
97
|
# @return [void]
|
87
98
|
def parse(file)
|
99
|
+
parse_files(file)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Parses multiple XML files, which fills all the attributes,
|
103
|
+
# will `raise` for errors
|
104
|
+
# @return [void]
|
105
|
+
def parse_files(*files)
|
88
106
|
require 'ox'
|
89
|
-
|
107
|
+
@tests = []
|
108
|
+
failed_tests = []
|
90
109
|
|
91
|
-
|
92
|
-
|
110
|
+
Array(files).flatten.each do |file|
|
111
|
+
raise "No JUnit file was found at #{file}" unless File.exist? file
|
93
112
|
|
94
|
-
|
95
|
-
|
113
|
+
xml_string = File.read(file)
|
114
|
+
doc = Ox.parse(xml_string)
|
96
115
|
|
97
|
-
|
98
|
-
|
116
|
+
suite_root = doc.nodes.first.value == 'testsuites' ? doc.nodes.first : doc
|
117
|
+
@tests += suite_root.nodes.map(&:nodes).flatten.select { |node| node.kind_of?(Ox::Element) && node.value == 'testcase' }
|
118
|
+
|
119
|
+
failed_suites = suite_root.nodes.select { |suite| suite[:failures].to_i > 0 || suite[:errors].to_i > 0 }
|
120
|
+
failed_tests += failed_suites.map(&:nodes).flatten.select { |node| node.kind_of?(Ox::Element) && node.value == 'testcase' }
|
121
|
+
end
|
99
122
|
|
100
123
|
@failures = failed_tests.select do |test|
|
101
124
|
test.nodes.count > 0
|
@@ -135,14 +158,15 @@ module Danger
|
|
135
158
|
|
136
159
|
tests = (failures + errors)
|
137
160
|
|
161
|
+
common_attributes = tests.map{|test| test.attributes.keys }.inject(&:&)
|
162
|
+
|
138
163
|
# check the provided headers are available
|
139
164
|
unless headers.nil?
|
140
|
-
|
141
|
-
not_available_headers = headers.select { |header| not attributtesKey.include?(header) }
|
165
|
+
not_available_headers = headers.select { |header| not common_attributes.include?(header) }
|
142
166
|
raise "Some of headers provided aren't available in the JUnit report (#{not_available_headers})" unless not_available_headers.empty?
|
143
167
|
end
|
144
168
|
|
145
|
-
keys = headers ||
|
169
|
+
keys = headers || common_attributes
|
146
170
|
attributes = keys.map(&:to_s).map(&:capitalize)
|
147
171
|
|
148
172
|
# Create the headers
|
data/spec/junit_spec.rb
CHANGED
@@ -87,6 +87,36 @@ module Danger
|
|
87
87
|
outputs = @junit.status_report[:markdowns].first
|
88
88
|
expect(outputs.to_s).to include('github.com/thing/thingy')
|
89
89
|
end
|
90
|
+
|
91
|
+
describe 'parsing multiple files' do
|
92
|
+
it 'gets the right results for multiple files' do
|
93
|
+
@junit.parse_files 'spec/fixtures/rspec_fail.xml', 'spec/fixtures/fastlane_trainer.xml'
|
94
|
+
|
95
|
+
expect(@junit.failures.count).to eq 1 + 1
|
96
|
+
expect(@junit.passes.count).to eq 190 + 1
|
97
|
+
expect(@junit.errors.count).to eq 0 + 0
|
98
|
+
expect(@junit.skipped.count).to eq 7 + 0
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'gets the right results for an array of files' do
|
102
|
+
files = %w(spec/fixtures/rspec_fail.xml spec/fixtures/fastlane_trainer.xml)
|
103
|
+
@junit.parse_files files
|
104
|
+
|
105
|
+
expect(@junit.failures.count).to eq 1 + 1
|
106
|
+
expect(@junit.passes.count).to eq 190 + 1
|
107
|
+
expect(@junit.errors.count).to eq 0 + 0
|
108
|
+
expect(@junit.skipped.count).to eq 7 + 0
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'defaults to reporting common attributes for multiple files' do
|
112
|
+
@junit.parse_files 'spec/fixtures/rspec_fail.xml', 'spec/fixtures/eigen_fail.xml'
|
113
|
+
|
114
|
+
@junit.report
|
115
|
+
|
116
|
+
outputs = @junit.status_report[:markdowns].first
|
117
|
+
expect(outputs.to_s).to include('Classname | Name')
|
118
|
+
end
|
119
|
+
end
|
90
120
|
end
|
91
121
|
end
|
92
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-junit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orta Therox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|
@@ -225,8 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
225
|
- !ruby/object:Gem::Version
|
226
226
|
version: '0'
|
227
227
|
requirements: []
|
228
|
-
|
229
|
-
rubygems_version: 2.6.14
|
228
|
+
rubygems_version: 3.0.3
|
230
229
|
signing_key:
|
231
230
|
specification_version: 4
|
232
231
|
summary: Get automatic inline test reporting for JUnit-conforming XML files
|