From 201d50164016bc519041af302f47d92f314abac5 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 30 Sep 2020 12:21:48 +0200 Subject: Update to ruby/spec@9277d27 --- spec/ruby/core/exception/top_level_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'spec/ruby/core/exception') diff --git a/spec/ruby/core/exception/top_level_spec.rb b/spec/ruby/core/exception/top_level_spec.rb index 96f957411e..97a91b0a58 100644 --- a/spec/ruby/core/exception/top_level_spec.rb +++ b/spec/ruby/core/exception/top_level_spec.rb @@ -5,6 +5,31 @@ describe "An Exception reaching the top level" do ruby_exe('raise "foo"', args: "2>&1").should.include?("in `
': foo (RuntimeError)") end + ruby_version_is "2.6" do + it "the Exception#cause is printed to STDERR with backtraces" do + code = <<-RUBY + def raise_cause + raise "the cause" + end + def raise_wrapped + raise "wrapped" + end + begin + raise_cause + rescue + raise_wrapped + end + RUBY + lines = ruby_exe(code, args: "2>&1").lines + lines.reject! { |l| l.include?('rescue in') } + lines.map! { |l| l.split(':')[2..-1].join(':').chomp } + lines.should == ["in `raise_wrapped': wrapped (RuntimeError)", + "in `
'", + "in `raise_cause': the cause (RuntimeError)", + "in `
'"] + end + end + describe "with a custom backtrace" do it "is printed on STDERR" do code = <<-RUBY -- cgit v1.2.3