Skip to content

Commit

Permalink
Switch to ReTestItems.jl.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Sep 4, 2023
1 parent 987a230 commit 716c472
Show file tree
Hide file tree
Showing 29 changed files with 115 additions and 117 deletions.
2 changes: 1 addition & 1 deletion test/Kaleidoscope.jl → test/Kaleidoscope_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "Kaleidoscope" begin
@testitem "Kaleidoscope" begin

include(joinpath(@__DIR__, "..", "examples", "Kaleidoscope", "Kaleidoscope.jl"))

Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LLVMExtra_jll = "dad2f222-ce93-54a1-a47d-0025e8a3acab"
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
2 changes: 1 addition & 1 deletion test/analysis.jl → test/analysis_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "analysis" begin
@testitem "analysis" begin

@dispose ctx=Context() builder=IRBuilder() mod=LLVM.Module("SomeModule") begin
ft = LLVM.FunctionType(LLVM.Int32Type())
Expand Down
2 changes: 1 addition & 1 deletion test/bitcode.jl → test/bitcode_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "bitcode" begin
@testitem "bitcode" begin

@dispose ctx=Context() begin
invalid_bitcode = "invalid"
Expand Down
2 changes: 1 addition & 1 deletion test/buffer.jl → test/buffer_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "buffer" begin
@testitem "buffer" begin

data = rand(UInt8, 8)

Expand Down
4 changes: 2 additions & 2 deletions test/core.jl → test/core_tests.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@testitem "core" setup=[TestHelpers] begin

struct TestStruct
x::Bool
y::Int64
Expand All @@ -11,8 +13,6 @@ end
struct TestSingleton
end

@testset "core" begin

@testset "context" begin

@test context(; throw_error=false) === nothing
Expand Down
2 changes: 1 addition & 1 deletion test/datalayout.jl → test/datalayout_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "datalayout" begin
@testitem "datalayout" begin

dlstr = "E-p:32:32-f128:128:128"

Expand Down
4 changes: 1 addition & 3 deletions test/debuginfo.jl → test/debuginfo_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using LLVM,Test

@testset "debuginfo" begin
@testitem "debuginfo" begin

DEBUG_METADATA_VERSION()

Expand Down
38 changes: 38 additions & 0 deletions test/essential_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@testitem "essentials" begin

@testset "types" begin
@test convert(Bool, LLVM.True) == true
@test convert(Bool, LLVM.False) == false

@test_throws ArgumentError LLVM.convert(Bool, LLVM.API.LLVMBool(2))

@test convert(LLVM.Bool, true) == LLVM.True
@test convert(LLVM.Bool, false) == LLVM.False
end

@testset "pass registry" begin
passreg = GlobalPassRegistry()

@test version() isa VersionNumber
@test ismultithreaded() isa Bool

InitializeCore(passreg)
InitializeTransformUtils(passreg)
InitializeScalarOpts(passreg)
InitializeObjCARCOpts(passreg)
InitializeVectorization(passreg)
InitializeInstCombine(passreg)
InitializeIPO(passreg)
InitializeInstrumentation(passreg)
InitializeAnalysis(passreg)
InitializeIPA(passreg)
InitializeCodeGen(passreg)
InitializeTarget(passreg)

InitializeNativeTarget()
InitializeAllTargetInfos()
InitializeAllTargetMCs()
InitializeNativeAsmPrinter()
end

end
2 changes: 1 addition & 1 deletion test/examples.jl → test/examples_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "examples" begin
@testitem "examples" begin

function find_sources(path::String, sources=String[])
if isdir(path)
Expand Down
2 changes: 1 addition & 1 deletion test/execution.jl → test/execution_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "execution" begin
@testitem "execution" begin

@testset "generic values" begin

Expand Down
8 changes: 8 additions & 0 deletions test/helpers.jl → test/helpers_testsetup.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
@testsetup module TestHelpers

using Test

export @check_ir

macro check_ir(inst, str)
quote
inst = string($(esc(inst)))
@test occursin($(str), inst)
end
end

end
4 changes: 4 additions & 0 deletions test/instructions.jl → test/instructions_tests.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@testitem "instructions" setup=[TestHelpers] begin

@testset "irbuilder" begin

@dispose ctx=Context() builder=IRBuilder() mod=LLVM.Module("SomeModule") begin
Expand Down Expand Up @@ -501,3 +503,5 @@ end
end
end
end

end
7 changes: 4 additions & 3 deletions test/interop.jl → test/interop_tests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@testitem "interop" begin

using LLVM.Interop
using InteractiveUtils

@testset "interop" begin

# many of these tests don't use explicit contexts, as they rely on high-level functionality.
# that functionality should be using default context options, so query those here.
supports_typed_ptrs = @dispose ctx=Context() begin
Expand Down Expand Up @@ -120,7 +120,6 @@ end

@testset "passes" begin


@dispose ctx=Context() mod=LLVM.Module("SomeModule") pm=ModulePassManager() begin

demote_float16!(pm)
Expand All @@ -143,6 +142,8 @@ cpu_features!(pm)

end

@test "we didn't crash!" != ""

end


Expand Down
2 changes: 1 addition & 1 deletion test/ir.jl → test/ir_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "ir" begin
@testitem "ir" begin

@dispose ctx=Context() begin
invalid_ir = "invalid"
Expand Down
4 changes: 3 additions & 1 deletion test/jljit.jl → test/jljit_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@testset "jljit" begin
@static if LLVM.has_julia_ojit()
@testitem "jljit" begin

let jljit=JuliaOJIT()
dispose(jljit)
Expand Down Expand Up @@ -265,3 +266,4 @@ end
end

end
end
2 changes: 1 addition & 1 deletion test/linker.jl → test/linker_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "linker" begin
@testitem "linker" begin

@dispose ctx=Context() builder=IRBuilder() begin
mod1 = let
Expand Down
9 changes: 7 additions & 2 deletions test/moduleprovider.jl → test/moduleprovider_tests.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
@testset "moduleprovider" begin
@testitem "moduleprovider" begin

@dispose ctx=Context() begin
mod = LLVM.Module("SomeModule")
mp = ModuleProvider(mod)
dispose(mp)

@test "we didn't crash!" != ""
end

@dispose ctx=Context() begin
mod = LLVM.Module("SomeModule")
ModuleProvider(mod) do md
end

@test "we didn't crash!" != ""
end

@dispose ctx=Context() begin
mod = LLVM.Module("SomeModule")
@dispose mp=ModuleProvider(mod) begin

end

@test "we didn't crash!" != ""
end

end
22 changes: 15 additions & 7 deletions test/newpm.jl → test/newpm_tests.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@static if LLVM.has_newpm()
@testitem "newpm" begin

using InteractiveUtils # for subtypes

@testset "newpm pass managers" begin

let mpm = NewPMModulePassManager()
Expand Down Expand Up @@ -197,22 +202,22 @@ host_t = Target(triple=host_triple)
end

@test "Successfully added custom module and function passes!" != ""

@dispose ctx=Context() builder=IRBuilder() mod=LLVM.Module("test") begin
pa = run!(mpm, mod, mam)
@test observed_modules == 1
@test observed_functions == 0
@test are_all_preserved(pa)


ft = LLVM.FunctionType(LLVM.VoidType())
fn = LLVM.Function(mod, "SomeFunction", ft)

entry = BasicBlock(fn, "entry")
position!(builder, entry)

ret!(builder)

pa = run!(mpm, mod, mam)
@test observed_modules == 2
@test observed_functions == 1
Expand All @@ -222,4 +227,7 @@ host_t = Target(triple=host_triple)
end
end

end # testset "newpm custom passes"
end # testset "newpm passes"

end
end
4 changes: 3 additions & 1 deletion test/orc.jl → test/orc_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@testset "orc" begin
@static if LLVM.has_orc_v1() && !LLVM.is_asserts() # XXX: dangling references abort
@testitem "orc" begin

let tm = JITTargetMachine()
let orc = OrcJIT(tm)
Expand Down Expand Up @@ -328,3 +329,4 @@ end
end

end
end
4 changes: 3 additions & 1 deletion test/orcv2.jl → test/orcv2_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@testset "orcv2" begin
@static if LLVM.has_orc_v2()
@testitem "orcv2" begin

let lljit=LLJIT()
dispose(lljit)
Expand Down Expand Up @@ -302,3 +303,4 @@ end
end

end
end
2 changes: 1 addition & 1 deletion test/pass.jl → test/pass_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "pass" begin
@testitem "pass" begin

@dispose ctx=Context() builder=IRBuilder() mod=LLVM.Module("SomeModule") begin
ft = LLVM.FunctionType(LLVM.VoidType())
Expand Down
2 changes: 1 addition & 1 deletion test/passmanager.jl → test/passmanager_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "passmanager" begin
@testitem "passmanager" begin

let
mpm = ModulePassManager()
Expand Down
Loading

0 comments on commit 716c472

Please sign in to comment.