From 1f5d44ac0602341c095e4d2c5e8df47b7044625a Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Thu, 21 Dec 2023 00:04:47 +0100 Subject: [PATCH 1/2] Use current_exceptions() on Julia >= v1.7 Base.catch_stack() was deprecated in 1.7. --- src/testset.jl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/testset.jl b/src/testset.jl index 9d12c00..80b6e25 100644 --- a/src/testset.jl +++ b/src/testset.jl @@ -46,6 +46,11 @@ function scrub_exc_stack(stack) return Any[ (x[1], scrub_backtrace(x[2])) for x in stack ] end +# Compat for catch_stack(), which was deprecated in 1.7 +@static if VERSION < v"1.7" + current_exceptions() = Base.catch_stack() +end + mutable struct Format stats::Bool desc_align::Int @@ -531,7 +536,7 @@ function testset_beginend(mod::Module, isfinal::Bool, pat::Pattern, id::Int64, d # something in the test block threw an error. Count that as an # error in this test set record(ts, Error(:nontest_error, Expr(:tuple), err, - Base.catch_stack(), $(QuoteNode(source)))) + current_exceptions(), $(QuoteNode(source)))) finally copy!(RNG, oldrng) setresult!($marks, ts.subject, !anyfailed(ts)) @@ -594,7 +599,7 @@ function testset_forloop(mod::Module, isfinal::Bool, pat::Pattern, id::Int64, err isa InterruptException && rethrow() # Something in the test block threw an error. Count that as an # error in this test set - record(ts, Error(:nontest_error, Expr(:tuple), err, Base.catch_stack(), $(QuoteNode(source)))) + record(ts, Error(:nontest_error, Expr(:tuple), err, current_exceptions(), $(QuoteNode(source)))) setresult!($marks, ts.subject, false) end end From b6c073aca875be9d935451df293433ce141591e5 Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Thu, 21 Dec 2023 00:05:52 +0100 Subject: [PATCH 2/2] Fix stats feature on 1.9 and later In v1.9, Base.cumulative_compile_time_ns() was changed to return a tuple of `(compile_time, recompile_time)`. We now use the sum of the two to show the total compilation time. --- src/testset.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/testset.jl b/src/testset.jl index 80b6e25..f3b677b 100644 --- a/src/testset.jl +++ b/src/testset.jl @@ -672,9 +672,13 @@ macro stats(yes, ex) end end -cumulative_compile_time_ns() = - isdefined(Base, :cumulative_compile_time_ns) ? +@static if VERSION >= v"1.9" + # In 1.9 this function was changed to return a tuple of (compile_time, recompilation_time) + cumulative_compile_time_ns() = sum(Base.cumulative_compile_time_ns()) +else + cumulative_compile_time_ns() = isdefined(Base, :cumulative_compile_time_ns) ? Base.cumulative_compile_time_ns() : UInt(0) +end end # module