diff --git a/Project.toml b/Project.toml index 6b3c56c..c60afb7 100644 --- a/Project.toml +++ b/Project.toml @@ -23,6 +23,8 @@ EnzymeCore = "0.8" FunctionWrappers = "1" Mooncake = "0.5" PrecompileTools = "1" +SafeTestsets = "0.1, 1" +SciMLTesting = "1" TruncatedStacktraces = "1" julia = "1.10" @@ -30,8 +32,9 @@ julia = "1.10" Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Pkg", "Test", "Enzyme", "EnzymeCore", "Mooncake"] +test = ["Test", "SafeTestsets", "SciMLTesting", "Enzyme", "EnzymeCore", "Mooncake"] diff --git a/test/enzyme_tests.jl b/test/Enzyme/enzyme_tests.jl similarity index 100% rename from test/enzyme_tests.jl rename to test/Enzyme/enzyme_tests.jl diff --git a/test/mooncake_tests.jl b/test/Mooncake/mooncake_tests.jl similarity index 100% rename from test/mooncake_tests.jl rename to test/Mooncake/mooncake_tests.jl diff --git a/test/nopre/Manifest.toml b/test/nopre/Manifest.toml deleted file mode 100644 index b801b1b..0000000 --- a/test/nopre/Manifest.toml +++ /dev/null @@ -1,261 +0,0 @@ -# This file is machine-generated - editing it directly is not advised - -julia_version = "1.12.4" -manifest_format = "2.0" -project_hash = "fc7db7725f4c12cf05bc39dfb6855e7476e54e38" - -[[deps.ArgTools]] -uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" -version = "1.1.2" - -[[deps.Artifacts]] -uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" -version = "1.11.0" - -[[deps.Base64]] -uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -version = "1.11.0" - -[[deps.CodeTracking]] -deps = ["InteractiveUtils", "UUIDs"] -git-tree-sha1 = "b7231a755812695b8046e8471ddc34c8268cbad5" -uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" -version = "3.0.0" - -[[deps.Compiler]] -git-tree-sha1 = "382d79bfe72a406294faca39ef0c3cef6e6ce1f1" -uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" -version = "0.1.1" - -[[deps.CompilerSupportLibraries_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.3.0+1" - -[[deps.Dates]] -deps = ["Printf"] -uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" -version = "1.11.0" - -[[deps.Downloads]] -deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] -uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" -version = "1.7.0" - -[[deps.FileWatching]] -uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" -version = "1.11.0" - -[[deps.FunctionWrappers]] -git-tree-sha1 = "d62485945ce5ae9c0c48f124a84998d755bae00e" -uuid = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" -version = "1.1.3" - -[[deps.FunctionWrappersWrappers]] -deps = ["FunctionWrappers", "PrecompileTools", "TruncatedStacktraces"] -path = "/home/crackauc/sandbox/tmp_20260108_090820_85201" -uuid = "77dc65aa-8811-40c2-897b-53d922fa7daf" -version = "0.1.4" - -[[deps.InteractiveUtils]] -deps = ["Markdown"] -uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -version = "1.11.0" - -[[deps.JET]] -deps = ["CodeTracking", "Compiler", "InteractiveUtils", "JuliaInterpreter", "JuliaSyntax", "LoweredCodeUtils", "MacroTools", "Pkg", "PrecompileTools", "Preferences", "Revise", "Test"] -git-tree-sha1 = "3642228b0d4ab0b263a5946f60ace6c2b5616256" -uuid = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" -version = "0.11.3" - -[[deps.JuliaInterpreter]] -deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] -git-tree-sha1 = "80580012d4ed5a3e8b18c7cd86cebe4b816d17a6" -uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" -version = "0.10.9" - -[[deps.JuliaSyntax]] -git-tree-sha1 = "0d4b3dab95018bcf3925204475693d9f09dc45b8" -uuid = "70703baa-626e-46a2-a12c-08ffd08c73b4" -version = "1.0.2" - -[[deps.JuliaSyntaxHighlighting]] -deps = ["StyledStrings"] -uuid = "ac6e5ff7-fb65-4e79-a425-ec3bc9c03011" -version = "1.12.0" - -[[deps.LibCURL]] -deps = ["LibCURL_jll", "MozillaCACerts_jll"] -uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.4" - -[[deps.LibCURL_jll]] -deps = ["Artifacts", "LibSSH2_jll", "Libdl", "OpenSSL_jll", "Zlib_jll", "nghttp2_jll"] -uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.15.0+0" - -[[deps.LibGit2]] -deps = ["LibGit2_jll", "NetworkOptions", "Printf", "SHA"] -uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" -version = "1.11.0" - -[[deps.LibGit2_jll]] -deps = ["Artifacts", "LibSSH2_jll", "Libdl", "OpenSSL_jll"] -uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.9.0+0" - -[[deps.LibSSH2_jll]] -deps = ["Artifacts", "Libdl", "OpenSSL_jll"] -uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.11.3+1" - -[[deps.Libdl]] -uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" -version = "1.11.0" - -[[deps.Logging]] -uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" -version = "1.11.0" - -[[deps.LoweredCodeUtils]] -deps = ["CodeTracking", "Compiler", "JuliaInterpreter"] -git-tree-sha1 = "65ae3db6ab0e5b1b5f217043c558d9d1d33cc88d" -uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" -version = "3.5.0" - -[[deps.MacroTools]] -git-tree-sha1 = "1e0228a030642014fe5cfe68c2c0a818f9e3f522" -uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -version = "0.5.16" - -[[deps.Markdown]] -deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"] -uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" -version = "1.11.0" - -[[deps.MozillaCACerts_jll]] -uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2025.11.4" - -[[deps.NetworkOptions]] -uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" -version = "1.3.0" - -[[deps.OpenSSL_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.5.4+0" - -[[deps.OrderedCollections]] -git-tree-sha1 = "05868e21324cede2207c6f0f466b4bfef6d5e7ee" -uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.8.1" - -[[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] -uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.12.1" -weakdeps = ["REPL"] - - [deps.Pkg.extensions] - REPLExt = "REPL" - -[[deps.PrecompileTools]] -deps = ["Preferences"] -git-tree-sha1 = "07a921781cab75691315adc645096ed5e370cb77" -uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -version = "1.3.3" - -[[deps.Preferences]] -deps = ["TOML"] -git-tree-sha1 = "522f093a29b31a93e34eaea17ba055d850edea28" -uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.5.1" - -[[deps.Printf]] -deps = ["Unicode"] -uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" -version = "1.11.0" - -[[deps.REPL]] -deps = ["InteractiveUtils", "JuliaSyntaxHighlighting", "Markdown", "Sockets", "StyledStrings", "Unicode"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" -version = "1.11.0" - -[[deps.Random]] -deps = ["SHA"] -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -version = "1.11.0" - -[[deps.Revise]] -deps = ["CodeTracking", "FileWatching", "InteractiveUtils", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Preferences", "REPL", "UUIDs"] -git-tree-sha1 = "dfd6fab9aa325b382773b8930998ce84c2918e5e" -uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" -version = "3.13.1" - - [deps.Revise.extensions] - DistributedExt = "Distributed" - - [deps.Revise.weakdeps] - Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" - -[[deps.SHA]] -uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" -version = "0.7.0" - -[[deps.Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" -version = "1.11.0" - -[[deps.Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" -version = "1.11.0" - -[[deps.StyledStrings]] -uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b" -version = "1.11.0" - -[[deps.TOML]] -deps = ["Dates"] -uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" -version = "1.0.3" - -[[deps.Tar]] -deps = ["ArgTools", "SHA"] -uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" -version = "1.10.0" - -[[deps.Test]] -deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] -uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -version = "1.11.0" - -[[deps.TruncatedStacktraces]] -deps = ["InteractiveUtils", "MacroTools", "Preferences"] -git-tree-sha1 = "ea3e54c2bdde39062abf5a9758a23735558705e1" -uuid = "781d530d-4396-4725-bb49-402e4bee1e77" -version = "1.4.0" - -[[deps.UUIDs]] -deps = ["Random", "SHA"] -uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" -version = "1.11.0" - -[[deps.Unicode]] -uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" -version = "1.11.0" - -[[deps.Zlib_jll]] -deps = ["Libdl"] -uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.3.1+2" - -[[deps.nghttp2_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.64.0+1" - -[[deps.p7zip_jll]] -deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] -uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" -version = "17.7.0+0" diff --git a/test/nopre/Project.toml b/test/nopre/Project.toml index 0b4fbf6..2021cec 100644 --- a/test/nopre/Project.toml +++ b/test/nopre/Project.toml @@ -1,4 +1,14 @@ [deps] FunctionWrappersWrappers = "77dc65aa-8811-40c2-897b-53d922fa7daf" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[sources] +FunctionWrappersWrappers = {path = "../.."} + +[compat] +SafeTestsets = "0.0.1, 0.1" +SciMLTesting = "1" +Test = "1" diff --git a/test/runtests.jl b/test/runtests.jl index 0018a99..624b377 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,67 +1,29 @@ -using Test, Pkg - -const GROUP = get(ENV, "GROUP", "All") - -if GROUP == "All" || GROUP == "Core" - @testset "FunctionWrappersWrappers.jl" begin - include("basictests.jl") - end -end - -if GROUP == "nopre" - Pkg.activate("nopre") - Pkg.develop(PackageSpec(path = dirname(@__DIR__))) - Pkg.instantiate() - include("nopre/jet_tests.jl") -end - -@testset "BigFloat support" begin - fwplus_big = FunctionWrappersWrapper( - +, - (Tuple{BigFloat, BigFloat}, Tuple{Float64, Float64}), - (BigFloat, Float64) - ) - a = BigFloat("3.14159265358979323846264338327950288") - b = BigFloat("2.71828182845904523536028747135266250") - @test fwplus_big(a, b) isa BigFloat - @test fwplus_big(a, b) == a + b - @test fwplus_big(1.0, 2.0) === 3.0 - - fwsin_big = FunctionWrappersWrapper( - sin, - (Tuple{BigFloat}, Tuple{Float64}), - (BigFloat, Float64) - ) - @test fwsin_big(BigFloat("1.0")) isa BigFloat - @test fwsin_big(1.0) === sin(1.0) -end - -@testset "UnionAll return types" begin - # Test that UnionAll types (like AbstractArray{Float64}) work as return types - function double_array(x::AbstractArray{Float64}) - return x .* 2 - end - - fwdouble = FunctionWrappersWrapper( - double_array, - (Tuple{AbstractArray{Float64}},), - (AbstractArray{Float64},) - ) - - v = [1.0, 2.0, 3.0] - result = fwdouble(v) - @test result isa Vector{Float64} - @test result == [2.0, 4.0, 6.0] -end - -if GROUP == "All" || GROUP == "Enzyme" - @testset "Enzyme extension" begin - include("enzyme_tests.jl") - end -end - -if GROUP == "All" || GROUP == "Mooncake" - @testset "Mooncake extension" begin - include("mooncake_tests.jl") - end -end +using SafeTestsets +using SciMLTesting + +run_tests(; + core = function () + @safetestset "FunctionWrappersWrappers.jl" begin + include(joinpath(@__DIR__, "basictests.jl")) + end + return @safetestset "BigFloat + UnionAll" begin + include(joinpath(@__DIR__, "shared", "bigfloat_unionall_tests.jl")) + end + end, + groups = Dict( + "nopre" => (; + env = joinpath(@__DIR__, "nopre"), + body = function () + @safetestset "JET" begin + include(joinpath(@__DIR__, "nopre", "jet_tests.jl")) + end + return @safetestset "BigFloat + UnionAll" begin + include(joinpath(@__DIR__, "shared", "bigfloat_unionall_tests.jl")) + end + end, + ), + "Enzyme" => joinpath(@__DIR__, "Enzyme", "enzyme_tests.jl"), + "Mooncake" => joinpath(@__DIR__, "Mooncake", "mooncake_tests.jl"), + ), + all = ["Core", "Enzyme", "Mooncake"], +) diff --git a/test/shared/bigfloat_unionall_tests.jl b/test/shared/bigfloat_unionall_tests.jl new file mode 100644 index 0000000..de091c5 --- /dev/null +++ b/test/shared/bigfloat_unionall_tests.jl @@ -0,0 +1,41 @@ +using FunctionWrappersWrappers +using Test + +@testset "BigFloat support" begin + fwplus_big = FunctionWrappersWrapper( + +, + (Tuple{BigFloat, BigFloat}, Tuple{Float64, Float64}), + (BigFloat, Float64) + ) + a = BigFloat("3.14159265358979323846264338327950288") + b = BigFloat("2.71828182845904523536028747135266250") + @test fwplus_big(a, b) isa BigFloat + @test fwplus_big(a, b) == a + b + @test fwplus_big(1.0, 2.0) === 3.0 + + fwsin_big = FunctionWrappersWrapper( + sin, + (Tuple{BigFloat}, Tuple{Float64}), + (BigFloat, Float64) + ) + @test fwsin_big(BigFloat("1.0")) isa BigFloat + @test fwsin_big(1.0) === sin(1.0) +end + +@testset "UnionAll return types" begin + # Test that UnionAll types (like AbstractArray{Float64}) work as return types + function double_array(x::AbstractArray{Float64}) + return x .* 2 + end + + fwdouble = FunctionWrappersWrapper( + double_array, + (Tuple{AbstractArray{Float64}},), + (AbstractArray{Float64},) + ) + + v = [1.0, 2.0, 3.0] + result = fwdouble(v) + @test result isa Vector{Float64} + @test result == [2.0, 4.0, 6.0] +end