danger-junit 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +6 -1
- data/README.md +20 -0
- data/danger-junit.gemspec +3 -0
- data/lib/junit/gem_version.rb +1 -1
- data/lib/junit/plugin.rb +42 -4
- data/spec/junit_spec.rb +23 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b38b37d5c91b3b94bd40bfd1f992bea06cdf53ff
|
4
|
+
data.tar.gz: e4195e8fec3601f580c1e7002b69a89a0f8e05dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfce1b8cb7f2e33dc4ccb299ac1d77b6912788c5dd4d32792851cf0ae6ad5d8de58c48d5c68c5aadadea9305796a5b6a3ba48c88cbd37fbec932ea7539491ea1
|
7
|
+
data.tar.gz: 0c7b6bffd9f5f3ab657cc64ceb0a7dd2d40da4347702e6f291861cf775304575e65a92a35976bf9b352171f1859411d95e468e576f8b1e9c37f88ddb074716d1
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-junit (0.
|
4
|
+
danger-junit (0.6.0)
|
5
5
|
danger (~> 2.0)
|
6
6
|
ox (~> 2.0)
|
7
7
|
|
@@ -10,6 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
addressable (2.4.0)
|
12
12
|
ast (2.3.0)
|
13
|
+
builder (3.2.2)
|
13
14
|
claide (1.0.0)
|
14
15
|
claide-plugins (0.9.1)
|
15
16
|
cork
|
@@ -93,6 +94,9 @@ GEM
|
|
93
94
|
diff-lcs (>= 1.2.0, < 2.0)
|
94
95
|
rspec-support (~> 3.5.0)
|
95
96
|
rspec-support (3.5.0)
|
97
|
+
rspec_junit_formatter (0.2.3)
|
98
|
+
builder (< 4)
|
99
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
96
100
|
rubocop (0.42.0)
|
97
101
|
parser (>= 2.3.1.1, < 3.0)
|
98
102
|
powerpack (~> 0.1)
|
@@ -122,6 +126,7 @@ DEPENDENCIES
|
|
122
126
|
pry
|
123
127
|
rake (~> 10.0)
|
124
128
|
rspec (~> 3.4)
|
129
|
+
rspec_junit_formatter (~> 0.2)
|
125
130
|
rubocop (~> 0.41)
|
126
131
|
yard (~> 0.8)
|
127
132
|
|
data/README.md
CHANGED
@@ -40,10 +40,27 @@ junit.show_skipped_tests = true
|
|
40
40
|
junit.report</pre>
|
41
41
|
</blockquote>
|
42
42
|
|
43
|
+
<blockquote>Only show specific parts of your results
|
44
|
+
<pre>
|
45
|
+
junit.parse "/path/to/output.xml"
|
46
|
+
junit.headers = [:name, :file]
|
47
|
+
junit.report</pre>
|
48
|
+
</blockquote>
|
49
|
+
|
50
|
+
<blockquote>Only show specific parts of your results
|
51
|
+
<pre>
|
52
|
+
junit.parse "/path/to/output.xml"
|
53
|
+
all_test = junit.tests.map(&:attributes)
|
54
|
+
slowest_test = sort_by { |attributes| attributes[:time].to_f }.last
|
55
|
+
message "#{slowest_test[:time]} took #{slowest_test[:time]} seconds"</pre>
|
56
|
+
</blockquote>
|
57
|
+
|
43
58
|
|
44
59
|
|
45
60
|
#### Attributes
|
46
61
|
<tr>
|
62
|
+
`tests` - All the tests for introspection
|
63
|
+
<tr>
|
47
64
|
`passes` - An array of XML elements that represent passed tests.
|
48
65
|
<tr>
|
49
66
|
`failures` - An array of XML elements that represent failed tests.
|
@@ -53,6 +70,9 @@ junit.report</pre>
|
|
53
70
|
`skipped` - An array of XML elements that represent skipped tests.
|
54
71
|
<tr>
|
55
72
|
`show_skipped_tests` - An attribute to make the plugin show a warning on skipped tests.
|
73
|
+
<tr>
|
74
|
+
`headers` - An array of symbols that become the columns of your tests,
|
75
|
+
if `nil`, the default, it will be all of the attribues.
|
56
76
|
|
57
77
|
|
58
78
|
|
data/danger-junit.gemspec
CHANGED
@@ -21,6 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency 'danger', '~> 2.0'
|
22
22
|
spec.add_runtime_dependency 'ox', '~> 2.0'
|
23
23
|
|
24
|
+
# So we can run our specs with junit
|
25
|
+
spec.add_development_dependency "rspec_junit_formatter", "~> 0.2"
|
26
|
+
|
24
27
|
# General ruby development
|
25
28
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/lib/junit/gem_version.rb
CHANGED
data/lib/junit/plugin.rb
CHANGED
@@ -24,10 +24,30 @@ module Danger
|
|
24
24
|
# junit.show_skipped_tests = true
|
25
25
|
# junit.report
|
26
26
|
#
|
27
|
+
# @example Only show specific parts of your results
|
28
|
+
#
|
29
|
+
# junit.parse "/path/to/output.xml"
|
30
|
+
# junit.headers = [:name, :file]
|
31
|
+
# junit.report
|
32
|
+
#
|
33
|
+
# @example Only show specific parts of your results
|
34
|
+
#
|
35
|
+
# junit.parse "/path/to/output.xml"
|
36
|
+
# all_test = junit.tests.map(&:attributes)
|
37
|
+
# slowest_test = sort_by { |attributes| attributes[:time].to_f }.last
|
38
|
+
# message "#{slowest_test[:time]} took #{slowest_test[:time]} seconds"
|
39
|
+
#
|
40
|
+
#
|
27
41
|
# @see orta/danger-junit, danger/danger, artsy/eigen
|
28
42
|
# @tags testing, reporting, junit, rspec, jasmine, jest, xcpretty
|
29
43
|
#
|
30
44
|
class DangerJunit < Plugin
|
45
|
+
|
46
|
+
# All the tests for introspection
|
47
|
+
#
|
48
|
+
# @return [Array<Ox::Element>]
|
49
|
+
attr_accessor :tests
|
50
|
+
|
31
51
|
# An array of XML elements that represent passed tests.
|
32
52
|
#
|
33
53
|
# @return [Array<Ox::Element>]
|
@@ -53,6 +73,12 @@ module Danger
|
|
53
73
|
# @return [Bool]
|
54
74
|
attr_accessor :show_skipped_tests
|
55
75
|
|
76
|
+
# An array of symbols that become the columns of your tests,
|
77
|
+
# if `nil`, the default, it will be all of the attribues.
|
78
|
+
#
|
79
|
+
# @return [Array<Symbol>]
|
80
|
+
attr_accessor :headers
|
81
|
+
|
56
82
|
# Parses an XML file, which fills all the attributes
|
57
83
|
# will `raise` for errors
|
58
84
|
# @return [void]
|
@@ -64,7 +90,7 @@ module Danger
|
|
64
90
|
@doc = Ox.parse xml_string
|
65
91
|
|
66
92
|
suite_root = @doc.nodes.first.value == 'testsuites' ? @doc.nodes.first : @doc
|
67
|
-
tests = suite_root.nodes.map(&:nodes).flatten.select { |node| node.value == 'testcase' }
|
93
|
+
@tests = suite_root.nodes.map(&:nodes).flatten.select { |node| node.value == 'testcase' }
|
68
94
|
|
69
95
|
failed_suites = suite_root.nodes.select { |suite| suite[:failures].to_i > 0 || suite[:errors].to_i > 0 }
|
70
96
|
failed_tests = failed_suites.map(&:nodes).flatten.select { |node| node.value == 'testcase' }
|
@@ -90,19 +116,31 @@ module Danger
|
|
90
116
|
message = "### Tests: \n\n"
|
91
117
|
|
92
118
|
tests = (failures + errors)
|
93
|
-
keys = tests.first.attributes.keys
|
119
|
+
keys = headers || tests.first.attributes.keys
|
94
120
|
attributes = keys.map(&:to_s).map(&:capitalize)
|
95
121
|
|
96
|
-
# Create the
|
122
|
+
# Create the headers
|
97
123
|
message << attributes.join(' | ') + "|\n"
|
98
124
|
message << attributes.map { |_| '---' }.join(' | ') + "|\n"
|
99
125
|
|
126
|
+
# Map out the keys to the tests
|
100
127
|
tests.each do |test|
|
101
|
-
|
128
|
+
row_values = keys.map { |key| test.attributes[key] }.map { |v| auto_link(v) }
|
129
|
+
message << row_values.join(' | ') + "|\n"
|
102
130
|
end
|
103
131
|
|
104
132
|
markdown message
|
105
133
|
end
|
106
134
|
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
def auto_link(value)
|
139
|
+
if File.exist?(value) && defined?(@dangerfile.github)
|
140
|
+
github.html_link value
|
141
|
+
else
|
142
|
+
value
|
143
|
+
end
|
144
|
+
end
|
107
145
|
end
|
108
146
|
end
|
data/spec/junit_spec.rb
CHANGED
@@ -49,6 +49,16 @@ module Danger
|
|
49
49
|
expect(output).to include(row)
|
50
50
|
end
|
51
51
|
|
52
|
+
it 'shows a known markdown row' do
|
53
|
+
@junit.parse 'spec/fixtures/rspec_fail.xml'
|
54
|
+
@junit.headers = [:time]
|
55
|
+
@junit.report
|
56
|
+
|
57
|
+
output = @junit.status_report[:markdowns].first
|
58
|
+
row = "Time|\n"
|
59
|
+
expect(output).to include(row)
|
60
|
+
end
|
61
|
+
|
52
62
|
it 'shows a warning for skipped' do
|
53
63
|
@junit.parse 'spec/fixtures/rspec_fail.xml'
|
54
64
|
@junit.show_skipped_tests = true
|
@@ -57,6 +67,19 @@ module Danger
|
|
57
67
|
warnings = @junit.status_report[:warnings].first
|
58
68
|
expect(warnings).to eq('Skipped 7 tests.')
|
59
69
|
end
|
70
|
+
|
71
|
+
it 'links paths that are files' do
|
72
|
+
allow(@dangerfile.github).to receive(:pr_json).and_return({
|
73
|
+
head: { repo: { html_url: 'https://github.com/thing/thingy' } }
|
74
|
+
})
|
75
|
+
allow(@dangerfile.github).to receive(:head_commit).and_return("hello")
|
76
|
+
|
77
|
+
@junit.parse 'spec/fixtures/danger-junit-fail.xml'
|
78
|
+
@junit.report
|
79
|
+
|
80
|
+
outputs = @junit.status_report[:markdowns].first
|
81
|
+
expect(outputs).to include('github.com/thing/thingy')
|
82
|
+
end
|
60
83
|
end
|
61
84
|
end
|
62
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-junit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orta Therox
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec_junit_formatter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.2'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|