From 50f38e6e74bb0b2556957a76e8d2442c0f9b013a Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Fri, 5 Jul 2024 09:44:19 -0500 Subject: [PATCH] Reorder invalidation tests (#388) On Julia 1.11, the impact of redefining `throw_boundserror` seems much larger, and it breaks later tests. Defer this until the end. --- test/snoop_invalidations.jl | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/test/snoop_invalidations.jl b/test/snoop_invalidations.jl index 8efbd629..79558dbb 100644 --- a/test/snoop_invalidations.jl +++ b/test/snoop_invalidations.jl @@ -220,20 +220,6 @@ end @test occursin(r"deleting Float64\(::Irrational{:twoπ}\).*invalidated:\n.*mt_disable: MethodInstance for Float64\(::Irrational{:twoπ}\)", str) @test occursin(r"deleting Float32\(::Irrational{:twoπ}\).*invalidated:\n.*mt_disable: MethodInstance for Float32\(::Irrational{:twoπ}\)", str) @test occursin(r"deleting BigFloat\(::Irrational{:twoπ}; precision\).*invalidated:\n.*backedges: 1: .*with MethodInstance for BigFloat\(::Irrational{:twoπ}\) \(1 children\)", str) - # #268 - invs = @snoop_invalidations begin - @eval Module() begin - @noinline Base.throw_boundserror(A, I) = throw(BoundsError(A, I)) - end - end - trees = invalidation_trees(invs) - show(io, trees) - lines = split(String(take!(io)), '\n') - idx = findfirst(str -> occursin("mt_disable", str), lines) - if idx !== nothing - @test occursin("throw_boundserror", lines[idx]) - @test occursin(r"\+\d+ more", lines[idx+1]) - end # Exclusion of Core.Compiler methods invs = @snoop_invalidations (::Type{T})(x::SnooprTests.MyInt) where T<:Integer = T(x.x) @@ -277,3 +263,20 @@ end Pkg.activate(cproj) end + +# This needs to come after "Delayed invalidations", as redefining `throw_boundserror` invalidates a lot of stuff +@testset "throw_boundserror" begin + # #268 + invs = @snoop_invalidations begin + @eval Module() begin + @noinline Base.throw_boundserror(A, I) = throw(BoundsError(A, I)) + end + end + trees = invalidation_trees(invs) + lines = split(sprint(show, trees), '\n') + idx = findfirst(str -> occursin("mt_disable", str), lines) + if idx !== nothing + @test occursin("throw_boundserror", lines[idx]) + @test occursin(r"\+\d+ more", lines[idx+1]) + end +end