Skip to content

Commit

Permalink
Also trigger breakpoint on testset error (#44652)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno authored Mar 21, 2022
1 parent 32b1305 commit cf999af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit cf999af

Please sign in to comment.