Skip to content

Commit 351d0d8

Browse files
authored
Merge pull request #54 from JamesWrigley/latest-fixes
Fixes for recent Julia versions
2 parents 4831b0f + b6c073a commit 351d0d8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/testset.jl

Lines changed: 13 additions & 4 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
@@ -667,9 +672,13 @@ macro stats(yes, ex)
667672
end
668673
end
669674

670-
cumulative_compile_time_ns() =
671-
isdefined(Base, :cumulative_compile_time_ns) ?
675+
@static if VERSION >= v"1.9"
676+
# In 1.9 this function was changed to return a tuple of (compile_time, recompilation_time)
677+
cumulative_compile_time_ns() = sum(Base.cumulative_compile_time_ns())
678+
else
679+
cumulative_compile_time_ns() = isdefined(Base, :cumulative_compile_time_ns) ?
672680
Base.cumulative_compile_time_ns() :
673681
UInt(0)
682+
end
674683

675684
end # module

0 commit comments

Comments
 (0)