mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
assertions.rb: show failed indexes
* test/lib/test/unit/assertions.rb (AllFailures): show indexes in total number of failure assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
50ec15d676
commit
1da4d51bf9
1 changed files with 7 additions and 3 deletions
|
@ -785,19 +785,23 @@ eom
|
||||||
attr_reader :failures
|
attr_reader :failures
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@count = 0
|
||||||
@failures = {}
|
@failures = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def for(key)
|
def for(key)
|
||||||
|
@count += 1
|
||||||
yield
|
yield
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@failures[key] = e
|
@failures[key] = [@count, e]
|
||||||
end
|
end
|
||||||
|
|
||||||
def message
|
def message
|
||||||
i = 0
|
i = 0
|
||||||
@failures.map {|k, v|
|
total = @count.to_s
|
||||||
"\n#{i+=1}. Assertion for #{k.inspect}\n#{v.message.gsub(/^/, ' | ')}"
|
fmt = "%#{total.size}d"
|
||||||
|
@failures.map {|k, (n, v)|
|
||||||
|
"\n#{i+=1}. [#{fmt%n}/#{total}] Assertion for #{k.inspect}\n#{v.message.gsub(/^/, ' | ')}"
|
||||||
}.join("\n")
|
}.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue