ci-queue 0.19.0 → 0.20.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/ci/queue/version.rb +1 -1
- data/lib/minitest/queue/junit_reporter.rb +74 -46
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 020e4e1012b0be90bc94deac97a2fb6e00a11aeed0c35e1cffba506145f0b2aa
|
4
|
+
data.tar.gz: 86a96759c23bacf51457b1a24c0284e40dba6904e16ac6a8bc52fdf83fd4243e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a77b0ee4af5f570ef8a398377049afdd88ce611ac9c16319decb9b627c265ef7f2efa773317e9ae04a5472d88d595471e2384fc7bfd4778c291c59d8fa79a08b
|
7
|
+
data.tar.gz: ba72651f0072f98167131617a2635b05260d343108ac4d073a5dba56bcb9e5f7980b14abe66ac10d88662967a86b8cd682d549cf8a22f37dad3b5ea94aa82018
|
data/lib/ci/queue/version.rb
CHANGED
@@ -1,78 +1,106 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'minitest/reporters'
|
3
|
-
require '
|
4
|
+
require 'rexml/document'
|
4
5
|
require 'fileutils'
|
5
6
|
|
6
7
|
module Minitest
|
7
8
|
module Queue
|
8
9
|
class JUnitReporter < Minitest::Reporters::BaseReporter
|
9
|
-
class XmlMarkup < ::Builder::XmlMarkup
|
10
|
-
def trunc!(txt)
|
11
|
-
txt.sub(/\n.*/m, '...')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
10
|
def initialize(report_path = 'log/junit.xml', options = {})
|
16
11
|
super({})
|
17
12
|
@report_path = File.absolute_path(report_path)
|
18
13
|
@base_path = options[:base_path] || Dir.pwd
|
19
14
|
end
|
20
15
|
|
21
|
-
def
|
22
|
-
super
|
23
|
-
|
16
|
+
def generate_document
|
24
17
|
suites = tests.group_by { |test| test.klass }
|
25
18
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
add_tests_to(xml, suite, tests)
|
31
|
-
end
|
19
|
+
doc = REXML::Document.new
|
20
|
+
testsuites = doc.add_element('testsuites')
|
21
|
+
suites.each do |suite, tests|
|
22
|
+
add_tests_to(testsuites, suite, tests)
|
32
23
|
end
|
24
|
+
doc
|
25
|
+
end
|
26
|
+
|
27
|
+
def format_document(doc, io)
|
28
|
+
io << "<?xml version='1.0' encoding='UTF-8'?>\n"
|
29
|
+
formatter = REXML::Formatters::Pretty.new
|
30
|
+
formatter.write(doc, io)
|
31
|
+
io << "\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
def report
|
35
|
+
super
|
36
|
+
|
33
37
|
FileUtils.mkdir_p(File.dirname(@report_path))
|
34
|
-
File.open(@report_path, 'w+')
|
38
|
+
File.open(@report_path, 'w+') do |file|
|
39
|
+
format_document(generate_document, file)
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
private
|
38
44
|
|
39
|
-
def add_tests_to(
|
45
|
+
def add_tests_to(testsuites, suite, tests)
|
40
46
|
suite_result = analyze_suite(tests)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
lineno = test.source_location.last
|
51
|
-
xml.testcase(name: test.name, lineno: lineno, classname: suite, assertions: test.assertions,
|
52
|
-
time: test.time, flaky_test: test.flaked?) do
|
53
|
-
xml << xml_message_for(test) unless test.passed?
|
54
|
-
end
|
47
|
+
relative_path = if tests.first.source_location.first == 'unknown'
|
48
|
+
Pathname.new('')
|
49
|
+
else
|
50
|
+
file_path = Pathname.new(tests.first.source_location.first)
|
51
|
+
if file_path.relative?
|
52
|
+
file_path
|
53
|
+
else
|
54
|
+
base_path = Pathname.new(@base_path)
|
55
|
+
file_path.relative_path_from(base_path)
|
55
56
|
end
|
56
57
|
end
|
58
|
+
|
59
|
+
testsuite = testsuites.add_element(
|
60
|
+
'testsuite',
|
61
|
+
'name' => suite,
|
62
|
+
'filepath' => relative_path,
|
63
|
+
'skipped' => suite_result[:skip_count],
|
64
|
+
'failures' => suite_result[:fail_count],
|
65
|
+
'errors' => suite_result[:error_count],
|
66
|
+
'tests' => suite_result[:test_count],
|
67
|
+
'assertions' => suite_result[:assertion_count],
|
68
|
+
'time' => suite_result[:time],
|
69
|
+
)
|
70
|
+
|
71
|
+
tests.each do |test|
|
72
|
+
lineno = tests.first.source_location.last
|
73
|
+
attributes = {
|
74
|
+
'name' => test.name,
|
75
|
+
'classname' => suite,
|
76
|
+
'assertions' => test.assertions,
|
77
|
+
'time' => test.time,
|
78
|
+
'flaky_test' => test.flaked?
|
79
|
+
}
|
80
|
+
attributes['lineno'] = lineno if lineno != -1
|
81
|
+
|
82
|
+
testcase = testsuite.add_element('testcase', attributes)
|
83
|
+
add_xml_message_for(testcase, test) unless test.passed?
|
84
|
+
end
|
57
85
|
end
|
58
86
|
|
59
|
-
def
|
60
|
-
xml = XmlMarkup.new(indent: 2, margin: 2)
|
87
|
+
def add_xml_message_for(testcase, test)
|
61
88
|
failure = test.failure
|
62
|
-
|
63
89
|
if test.skipped? && !test.flaked?
|
64
|
-
|
90
|
+
testcase.add_element('skipped', 'type' => failure.error.class.name)
|
65
91
|
elsif test.error?
|
66
|
-
|
67
|
-
|
68
|
-
end
|
92
|
+
error = testcase.add_element('error', 'type' => failure.error.class.name, 'message' => truncate_message(failure.message))
|
93
|
+
error.add_text(REXML::CData.new(message_for(test)))
|
69
94
|
elsif failure
|
70
|
-
|
71
|
-
|
72
|
-
end
|
95
|
+
failure = testcase.add_element('failure', 'type' => failure.error.class.name, 'message' => truncate_message(failure.message))
|
96
|
+
failure.add_text(REXML::CData.new(message_for(test)))
|
73
97
|
end
|
74
98
|
end
|
75
99
|
|
100
|
+
def truncate_message(message)
|
101
|
+
message.lines.first.chomp.gsub(/\e\[[^m]+m/, '')
|
102
|
+
end
|
103
|
+
|
76
104
|
def message_for(test)
|
77
105
|
suite = test.klass
|
78
106
|
name = test.name
|
@@ -81,17 +109,17 @@ module Minitest
|
|
81
109
|
if test.passed?
|
82
110
|
nil
|
83
111
|
elsif test.skipped?
|
84
|
-
"
|
112
|
+
"\nSkipped:\n#{name}(#{suite}) [#{location(error)}]:\n#{error.message}\n"
|
85
113
|
elsif test.failure
|
86
|
-
"
|
114
|
+
"\nFailure:\n#{name}(#{suite}) [#{location(error)}]:\n#{error.message}\n"
|
87
115
|
elsif test.error?
|
88
|
-
"
|
116
|
+
"\nError:\n#{name}(#{suite}) [#{location(error)}]:\n#{error.message}\n"
|
89
117
|
end
|
90
118
|
end
|
91
119
|
|
92
120
|
def location(exception)
|
93
121
|
last_before_assertion = ''
|
94
|
-
exception.backtrace.reverse_each do |s|
|
122
|
+
(exception.backtrace || []).reverse_each do |s|
|
95
123
|
break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
|
96
124
|
last_before_assertion = s
|
97
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci-queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|