Skip to content

Commit

Permalink
Fixup r"" in Log message handle_message testset
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed Jan 15, 2025
1 parent e9374b1 commit ca943e2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/corelogging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,17 @@ end
end
end
@testset "Log message handle_message exception handling" begin
# Exceptions in log handling (printing) of msg are caught by default
# Exceptions in log handling (printing) of msg are caught by default.
struct Foo end
Base.show(::IO, ::Foo) = 1 ÷ 0

@test_warn r"Error: Exception while generating log record in module Main at.*DivideError: integer division error" @info Foo()
# We cannot use `@test_logs` here, since test_logs does not actually _print_ the message
# (i.e. it does not invoke handle_message). To test exception handling during printing,
# we have to use `@test_warn` to see what was printed.
@test_warn r"Error: Exception while generating log record in module .*DivideError: integer division error"s @info Foo()

# Exceptions in log handling (printing) of attributes are caught by default
out = capture_stderr() do
@info "foo" x=Foo()
end
@test occursin("Error: Exception while generating log record in module Main at", out)
@test occursin("DivideError: integer division error", out)
@test_warn r"Error: Exception while generating log record in module .*DivideError: integer division error"s @info "foo" x=Foo()
end

@testset "Special keywords" begin
Expand Down

0 comments on commit ca943e2

Please sign in to comment.