Skip to content

Commit

Permalink
separate module context for Compiler.jl tests
Browse files Browse the repository at this point in the history
xref: <#56632 (review)>

This also allows us to execute each file standalone, which might be
useful for debugging.
  • Loading branch information
aviatesk committed Nov 22, 2024
1 parent 215189e commit 79b6db1
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Compiler/test/AbstractInterpreter.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_AbstractInterpreter

using Test

include("irutils.jl")
Expand Down Expand Up @@ -534,3 +536,5 @@ let interp = DebugInterp()
end
@test found
end

end # module test_AbstractInterpreter
4 changes: 4 additions & 0 deletions Compiler/test/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# tests for codegen and optimizations

module test_codegen

using Random
using InteractiveUtils
using Libdl
Expand Down Expand Up @@ -1027,3 +1029,5 @@ for a in ((@noinline Ref{Int}(2)),
@test ex === a
end
end

end # test_codegen
4 changes: 4 additions & 0 deletions Compiler/test/compact.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_compact

using Test

include("irutils.jl")
Expand Down Expand Up @@ -55,3 +57,5 @@ end
verify_ir(new_ir)
@test length(new_ir.cfg.blocks) == 1
end

end # module test_compact
4 changes: 4 additions & 0 deletions Compiler/test/contextual.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_contextual

# N.B.: This file is also run from interpreter.jl, so needs to be standalone-executable
using Test
include("setup_Compiler.jl")
Expand Down Expand Up @@ -124,3 +126,5 @@ f() = 2
foo(i) = i+bar(Val(1))

@test @inferred(overdub(Ctx(), foo, 1)) == 43

end # module test_contextual
6 changes: 6 additions & 0 deletions Compiler/test/datastructures.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_datastructures

using Test

include("setup_Compiler.jl")

@testset "CachedMethodTable" begin
Expand Down Expand Up @@ -113,3 +117,5 @@ end
end
end
end

end # module test_datastructures
4 changes: 4 additions & 0 deletions Compiler/test/effects.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_effects

using Test
include("irutils.jl")

Expand Down Expand Up @@ -1384,3 +1386,5 @@ end |> Compiler.is_nothrow
@test Base.infer_effects() do
@ccall unsafecall()::Cvoid
end == Compiler.EFFECTS_UNKNOWN

end # module test_effects
4 changes: 4 additions & 0 deletions Compiler/test/inference.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_inference

using Test

include("irutils.jl")
Expand Down Expand Up @@ -6126,3 +6128,5 @@ function func_swapglobal!_must_throw(x)
end
@test Base.infer_return_type(func_swapglobal!_must_throw, (Int,); interp=SwapGlobalInterp()) === Union{}
@test !Compiler.is_effect_free(Base.infer_effects(func_swapglobal!_must_throw, (Int,); interp=SwapGlobalInterp()) )

end # test_inference
4 changes: 4 additions & 0 deletions Compiler/test/inline.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_inline

using Test
using Base.Meta
using Core: ReturnNode
Expand Down Expand Up @@ -2309,3 +2311,5 @@ g_noinline_invoke(x) = f_noinline_invoke(x)
let src = code_typed1(g_noinline_invoke, (Union{Symbol,Nothing},))
@test !any(@nospecialize(x)->isa(x,GlobalRef), src.code)
end

end # module test_inline
4 changes: 4 additions & 0 deletions Compiler/test/invalidation.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_invalidation

# setup
# -----

Expand Down Expand Up @@ -283,3 +285,5 @@ begin take!(GLOBAL_BUFFER)
@test isnothing(pr48932_caller_inlined(42))
@test "42" == String(take!(GLOBAL_BUFFER))
end

end # module test_invalidation
4 changes: 4 additions & 0 deletions Compiler/test/irpasses.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_irpasses

using Test
using Base.Meta
using Core.IR
Expand Down Expand Up @@ -1996,3 +1998,5 @@ let code = Any[
ir = Compiler.domsort_ssa!(ir, domtree)
Compiler.verify_ir(ir)
end

end # module test_irpasses
4 changes: 4 additions & 0 deletions Compiler/test/ssair.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_ssair

include("irutils.jl")

using Test
Expand Down Expand Up @@ -818,3 +820,5 @@ let cl = Int32[32, 1, 1, 1000, 240, 230]
cl2 = ccall(:jl_uncompress_codelocs, Any, (Any, Int), str, 2)
@test cl == cl2
end

end # module test_ssair
4 changes: 4 additions & 0 deletions Compiler/test/tarjan.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_tarjan

using Test

include("irutils.jl")
Expand Down Expand Up @@ -167,3 +169,5 @@ end
test_reachability(100, 150; all_checks=false)
test_reachability(100, 1000; all_checks=false)
end

end # module test_tarjan
4 changes: 4 additions & 0 deletions Compiler/test/validation.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module test_validation

using Test, Core.IR

include("setup_Compiler.jl")
Expand Down Expand Up @@ -139,3 +141,5 @@ end
@test count(e.kind === Compiler.SLOTNAMES_NARGS_MISMATCH for e in errors) == 1
@test count(e.kind === Compiler.SIGNATURE_NARGS_MISMATCH for e in errors) == 1
end

end # module test_validation

0 comments on commit 79b6db1

Please sign in to comment.