mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Enable "-f" option in multi_exec mode
Make `MultiFormatter` a module and extend the formatter specified by "-f" option.
This commit is contained in:
parent
19f91f7880
commit
fa52a924aa
Notes:
git
2019-11-05 17:42:58 +09:00
4 changed files with 34 additions and 12 deletions
|
@ -90,8 +90,7 @@ class MSpecMain < MSpecScript
|
|||
|
||||
def multi_exec(argv)
|
||||
require 'mspec/runner/formatters/multi'
|
||||
formatter = MultiFormatter.new
|
||||
warn "formatter options is ignored due to multi option" if config[:formatter]
|
||||
formatter = config_formatter.extend(MultiFormatter)
|
||||
|
||||
require 'mspec/runner/parallel'
|
||||
processes = cores(@files.size)
|
||||
|
|
|
@ -97,6 +97,16 @@ class DottedFormatter
|
|||
end
|
||||
end
|
||||
|
||||
# Callback for the MSpec :start event. Calls :after event.
|
||||
def start
|
||||
after
|
||||
end
|
||||
|
||||
# Callback for the MSpec :unload event. Calls :after event.
|
||||
def unload
|
||||
after
|
||||
end
|
||||
|
||||
# Callback for the MSpec :finish event. Prints a description
|
||||
# and backtrace for every exception that occurred while
|
||||
# evaluating the examples.
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
require 'mspec/runner/formatters/spinner'
|
||||
module MultiFormatter
|
||||
def self.extend_object(obj)
|
||||
super
|
||||
obj.multi_initialize
|
||||
end
|
||||
|
||||
class MultiFormatter < SpinnerFormatter
|
||||
def initialize(out=nil)
|
||||
super(out)
|
||||
def multi_initialize
|
||||
@counter = @tally = Tally.new
|
||||
@timer = TimerAction.new
|
||||
@timer.start
|
||||
end
|
||||
|
||||
def register
|
||||
super
|
||||
|
||||
MSpec.register :start, self
|
||||
MSpec.register :unload, self
|
||||
MSpec.unregister :before, self
|
||||
end
|
||||
|
||||
def aggregate_results(files)
|
||||
require 'yaml'
|
||||
|
||||
|
|
|
@ -125,12 +125,7 @@ class MSpecScript
|
|||
require 'mspec/runner/formatters/file'
|
||||
require 'mspec/runner/filters'
|
||||
|
||||
if config[:formatter].nil?
|
||||
config[:formatter] = STDOUT.tty? ? SpinnerFormatter : @files.size < 50 ? DottedFormatter : FileFormatter
|
||||
end
|
||||
|
||||
if config[:formatter]
|
||||
formatter = config[:formatter].new(config[:output])
|
||||
if formatter = config_formatter
|
||||
formatter.register
|
||||
MSpec.store :formatter, formatter
|
||||
end
|
||||
|
@ -149,6 +144,14 @@ class MSpecScript
|
|||
custom_register
|
||||
end
|
||||
|
||||
# Makes a formatter specified by :formatter option.
|
||||
def config_formatter
|
||||
if config[:formatter].nil?
|
||||
config[:formatter] = STDOUT.tty? ? SpinnerFormatter : @files.size < 50 ? DottedFormatter : FileFormatter
|
||||
end
|
||||
config[:formatter].new(config[:output])
|
||||
end
|
||||
|
||||
# Callback for enabling custom actions, etc. This version is a
|
||||
# no-op. Provide an implementation specific version in a config
|
||||
# file. Called by #register.
|
||||
|
|
Loading…
Add table
Reference in a new issue