Skip to content

Commit

Permalink
Print the actual file name and line number.
Browse files Browse the repository at this point in the history
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

yyamano committed Jan 16, 2017
1 parent b4c2ebd commit 058c366
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mrblib/mtest_unit.rb
Original file line number Diff line number Diff line change
@@ -412,16 +412,18 @@ def print *a
end

def puke klass, meth, e
# dirty hack to find the actual filename and line number that the assertion failed at
loc = e.backtrace.find(Proc.new {e.inspect}) {|l| !l.include?(':in MTest::')}
e = case e
when MTest::Skip
@skips += 1
"Skipped:\n#{meth}(#{klass}) #{e.inspect}\n"
"Skipped:\n#{meth}(#{klass}) #{loc}\n"
when MTest::Assertion
@failures += 1
"Failure:\n#{meth}(#{klass}) #{e.inspect}\n"
"Failure:\n#{meth}(#{klass}) #{loc}\n"
else
@errors += 1
"Error:\n#{meth}(#{klass}): #{e.class}, #{e.inspect}\n"
"Error:\n#{meth}(#{klass}): #{e.class}, #{loc}\n"
end
@report << e
e[0, 1]

0 comments on commit 058c366

Please sign in to comment.