Permalink
Browse files

Merge branch 'master' into upgrade_to_4

Conflicts:
	lib/minitest/display.rb
  • Loading branch information...
2 parents 66a8173 + fadb57b commit c2e7dd9aae6d66997a88501982388295a7f76456 @quirkey committed Dec 8, 2012
Showing with 21 additions and 9 deletions.
  1. +21 −9 lib/minitest/display.rb
View
30 lib/minitest/display.rb
@@ -29,6 +29,7 @@ def options
:color => true,
:wrap_at => 80,
:output_slow => 5,
+ :output_slow_suites => 5,
:print => {
:success => '.',
:failure => 'F',
@@ -137,9 +138,9 @@ def _run_suite(suite, type)
wrap_count = wrap_at
full_start_time = Time.now
- @test_times ||= []
- # END
+ @test_times ||= Hash.new { |h, k| h[k] = [] }
+ #END
assertions = suite.send("#{type}_methods").grep(filter).map { |method|
inst = suite.new method
inst._assertions = 0
@@ -153,7 +154,7 @@ def _run_suite(suite, type)
# PATCH
time = Time.now - start_time
- @test_times << ["#{suite}##{method}", time]
+ @test_times[suite] << ["#{suite}##{method}", time]
print "%.2f s = " % time if @verbose
print case result
@@ -195,12 +196,23 @@ def status(io = self.output)
end
io.puts display.color(format % [test_count, assertion_count, failures, errors, skips], final_status)
- if display.options[:output_slow]
- @test_times.sort! {|a, b| b[1] <=> a[1] }
- puts "Slowest tests:"
- @test_times[0..display.options[:output_slow].to_i].each do |test_name, time|
- puts "%.2f s\t#{test_name}" % time
- end
+ display_slow_tests if display.options[:output_slow]
+ display_slow_suites if display.options[:output_slow_suites]
+ end
+
+ def display_slow_tests
+ times = @test_times.values.flatten(1).sort { |a, b| b[1] <=> a[1] }
+ puts "Slowest tests:"
+ times[0..display.options[:output_slow].to_i].each do |test_name, time|
+ puts "%.2f s\t#{test_name}" % time
+ end
+ end
+
+ def display_slow_suites
+ times = @test_times.map { |suite, tests| [suite, tests.map(&:last).sum] }.sort { |a, b| b[1] <=> a[1] }
+ puts "Slowest suites:"
+ times[0..display.options[:output_slow_suites].to_i].each do |suite, time|
+ puts "%.2f s\t#{suite}" % time
end
end

0 comments on commit c2e7dd9

Please sign in to comment.