Skip to content

Commit 1f5d44a

Browse files
committed
Use current_exceptions() on Julia >= v1.7
Base.catch_stack() was deprecated in 1.7.
1 parent 4831b0f commit 1f5d44a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/testset.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ function scrub_exc_stack(stack)
4646
return Any[ (x[1], scrub_backtrace(x[2])) for x in stack ]
4747
end
4848

49+
# Compat for catch_stack(), which was deprecated in 1.7
50+
@static if VERSION < v"1.7"
51+
current_exceptions() = Base.catch_stack()
52+
end
53+
4954
mutable struct Format
5055
stats::Bool
5156
desc_align::Int
@@ -531,7 +536,7 @@ function testset_beginend(mod::Module, isfinal::Bool, pat::Pattern, id::Int64, d
531536
# something in the test block threw an error. Count that as an
532537
# error in this test set
533538
record(ts, Error(:nontest_error, Expr(:tuple), err,
534-
Base.catch_stack(), $(QuoteNode(source))))
539+
current_exceptions(), $(QuoteNode(source))))
535540
finally
536541
copy!(RNG, oldrng)
537542
setresult!($marks, ts.subject, !anyfailed(ts))
@@ -594,7 +599,7 @@ function testset_forloop(mod::Module, isfinal::Bool, pat::Pattern, id::Int64,
594599
err isa InterruptException && rethrow()
595600
# Something in the test block threw an error. Count that as an
596601
# error in this test set
597-
record(ts, Error(:nontest_error, Expr(:tuple), err, Base.catch_stack(), $(QuoteNode(source))))
602+
record(ts, Error(:nontest_error, Expr(:tuple), err, current_exceptions(), $(QuoteNode(source))))
598603
setresult!($marks, ts.subject, false)
599604
end
600605
end

0 commit comments

Comments
 (0)