diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-07 02:49:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-07 02:49:04 +0000 |
commit | 10c51ff5ce07c4c0bf72bdcfe65cc222a83e9369 (patch) | |
tree | 2a9956d17f2c60e354ca4ef74ed3a2d8a6d3d723 /test/lib | |
parent | ad57f92f5c51a1f3c5bd21e9416a8c98b7ce7760 (diff) | |
download | ruby-10c51ff5ce07c4c0bf72bdcfe65cc222a83e9369.tar.gz |
test/unit.rb: statistics
* test/lib/test/unit.rb (Test::Unit::Statistics): show statistics.
only --longest option is implemented right now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/test/unit.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb index f3aff4ee8c..981c1c1f2f 100644 --- a/test/lib/test/unit.rb +++ b/test/lib/test/unit.rb @@ -573,6 +573,39 @@ module Test end end + module Statistics + def record(suite, method, assertions, time, error) + if max = @options[:longest] + longest = @longest ||= [] + if i = longest.empty? ? 0 : longest.bsearch_index {|_,_,_,t,_|t<time} + longest[i, 0] = [[suite.name, method, assertions, time, error]] + longest[max..-1] = [] if longest.size >= max + end + end + # (((@record ||= {})[suite] ||= {})[method]) = [assertions, time, error] + super + end + + def run(*args) + result = super + if @longest + @longest.each {|suite, method, assertions, time, error| + printf "%5.2fsec(%d): %s#%s\n", time, assertions, suite, method + } + end + result + end + + private + def setup_options(opts, options) + super + opts.separator "statistics options:" + opts.on '--longest=N', Integer, 'Show longest N tests' do |n| + options[:longest] = n + end + end + end + module StatusLine # :nodoc: all def terminal_width unless @terminal_width ||= nil @@ -988,6 +1021,7 @@ module Test include Test::Unit::Options include Test::Unit::StatusLine include Test::Unit::Parallel + include Test::Unit::Statistics include Test::Unit::Skipping include Test::Unit::GlobOption include Test::Unit::RepeatOption |