Skip to content
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

Fixes for recent Julia versions #54

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
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
Loading