1 require_relative '../spec_helper'
3 describe "The --backtrace-limit command line option" do
4 ruby_version_is ""..."3.4" do
5 it "limits top-level backtraces to a given number of entries" do
6 file = fixture(__FILE__ , "backtrace.rb")
7 out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1)
8 out = out.gsub(__dir__, '')
12 /fixtures/backtrace.rb:2:in `a': oops (RuntimeError)
13 \tfrom /fixtures/backtrace.rb:6:in `b'
14 \tfrom /fixtures/backtrace.rb:10:in `c'
19 it "affects Exception#full_message" do
20 file = fixture(__FILE__ , "backtrace.rb")
21 out = ruby_exe(file, options: "--backtrace-limit=2", args: "full_message 2>&1")
22 out = out.gsub(__dir__, '')
26 /fixtures/backtrace.rb:2:in `a': oops (RuntimeError)
27 \tfrom /fixtures/backtrace.rb:6:in `b'
28 \tfrom /fixtures/backtrace.rb:10:in `c'
33 it "does not affect Exception#backtrace" do
34 file = fixture(__FILE__ , "backtrace.rb")
35 out = ruby_exe(file, options: "--backtrace-limit=2", args: "backtrace 2>&1")
36 out = out.gsub(__dir__, '')
40 /fixtures/backtrace.rb:2:in `a'
41 /fixtures/backtrace.rb:6:in `b'
42 /fixtures/backtrace.rb:10:in `c'
43 /fixtures/backtrace.rb:14:in `d'
44 /fixtures/backtrace.rb:29:in `<main>'
49 ruby_version_is "3.4" do
50 it "limits top-level backtraces to a given number of entries" do
51 file = fixture(__FILE__ , "backtrace.rb")
52 out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1)
53 out = out.gsub(__dir__, '')
57 /fixtures/backtrace.rb:2:in 'Object#a': oops (RuntimeError)
58 \tfrom /fixtures/backtrace.rb:6:in 'Object#b'
59 \tfrom /fixtures/backtrace.rb:10:in 'Object#c'
64 it "affects Exception#full_message" do
65 file = fixture(__FILE__ , "backtrace.rb")
66 out = ruby_exe(file, options: "--backtrace-limit=2", args: "full_message 2>&1")
67 out = out.gsub(__dir__, '')
71 /fixtures/backtrace.rb:2:in 'Object#a': oops (RuntimeError)
72 \tfrom /fixtures/backtrace.rb:6:in 'Object#b'
73 \tfrom /fixtures/backtrace.rb:10:in 'Object#c'
78 it "does not affect Exception#backtrace" do
79 file = fixture(__FILE__ , "backtrace.rb")
80 out = ruby_exe(file, options: "--backtrace-limit=2", args: "backtrace 2>&1")
81 out = out.gsub(__dir__, '')
85 /fixtures/backtrace.rb:2:in 'Object#a'
86 /fixtures/backtrace.rb:6:in 'Object#b'
87 /fixtures/backtrace.rb:10:in 'Object#c'
88 /fixtures/backtrace.rb:14:in 'Object#d'
89 /fixtures/backtrace.rb:29:in '<main>'