ruby-changes:65265
From: Nobuyoshi <ko1@a...>
Date: Mon, 15 Feb 2021 18:29:57 +0900 (JST)
Subject: [ruby-changes:65265] 522b256689 (master): Added tests for --backtrace-limit option
https://git.ruby-lang.org/ruby.git/commit/?id=522b256689 From 522b25668979892b10c71109a2520b300d57cb8c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 15 Feb 2021 15:55:58 +0900 Subject: Added tests for --backtrace-limit option --- test/ruby/test_rubyoptions.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index d860bf4..08f9e98 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -66,6 +66,18 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L66 end end + def test_backtrace_limit + assert_in_out_err(%w(--backtrace-limit), "", [], /missing argument for --backtrace-limit/) + assert_in_out_err(%w(--backtrace-limit= 1), "", [], /missing argument for --backtrace-limit/) + assert_in_out_err(%w(--backtrace-limit=-1), "", [], /wrong limit for backtrace length/) + code = 'def f(n);n > 0 ? f(n-1) : raise;end;f(5)' + assert_in_out_err(%w(--backtrace-limit=1), code, [], + [/.*unhandled exception\n/, /^\tfrom .*\n/, + /^\t \.{3} \d+ levels\.{3}\n/]) + assert_in_out_err(%w(--backtrace-limit=3), code, [], + [/.*unhandled exception\n/, *[/^\tfrom .*\n/]*3, + /^\t \.{3} \d+ levels\.{3}\n/]) + end def test_warning save_rubyopt = ENV['RUBYOPT'] -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/