Skip to content

Also trigger breakpoint on testset error #44652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/rtutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,11 @@ JL_DLLEXPORT void jl_breakpoint(jl_value_t *v)
// put a breakpoint in your debugger here
}

JL_DLLEXPORT void jl_test_failure_breakpoint(jl_value_t *v)
{
// put a breakpoint in your debugger here
}

// logging tools --------------------------------------------------------------

void jl_log(int level, jl_value_t *module, jl_value_t *group, jl_value_t *id,
Expand Down
7 changes: 6 additions & 1 deletion stdlib/Test/src/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ function do_test(result::ExecutionResult, orig_expr)
@assert isa(result, Threw)
testres = Error(:test_error, orig_expr, result.exception, result.backtrace::Vector{Any}, result.source)
end
isa(testres, Pass) || ccall(:jl_breakpoint, Cvoid, (Any,), result)
isa(testres, Pass) || trigger_test_failure_break(result)
record(get_testset(), testres)
end

Expand Down Expand Up @@ -1317,6 +1317,9 @@ macro testset(args...)
end
end

trigger_test_failure_break(@nospecialize(err)) =
ccall(:jl_test_failure_breakpoint, Cvoid, (Any,), err)

"""
Generate the code for a `@testset` with a function call or `begin`/`end` argument
"""
Expand Down Expand Up @@ -1360,6 +1363,7 @@ function testset_beginend_call(args, tests, source)
err isa InterruptException && rethrow()
# something in the test block threw an error. Count that as an
# error in this test set
trigger_test_failure_break(err)
record(ts, Error(:nontest_error, Expr(:tuple), err, Base.current_exceptions(), $(QuoteNode(source))))
finally
copy!(RNG, oldrng)
Expand Down Expand Up @@ -1435,6 +1439,7 @@ function testset_forloop(args, testloop, source)
err isa InterruptException && rethrow()
# Something in the test block threw an error. Count that as an
# error in this test set
trigger_test_failure_break(err)
record(ts, Error(:nontest_error, Expr(:tuple), err, Base.current_exceptions(), $(QuoteNode(source))))
end
end
Expand Down