summaryrefslogtreecommitdiffhomepage
path: root/test/assert.rb
diff options
context:
space:
mode:
authortake_cheeze <[email protected]>2014-07-19 22:33:13 +0900
committertake_cheeze <[email protected]>2014-07-19 22:33:13 +0900
commita24729044acffa7b6d7a34387adb7e18db65288c (patch)
tree9edd451920287f3cdbcb9d6e1769ea79217b492a /test/assert.rb
parentd17506c176ef6d1ac70e84664790cdb1cb2cf3de (diff)
downloadmruby-a24729044acffa7b6d7a34387adb7e18db65288c.tar.gz
mruby-a24729044acffa7b6d7a34387adb7e18db65288c.zip
Print backtrace of crashed test in verbose mode.
Diffstat (limited to 'test/assert.rb')
-rw-r--r--test/assert.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/assert.rb b/test/assert.rb
index a4ee00299..72e4d3b37 100644
--- a/test/assert.rb
+++ b/test/assert.rb
@@ -21,7 +21,7 @@ end
##
# Create the assertion in a readable way
-def assertion_string(err, str, iso=nil, e=nil)
+def assertion_string(err, str, iso=nil, e=nil, bt=nil)
msg = "#{err}#{str}"
msg += " [#{iso}]" if iso && iso != ''
msg += " => #{e.message}" if e
@@ -31,6 +31,7 @@ def assertion_string(err, str, iso=nil, e=nil)
msg += "\n - Assertion[#{idx}] Failed: #{str}\n#{diff}"
end
end
+ msg += "\nbacktrace:\n\t#{bt.join("\n\t")}" if bt
msg
end
@@ -56,11 +57,12 @@ def assert(str = 'Assertion failed', iso = '')
t_print('.')
end
rescue Exception => e
+ bt = e.backtrace if $mrbtest_verbose
if e.class.to_s == 'MRubyTestSkip'
$asserts.push "Skip: #{str} #{iso} #{e.cause}"
t_print('?')
else
- $asserts.push(assertion_string("#{e.class}: ", str, iso, e))
+ $asserts.push(assertion_string("#{e.class}: ", str, iso, e, bt))
$kill_test += 1
t_print('X')
end