diff --git a/test/Project.toml b/test/Project.toml index 1090e98..6e02f84 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -3,11 +3,11 @@ JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" QuasiMonteCarlo = "8a4e6c94-4038-4cdc-81c3-7e6ffdb2a71b" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" @@ -18,5 +18,6 @@ Optimization = "4.1, 5.2" QuasiMonteCarlo = "0.3" SafeTestsets = "0.1" SciMLBase = "2.79, 3.0" +SciMLTesting = "1" StaticArrays = "1.9" julia = "1.10" diff --git a/test/qa.jl b/test/qa.jl deleted file mode 100644 index 96e50e9..0000000 --- a/test/qa.jl +++ /dev/null @@ -1,34 +0,0 @@ -using JET -using ParallelParticleSwarms -using StaticArrays -using Test - -@testset "JET static analysis" begin - @testset "Utility functions type stability" begin - @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.θ_default( - 0.5f0 - ) - @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.γ_default( - 0.5f0 - ) - - @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.uniform( - 2, Float32[-5.0, -5.0], Float32[5.0, 5.0] - ) - end - - @testset "Particle struct construction" begin - T = SVector{2, Float32} - position = @SVector zeros(Float32, 2) - velocity = @SVector zeros(Float32, 2) - cost = 0.0f0 - - @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.SPSOParticle( - position, velocity, cost, position, cost - ) - - @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.SPSOGBest( - position, cost - ) - end -end diff --git a/test/qa/Project.toml b/test/qa/Project.toml index c7c271d..8477799 100644 --- a/test/qa/Project.toml +++ b/test/qa/Project.toml @@ -1,6 +1,8 @@ [deps] JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" ParallelParticleSwarms = "ab63da0c-63b4-40fa-a3b7-d2cba5be6419" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" @@ -9,5 +11,7 @@ ParallelParticleSwarms = {path = "../.."} [compat] JET = "0.9, 0.10, 0.11" +SafeTestsets = "0.0.1, 0.1" +SciMLTesting = "1" StaticArrays = "1.9" julia = "1.10" diff --git a/test/qa/jet_tests.jl b/test/qa/jet_tests.jl new file mode 100644 index 0000000..7f67e08 --- /dev/null +++ b/test/qa/jet_tests.jl @@ -0,0 +1,32 @@ +using JET +using ParallelParticleSwarms +using StaticArrays +using Test + +@testset "Utility functions type stability" begin + @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.θ_default( + 0.5f0 + ) + @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.γ_default( + 0.5f0 + ) + + @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.uniform( + 2, Float32[-5.0, -5.0], Float32[5.0, 5.0] + ) +end + +@testset "Particle struct construction" begin + T = SVector{2, Float32} + position = @SVector zeros(Float32, 2) + velocity = @SVector zeros(Float32, 2) + cost = 0.0f0 + + @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.SPSOParticle( + position, velocity, cost, position, cost + ) + + @test_opt target_modules = (ParallelParticleSwarms,) ParallelParticleSwarms.SPSOGBest( + position, cost + ) +end diff --git a/test/qa/qa.jl b/test/qa/qa.jl new file mode 100644 index 0000000..4f12a49 --- /dev/null +++ b/test/qa/qa.jl @@ -0,0 +1,5 @@ +using SafeTestsets + +@safetestset "JET static analysis" begin + include("jet_tests.jl") +end diff --git a/test/runtests.jl b/test/runtests.jl index ac97ce6..799cdbe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,27 +1,25 @@ -using Pkg using SafeTestsets using Test +using SciMLTesting -const TEST_GROUP = get(ENV, "PPS_TEST_GROUP", "Core") +run_tests(; + env = "PPS_TEST_GROUP", + default = "Core", + core = function () + global CI_GROUP = get(ENV, "GROUP", "CPU") -if TEST_GROUP == "QA" - Pkg.activate(joinpath(@__DIR__, "qa")) - Pkg.develop(PackageSpec(path = joinpath(@__DIR__, ".."))) - Pkg.instantiate() - include("qa.jl") -else - global CI_GROUP = get(ENV, "GROUP", "CPU") + @safetestset "Regression tests" include("./regression.jl") + @safetestset "Reinitialization tests" include("./reinit.jl") - @safetestset "Regression tests" include("./regression.jl") - @safetestset "Reinitialization tests" include("./reinit.jl") - - #TODO: Current throws warning for redefinition with the use of @testset multiple times. Migrate to TestItemRunners.jl - @testset for BACKEND in unique(("CPU", CI_GROUP)) - global GROUP = BACKEND - @testset "$(BACKEND) optimizers tests" include("./gpu.jl") - GC.gc(true) - @testset "$(BACKEND) optimizers with constraints tests" include("./constraints.jl") - GC.gc(true) - @testset "$(BACKEND) hybrid optimizers" include("./lbfgs.jl") - end -end + #TODO: Current throws warning for redefinition with the use of @testset multiple times. Migrate to TestItemRunners.jl + return @testset for BACKEND in unique(("CPU", CI_GROUP)) + global GROUP = BACKEND + @testset "$(BACKEND) optimizers tests" include("./gpu.jl") + GC.gc(true) + @testset "$(BACKEND) optimizers with constraints tests" include("./constraints.jl") + GC.gc(true) + @testset "$(BACKEND) hybrid optimizers" include("./lbfgs.jl") + end + end, + qa = (; env = joinpath(@__DIR__, "qa"), body = joinpath(@__DIR__, "qa", "qa.jl")), +)