class Minitest::Reporter
def self.synchronize # :nodoc:
def self.synchronize # :nodoc: if @mutex then # see parallel_each.rb @mutex.synchronize { yield } else yield end end
def initialize io = $stdout, options = {} # :nodoc:
def initialize io = $stdout, options = {} # :nodoc: self.io = io self.options = options self.assertions = 0 self.count = 0 self.results = [] self.start_time = nil end
def passed?
def passed? results.all?(&:skipped?) end
def record result
def record result self.count += 1 self.assertions += result.assertions io.print "%s#%s = %.2f s = " % [result.class, result.name, result.time] if options[:verbose] io.print result.result_code io.puts if options[:verbose] results << result if not result.passed? or result.skipped? end
def record result
def record result Reporter.synchronize do simple_record result end end
def report
def report aggregate = results.group_by { |r| r.failure.class } aggregate.default = [] # dumb. group_by should provide this f = aggregate[Assertion].size e = aggregate[UnexpectedError].size s = aggregate[Skip].size t = Time.now - start_time io.puts # finish the dots io.puts io.puts "Finished in %.6fs, %.4f runs/s, %.4f assertions/s." % [t, count / t, self.assertions / t] format = "%d runs, %d assertions, %d failures, %d errors, %d skips" summary = format % [count, self.assertions, f, e, s] filtered_results = results.dup filtered_results.reject!(&:skipped?) unless options[:verbose] filtered_results.each_with_index do |result, i| io.puts "\n%3d) %s" % [i+1, result] end io.puts io.puts summary io.sync = self.old_sync if self.sync end
def run_and_report
def run_and_report start yield report end
def start
def start self.sync = io.respond_to? :"sync=" # stupid emacs self.old_sync, io.sync = io.sync, true if self.sync self.start_time = Time.now io.puts "Run options: #{options[:args]}" io.puts io.puts "# Running:" io.puts end