1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/minitest/verbose_progress_plugin.rb
Will Jordan 24adaa095a
Support parallel tests in verbose progress reporting (#2223)
* Support parallel tests in verbose progress reporting
Reports correct duration and status for tests run in parallel threads.

* manually load verbose_progress minitest plugin
2020-04-20 09:45:43 +09:00

34 lines
936 B
Ruby

module Minitest
# Adds minimal support for parallel tests to the default verbose progress reporter.
def self.plugin_verbose_progress_init(options)
if options[:verbose]
self.reporter.reporters.
delete_if {|r| r.is_a?(ProgressReporter)}.
push(VerboseProgressReporter.new(options[:io], options))
end
end
# Verbose progress reporter that supports parallel test execution.
class VerboseProgressReporter < Reporter
def prerecord(klass, name)
@current ||= nil
@current = [klass.name, name].tap(&method(:print_start))
end
def record(result)
print_start [result.klass, result.name]
@current = nil
io.print "%.2f s = " % [result.time]
io.print result.result_code
io.puts
end
def print_start(test)
unless @current == test
io.puts '…' if @current
io.print "%s#%s = " % test
io.flush
end
end
end
end