Merge pull request #52141 from MaxLap/fix_log_causes_ruby_head
Fixes tests with nested exception backtraces on Ruby master
This commit is contained in:
commit
98636b3a78
@ -45,15 +45,26 @@ def method_that_raises
|
|||||||
end
|
end
|
||||||
|
|
||||||
def raise_nested_exceptions
|
def raise_nested_exceptions
|
||||||
raise "First error"
|
raise_nested_exceptions_third
|
||||||
rescue
|
|
||||||
begin
|
|
||||||
raise "Second error"
|
|
||||||
rescue
|
|
||||||
raise "Third error"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def raise_nested_exceptions_first
|
||||||
|
raise "First error"
|
||||||
|
end
|
||||||
|
|
||||||
|
def raise_nested_exceptions_second
|
||||||
|
raise_nested_exceptions_first
|
||||||
|
rescue
|
||||||
|
raise "Second error"
|
||||||
|
end
|
||||||
|
|
||||||
|
def raise_nested_exceptions_third
|
||||||
|
raise_nested_exceptions_second
|
||||||
|
rescue
|
||||||
|
raise "Third error"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
env["action_dispatch.show_detailed_exceptions"] = @detailed
|
env["action_dispatch.show_detailed_exceptions"] = @detailed
|
||||||
req = ActionDispatch::Request.new(env)
|
req = ActionDispatch::Request.new(env)
|
||||||
@ -641,29 +652,67 @@ def self.build_app(app, *args)
|
|||||||
Information for: RuntimeError (Third error):
|
Information for: RuntimeError (Third error):
|
||||||
MSG
|
MSG
|
||||||
|
|
||||||
assert_match Regexp.new(<<~REGEX.strip), paragraphs[2].lines[0..2].join
|
if RUBY_VERSION >= "3.4"
|
||||||
\\A.*in `rescue in rescue in raise_nested_exceptions'
|
# Changes to the format of exception backtraces
|
||||||
.*in `rescue in raise_nested_exceptions'
|
# https://bugs.ruby-lang.org/issues/16495 (use single quote instead of backtrace)
|
||||||
.*in `raise_nested_exceptions'
|
# https://bugs.ruby-lang.org/issues/20275 (don't have entry for rescue in)
|
||||||
REGEX
|
# And probably more, they now show the class too
|
||||||
|
assert_match Regexp.new(<<~REGEX.strip), paragraphs[2]
|
||||||
|
\\A.*in '.*raise_nested_exceptions_third'
|
||||||
|
.*in '.*raise_nested_exceptions'
|
||||||
|
REGEX
|
||||||
|
|
||||||
assert_includes(paragraphs[3], <<~MSG.strip)
|
assert_includes(paragraphs[3], <<~MSG.strip)
|
||||||
Information for cause: RuntimeError (Second error):
|
Information for cause: RuntimeError (Second error):
|
||||||
MSG
|
MSG
|
||||||
|
|
||||||
assert_match Regexp.new(<<~REGEX.strip), paragraphs[4].lines[0..1].join
|
assert_match Regexp.new(<<~REGEX.strip), paragraphs[4]
|
||||||
\\A.*in `rescue in raise_nested_exceptions'
|
\\A.*in '.*raise_nested_exceptions_second'
|
||||||
.*in `raise_nested_exceptions'
|
.*in '.*raise_nested_exceptions_third'
|
||||||
REGEX
|
.*in '.*raise_nested_exceptions'
|
||||||
|
REGEX
|
||||||
|
|
||||||
|
|
||||||
assert_includes(paragraphs[5], <<~MSG.strip)
|
assert_includes(paragraphs[5], <<~MSG.strip)
|
||||||
Information for cause: RuntimeError (First error):
|
Information for cause: RuntimeError (First error):
|
||||||
MSG
|
MSG
|
||||||
|
|
||||||
assert_match Regexp.new(<<~REGEX.strip), paragraphs[6].lines[0]
|
assert_match Regexp.new(<<~REGEX.strip), paragraphs[6]
|
||||||
\\A.*in `raise_nested_exceptions'
|
\\A.*in '.*raise_nested_exceptions_first'
|
||||||
REGEX
|
.*in '.*raise_nested_exceptions_second'
|
||||||
|
.*in '.*raise_nested_exceptions_third'
|
||||||
|
.*in '.*raise_nested_exceptions'
|
||||||
|
REGEX
|
||||||
|
else
|
||||||
|
assert_match Regexp.new(<<~REGEX.strip), paragraphs[2]
|
||||||
|
\\A.*in `rescue in raise_nested_exceptions_third'
|
||||||
|
.*in `raise_nested_exceptions_third'
|
||||||
|
.*in `raise_nested_exceptions'
|
||||||
|
REGEX
|
||||||
|
|
||||||
|
assert_includes(paragraphs[3], <<~MSG.strip)
|
||||||
|
Information for cause: RuntimeError (Second error):
|
||||||
|
MSG
|
||||||
|
|
||||||
|
assert_match Regexp.new(<<~REGEX.strip), paragraphs[4]
|
||||||
|
\\A.*in `rescue in raise_nested_exceptions_second'
|
||||||
|
.*in `raise_nested_exceptions_second'
|
||||||
|
.*in `raise_nested_exceptions_third'
|
||||||
|
.*in `raise_nested_exceptions'
|
||||||
|
REGEX
|
||||||
|
|
||||||
|
|
||||||
|
assert_includes(paragraphs[5], <<~MSG.strip)
|
||||||
|
Information for cause: RuntimeError (First error):
|
||||||
|
MSG
|
||||||
|
|
||||||
|
assert_match Regexp.new(<<~REGEX.strip), paragraphs[6]
|
||||||
|
\\A.*in `raise_nested_exceptions_first'
|
||||||
|
.*in `raise_nested_exceptions_second'
|
||||||
|
.*in `raise_nested_exceptions_third'
|
||||||
|
.*in `raise_nested_exceptions'
|
||||||
|
REGEX
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "display backtrace when error type is SyntaxError" do
|
test "display backtrace when error type is SyntaxError" do
|
||||||
@ -783,28 +832,28 @@ def self.build_app(app, *args)
|
|||||||
# Possible Ruby 3.4-dev bug: https://bugs.ruby-lang.org/issues/19117#note-45
|
# Possible Ruby 3.4-dev bug: https://bugs.ruby-lang.org/issues/19117#note-45
|
||||||
# assert application trace refers to line that raises the last exception
|
# assert application trace refers to line that raises the last exception
|
||||||
assert_select "#Application-Trace-0" do
|
assert_select "#Application-Trace-0" do
|
||||||
assert_select "code a:first", %r{in '.*raise_nested_exceptions'}
|
assert_select "code a:first", %r{in '.*raise_nested_exceptions_third'}
|
||||||
end
|
end
|
||||||
|
|
||||||
# assert the second application trace refers to the line that raises the second exception
|
# assert the second application trace refers to the line that raises the second exception
|
||||||
assert_select "#Application-Trace-1" do
|
assert_select "#Application-Trace-1" do
|
||||||
assert_select "code a:first", %r{in '.*raise_nested_exceptions'}
|
assert_select "code a:first", %r{in '.*raise_nested_exceptions_second'}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# assert application trace refers to line that raises the last exception
|
# assert application trace refers to line that raises the last exception
|
||||||
assert_select "#Application-Trace-0" do
|
assert_select "#Application-Trace-0" do
|
||||||
assert_select "code a:first", %r{in [`']rescue in rescue in .*raise_nested_exceptions'}
|
assert_select "code a:first", %r{in [`']rescue in .*raise_nested_exceptions_third'}
|
||||||
end
|
end
|
||||||
|
|
||||||
# assert the second application trace refers to the line that raises the second exception
|
# assert the second application trace refers to the line that raises the second exception
|
||||||
assert_select "#Application-Trace-1" do
|
assert_select "#Application-Trace-1" do
|
||||||
assert_select "code a:first", %r{in [`']rescue in .*raise_nested_exceptions'}
|
assert_select "code a:first", %r{in [`']rescue in .*raise_nested_exceptions_second'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# assert the third application trace refers to the line that raises the first exception
|
# assert the third application trace refers to the line that raises the first exception
|
||||||
assert_select "#Application-Trace-2" do
|
assert_select "#Application-Trace-2" do
|
||||||
assert_select "code a:first", %r{in [`'].*raise_nested_exceptions'}
|
assert_select "code a:first", %r{in [`'].*raise_nested_exceptions_first'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user