Skip to content

Commit

Permalink
Revert "Output logs when not inside a testset"
Browse files Browse the repository at this point in the history
This reverts commit 9684fb8.
  • Loading branch information
mmcgr committed Jul 14, 2023
1 parent c1a6bed commit 1878486
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions src/testrel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,8 @@ function _test_rel_steps(;
test_engine = user_engine === nothing ? get_test_engine() : user_engine
@debug("$name: using test engine: $test_engine")

# Output logs directly if we're nested inside a concurrent RAITestSet or a standard
# TestSet
capture_logs = nested || Test.get_testset_depth() > 0
if capture_logs
logger = TestLogger(; catch_exceptions=true)
else
logger = Base.current_logger()
end
logger = TestLogger(; catch_exceptions=true)

try
stats = @timed Logging.with_logger(logger) do
@testset TestRelTestSet nested = nested "$name" begin
Expand All @@ -427,26 +421,24 @@ function _test_rel_steps(;
end
duration = sprint(show, stats.time; context=:compact => true)
ts = stats.value

if capture_logs
ts.logs = logger.logs
check_flaky(name, logger.logs)

log_header = get_log_header(ts, duration, schema, test_engine)
if anyerror(ts) || anyfail(ts)
ts.error_message = log_header
io, ctx = get_logging_io()
write(ctx, log_header)
write(ctx, "\n\nCAPTURED LOGS:\n")
playback_log.(ctx, logger.logs)
msg = String(take!(io))
@error msg database = schema engine_name = test_engine
else
@info log_header
end
ts.logs = logger.logs

check_flaky(name, logger.logs)

log_header = get_log_header(ts, duration, schema, test_engine)
if anyerror(ts) || anyfail(ts)
ts.error_message = log_header
io, ctx = get_logging_io()
write(ctx, log_header)
write(ctx, "\n\nCAPTURED LOGS:\n")
playback_log.(ctx, logger.logs)
msg = String(take!(io))
@error msg database = schema engine_name = test_engine
else
@info log_header
end

return ts
ts
catch err
io, ctx = get_logging_io()
write(ctx, "[ERROR] Something went wrong running test $name \n\n CAPTURED LOGS:\n")
Expand Down

0 comments on commit 1878486

Please sign in to comment.