Module: Minitest::Queue
- Defined in:
- lib/minitest/queue.rb,
lib/minitest/queue/runner.rb,
lib/minitest/queue/statsd.rb,
lib/minitest/queue/test_data.rb,
lib/minitest/queue/error_report.rb,
lib/minitest/queue/grind_recorder.rb,
lib/minitest/queue/grind_reporter.rb,
lib/minitest/queue/junit_reporter.rb,
lib/minitest/queue/failure_formatter.rb,
lib/minitest/queue/test_data_reporter.rb,
lib/minitest/queue/test_time_recorder.rb,
lib/minitest/queue/test_time_reporter.rb,
lib/minitest/queue/build_status_recorder.rb,
lib/minitest/queue/build_status_reporter.rb,
lib/minitest/queue/local_requeue_reporter.rb
Defined Under Namespace
Classes: BuildStatusRecorder, BuildStatusReporter, ErrorReport, FailureFormatter, GrindRecorder, GrindReporter, JUnitReporter, LocalRequeueReporter, OrderReporter, Runner, SingleExample, Statsd, TestData, TestDataReporter, TestTimeRecorder, TestTimeReporter
Constant Summary
collapse
- DEFAULT_RUN_COMMAND_FORMATTER =
lambda do |runnable|
filename = Minitest::Queue.relative_path(runnable.source_location[0])
identifier = "#{runnable.klass}##{runnable.name}"
['bundle', 'exec', 'ruby', '-Ilib:test', filename, '-n', identifier]
end
- RAILS_RUN_COMMAND_FORMATTER =
lambda do |runnable|
filename = Minitest::Queue.relative_path(runnable.source_location[0])
lineno = runnable.source_location[1]
['bin/rails', 'test', "#{filename}:#{lineno}"]
end
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#project_root=(value) ⇒ Object
Sets the attribute project_root
106
107
108
|
# File 'lib/minitest/queue.rb', line 106
def project_root=(value)
@project_root = value
end
|
#queue ⇒ Object
Returns the value of attribute queue.
171
172
173
|
# File 'lib/minitest/queue.rb', line 171
def queue
@queue
end
|
108
109
110
111
112
113
114
|
# File 'lib/minitest/queue.rb', line 108
def run_command_formatter
@run_command_formatter ||= if defined?(Rails) && defined?(Rails::TestUnitRailtie)
RAILS_RUN_COMMAND_FORMATTER
else
DEFAULT_RUN_COMMAND_FORMATTER
end
end
|
Class Method Details
.project_root ⇒ Object
137
138
139
|
# File 'lib/minitest/queue.rb', line 137
def self.project_root
@project_root ||= Dir.pwd
end
|
.relative_path(path, root: project_root) ⇒ Object
141
142
143
144
145
|
# File 'lib/minitest/queue.rb', line 141
def self.relative_path(path, root: project_root)
Pathname(path).relative_path_from(Pathname(root)).to_s
rescue ArgumentError
path
end
|
Instance Method Details
#__run(*args) ⇒ Object
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# File 'lib/minitest/queue.rb', line 192
def __run(*args)
if queue
run_from_queue(*args)
if queue.config.circuit_breakers.any?(&:open?)
STDERR.puts queue.config.circuit_breakers.map(&:message).join(' ').strip
end
if queue.max_test_failed?
STDERR.puts 'This worker is exiting early because too many failed tests were encountered.'
end
else
super
end
end
|
#loaded_tests ⇒ Object
184
185
186
187
188
189
190
|
# File 'lib/minitest/queue.rb', line 184
def loaded_tests
Minitest::Test.runnables.flat_map do |runnable|
runnable.runnable_methods.map do |method_name|
SingleExample.new(runnable, method_name)
end
end
end
|
#queue_reporters=(reporters) ⇒ Object
177
178
179
180
181
182
|
# File 'lib/minitest/queue.rb', line 177
def queue_reporters=(reporters)
@queue_reporters ||= []
Reporters.use!(((Reporters.reporters || []) - @queue_reporters) + reporters)
Minitest.backtrace_filter.add_filter(%r{exe/minitest-queue|lib/ci/queue/})
@queue_reporters = reporters
end
|
#run_command_for_runnable(runnable) ⇒ Object
128
129
130
131
132
133
134
135
|
# File 'lib/minitest/queue.rb', line 128
def run_command_for_runnable(runnable)
command = run_command_formatter.call(runnable)
if command.is_a?(Array)
Shellwords.join(command)
else
command
end
end
|
#run_from_queue(reporter) ⇒ Object
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
# File 'lib/minitest/queue.rb', line 208
def run_from_queue(reporter, *)
queue.poll do |example|
result = example.run
failed = !(result.passed? || result.skipped?)
if example.flaky?
result.mark_as_flaked!
failed = false
end
if failed
queue.report_failure!
else
queue.report_success!
end
requeued = false
if failed && CI::Queue.requeueable?(result) && queue.requeue(example)
requeued = true
result.requeue!
reporter.record(result)
elsif queue.acknowledge(example) || !failed
reporter.record(result)
end
if !requeued && failed
queue.increment_test_failed
end
end
end
|