From 5edbec17ec9f2dfb292ad81ee02fd20100e57c6b Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 7 Feb 2017 05:19:29 +0000 Subject: test/unit.rb: most-asserted * test/lib/test/unit.rb (Statistics#record): record most asserted tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/lib/test/unit.rb | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'test/lib') diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb index 9cad662250..03c56d825a 100644 --- a/test/lib/test/unit.rb +++ b/test/lib/test/unit.rb @@ -587,12 +587,22 @@ module Test end module Statistics + def update_list(list, rec, max) + if i = list.empty? ? 0 : list.bsearch_index {|*a| yield(*a)} + list[i, 0] = [rec] + list[max..-1] = [] if list.size >= max + end + end + def record(suite, method, assertions, time, error) - if max = @options[:longest] - longest = @longest ||= [] - if i = longest.empty? ? 0 : longest.bsearch_index {|_,_,_,t,_|t= max + if @options.values_at(:longest, :most_asserted).any? + @tops ||= {} + rec = [suite.name, method, assertions, time, error] + if max = @options[:longest] + update_list(@tops[:longest] ||= [], rec, max) {|_,_,_,t,_|t