ci-queue 0.20.0 → 0.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ci/queue/version.rb +1 -1
- data/lib/minitest/queue.rb +42 -0
- data/lib/minitest/queue/junit_reporter.rb +19 -23
- 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: c5d3525c5eac10718326a27026a9760509bca1a0d23b15f6ad2b8f5521321c29
|
4
|
+
data.tar.gz: 05a459ded4b16d60c5dd5e58ed3e175b97467193894d6f64acbdb3d071e971a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1589714a963162803a93e134b671026c90910d7a645057d58dafa785f97408f94562d43d4545c7123b63feb93a0966710b43acf63cc1d7aa727684db7a952e7
|
7
|
+
data.tar.gz: da902c68164c997ebbda25d6305742059c101d08a23d084b3b0bedeb3e2f4bace623e1241c4298dff24b0061a846be201b9ae4edda4d3df3537ae40642bab276
|
data/lib/ci/queue/version.rb
CHANGED
data/lib/minitest/queue.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'shellwords'
|
2
3
|
require 'minitest'
|
3
4
|
require 'minitest/reporters'
|
4
5
|
|
@@ -102,6 +103,47 @@ module Minitest
|
|
102
103
|
end
|
103
104
|
|
104
105
|
module Queue
|
106
|
+
attr_writer :run_command_formatter, :project_root
|
107
|
+
|
108
|
+
def run_command_formatter
|
109
|
+
@run_command_formatter ||= if defined?(Railties)
|
110
|
+
RAILS_RUN_COMMAND_FORMATTER
|
111
|
+
else
|
112
|
+
DEFAULT_RUN_COMMAND_FORMATTER
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
DEFAULT_RUN_COMMAND_FORMATTER = lambda do |runnable|
|
117
|
+
filename = Minitest::Queue.relative_path(runnable.source_location[0])
|
118
|
+
identifier = "#{runnable.klass}##{runnable.name}"
|
119
|
+
['bundle', 'exec', 'ruby', '-Ilib:test', filename, '-n', identifier]
|
120
|
+
end
|
121
|
+
|
122
|
+
RAILS_RUN_COMMAND_FORMATTER = lambda do |runnable|
|
123
|
+
filename = Minitest::Queue.relative_path(runnable.source_location[0])
|
124
|
+
lineno = runnable.source_location[1]
|
125
|
+
['bin/rails', 'test', "#{filename}:#{lineno}"]
|
126
|
+
end
|
127
|
+
|
128
|
+
def run_command_for_runnable(runnable)
|
129
|
+
command = run_command_formatter.call(runnable)
|
130
|
+
if command.is_a?(Array)
|
131
|
+
Shellwords.join(command)
|
132
|
+
else
|
133
|
+
command
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.project_root
|
138
|
+
@project_root ||= Dir.pwd
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.relative_path(path, root: project_root)
|
142
|
+
Pathname(path).relative_path_from(Pathname(root)).to_s
|
143
|
+
rescue ArgumentError
|
144
|
+
path
|
145
|
+
end
|
146
|
+
|
105
147
|
class SingleExample
|
106
148
|
|
107
149
|
def initialize(runnable, method_name)
|
@@ -16,7 +16,12 @@ module Minitest
|
|
16
16
|
def generate_document
|
17
17
|
suites = tests.group_by { |test| test.klass }
|
18
18
|
|
19
|
-
doc = REXML::Document.new
|
19
|
+
doc = REXML::Document.new(nil, {
|
20
|
+
:prologue_quote => :quote,
|
21
|
+
:attribute_quote => :quote,
|
22
|
+
})
|
23
|
+
doc << REXML::XMLDecl.new('1.1', 'utf-8')
|
24
|
+
|
20
25
|
testsuites = doc.add_element('testsuites')
|
21
26
|
suites.each do |suite, tests|
|
22
27
|
add_tests_to(testsuites, suite, tests)
|
@@ -25,7 +30,6 @@ module Minitest
|
|
25
30
|
end
|
26
31
|
|
27
32
|
def format_document(doc, io)
|
28
|
-
io << "<?xml version='1.0' encoding='UTF-8'?>\n"
|
29
33
|
formatter = REXML::Formatters::Pretty.new
|
30
34
|
formatter.write(doc, io)
|
31
35
|
io << "\n"
|
@@ -44,17 +48,7 @@ module Minitest
|
|
44
48
|
|
45
49
|
def add_tests_to(testsuites, suite, tests)
|
46
50
|
suite_result = analyze_suite(tests)
|
47
|
-
relative_path =
|
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)
|
56
|
-
end
|
57
|
-
end
|
51
|
+
relative_path = location_for_runnable(tests.first) || '<unknown>'
|
58
52
|
|
59
53
|
testsuite = testsuites.add_element(
|
60
54
|
'testsuite',
|
@@ -75,7 +69,8 @@ module Minitest
|
|
75
69
|
'classname' => suite,
|
76
70
|
'assertions' => test.assertions,
|
77
71
|
'time' => test.time,
|
78
|
-
'flaky_test' => test.flaked
|
72
|
+
'flaky_test' => test.flaked?,
|
73
|
+
'run-command' => Minitest.run_command_for_runnable(test),
|
79
74
|
}
|
80
75
|
attributes['lineno'] = lineno if lineno != -1
|
81
76
|
|
@@ -106,24 +101,25 @@ module Minitest
|
|
106
101
|
name = test.name
|
107
102
|
error = test.failure
|
108
103
|
|
104
|
+
message_with_relative_paths = error.message.gsub("#{Minitest::Queue.project_root}/", '')
|
105
|
+
|
109
106
|
if test.passed?
|
110
107
|
nil
|
111
108
|
elsif test.skipped?
|
112
|
-
"\nSkipped:\n#{name}(#{suite}) [#{
|
109
|
+
"\nSkipped:\n#{name}(#{suite}) [#{location_for_runnable(test)}]:\n#{message_with_relative_paths}\n"
|
113
110
|
elsif test.failure
|
114
|
-
"\nFailure:\n#{name}(#{suite}) [#{
|
111
|
+
"\nFailure:\n#{name}(#{suite}) [#{location_for_runnable(test)}]:\n#{message_with_relative_paths}\n"
|
115
112
|
elsif test.error?
|
116
|
-
"\nError:\n#{name}(#{suite}) [#{
|
113
|
+
"\nError:\n#{name}(#{suite}) [#{location_for_runnable(test)}]:\n#{message_with_relative_paths}\n"
|
117
114
|
end
|
118
115
|
end
|
119
116
|
|
120
|
-
def
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
117
|
+
def location_for_runnable(runnable)
|
118
|
+
if runnable.source_location.first == 'unknown'
|
119
|
+
nil
|
120
|
+
else
|
121
|
+
Minitest::Queue.relative_path(runnable.source_location.first)
|
125
122
|
end
|
126
|
-
last_before_assertion.sub(/:in .*$/, '')
|
127
123
|
end
|
128
124
|
|
129
125
|
def analyze_suite(tests)
|
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.20.
|
4
|
+
version: 0.20.1
|
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-05-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|