mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
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
This commit is contained in:
parent
ec2cda3faa
commit
24adaa095a
4 changed files with 41 additions and 0 deletions
|
@ -42,6 +42,7 @@
|
|||
* Update `Rack::Handler::Puma.run` to use `**options` (#2189)
|
||||
* ThreadPool concurrency refactoring (#2220)
|
||||
* JSON parse cluster worker stats instead of regex (#2124)
|
||||
* Support parallel tests in verbose progress reporting (#2223)
|
||||
|
||||
## 4.3.3 and 3.12.4 / 2020-02-28
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ if %w(2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1).include? RUBY_VERSION
|
|||
end
|
||||
end
|
||||
|
||||
require_relative "minitest/verbose"
|
||||
require "minitest/autorun"
|
||||
require "minitest/pride"
|
||||
require "minitest/proveit"
|
||||
|
|
5
test/minitest/verbose.rb
Normal file
5
test/minitest/verbose.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require "minitest"
|
||||
require_relative "verbose_progress_plugin"
|
||||
|
||||
Minitest.load_plugins
|
||||
Minitest.extensions << 'verbose_progress' unless Minitest.extensions.include?('verbose_progress')
|
34
test/minitest/verbose_progress_plugin.rb
Normal file
34
test/minitest/verbose_progress_plugin.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
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
|
Loading…
Reference in a new issue