Skip to content

Commit

Permalink
Reorder invalidation tests (#388)
Browse files Browse the repository at this point in the history
On Julia 1.11, the impact of redefining `throw_boundserror` seems much
larger, and it breaks later tests. Defer this until the end.
  • Loading branch information
timholy authored Jul 5, 2024
1 parent a82644a commit 50f38e6
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions test/snoop_invalidations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 50f38e6

Please sign in to comment.