[前][次][番号順一覧][スレッド一覧]

ruby-changes:60242

From: Koichi <ko1@a...>
Date: Sun, 1 Mar 2020 03:03:13 +0900 (JST)
Subject: [ruby-changes:60242] 413c98003b (master): show backtrace.

https://git.ruby-lang.org/ruby.git/commit/?id=413c98003b

From 413c98003bc936dd29e40aebad68b43fbe6a527f Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Sun, 1 Mar 2020 03:02:05 +0900
Subject: show backtrace.

assert_nothing_raised doesn't show the backtrace if an exception
is thrown in a block. This patch shows this backtrace.

diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index 39964d9..e5f741f 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -194,7 +194,11 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L194
           end
           if ((args.empty? && !as) ||
               args.any? {|a| a.instance_of?(Module) ? e.is_a?(a) : e.class == a })
-            msg = message(msg) { "Exception raised:\n<#{mu_pp(e)}>" }
+            msg = message(msg) {
+              "Exception raised:\n<#{mu_pp(e)}>\n" +
+              "Backtrace:\n" +
+              e.backtrace.map{|frame| "  #{frame}"}.join("\n")
+            }
             raise MiniTest::Assertion, msg.call, bt
           else
             raise
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]