Skip to content

Commit

Permalink
Merge pull request #54 from JamesWrigley/latest-fixes
Browse files Browse the repository at this point in the history
Fixes for recent Julia versions
  • Loading branch information
JamesWrigley authored Sep 9, 2024
2 parents 4831b0f + b6c073a commit 351d0d8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/testset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -667,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

0 comments on commit 351d0d8

Please sign in to comment.