module Minitest::Queue
Constants
- DEFAULT_RUN_COMMAND_FORMATTER
- RAILS_RUN_COMMAND_FORMATTER
Attributes
project_root[W]
queue[R]
run_command_formatter[W]
Public Class Methods
project_root()
click to toggle source
# File lib/minitest/queue.rb, line 137 def self.project_root @project_root ||= Dir.pwd end
relative_path(path, root: project_root)
click to toggle source
# 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
Public Instance Methods
__run(*args)
click to toggle source
Calls superclass method
# 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()
click to toggle source
# 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=(queue)
click to toggle source
# File lib/minitest/queue.rb, line 173 def queue=(queue) @queue = queue end
queue_reporters=(reporters)
click to toggle source
# 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)
click to toggle source
# 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_command_formatter()
click to toggle source
# 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
run_from_queue(reporter, *)
click to toggle source
# 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 # If the test was already acknowledged by another worker (we timed out) # Then we only record it if it is successful. reporter.record(result) end if !requeued && failed queue.increment_test_failed end end end