From 4ea2f4ebca608e92aa26928807982f9b5497fc48 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Sun, 14 Jun 2026 08:50:18 -0400 Subject: [PATCH] Use SciMLTesting v1.2 folder-based run_tests Convert the test harness to SciMLTesting v1.2. The Core group's five Enzyme/gradient files are gated behind `CI != "true"` (skipped on CI); that guard cannot be expressed by folder-discovery (which runs every file in a group unconditionally), so Core is wired as an explicit `run_tests` `core` thunk that keeps the CI guard verbatim and runs each self-contained file under its own @safetestset. "All" is curated to ["Core"] so GROUP=All runs only Core (QA runs only for GROUP=QA), matching the previous runtests.jl. The QA env activation (activate/develop/instantiate + bare include of qa.jl) is kept as an explicit thunk so it stays byte-for-byte identical. Adds SciMLTesting + SafeTestsets to the test and qa test envs. test/data, test/utilities, and test/test_groups.toml are unchanged. Co-Authored-By: Chris Rackauckas Co-Authored-By: Claude Opus 4.8 (1M context) --- test/Project.toml | 4 ++ test/qa/Project.toml | 5 ++ test/runtests.jl | 110 +++++++++++++++++++++++++++++++------------ 3 files changed, 89 insertions(+), 30 deletions(-) diff --git a/test/Project.toml b/test/Project.toml index e331aab..1880de7 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -12,6 +12,8 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" @@ -29,4 +31,6 @@ EnzymeTestUtils = "0.2.4" FiniteDifferences = "0.12.34" ForwardDiff = "1.4.0" Plots = "1.41.6" +SafeTestsets = "0.0.1, 0.1" +SciMLTesting = "1" StaticArrays = "1.9.18" diff --git a/test/qa/Project.toml b/test/qa/Project.toml index f459d39..390c352 100644 --- a/test/qa/Project.toml +++ b/test/qa/Project.toml @@ -5,6 +5,8 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [sources] @@ -15,4 +17,7 @@ Aqua = "0.8" Distributions = "0.25.126" ExplicitImports = "1" JET = "0.9, 0.10, 0.11" +SafeTestsets = "0.0.1, 0.1" +SciMLTesting = "1" +Test = "1" julia = "1.10" diff --git a/test/runtests.jl b/test/runtests.jl index 921813f..67c0d31 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,40 +1,90 @@ using Pkg -using Test +using SafeTestsets, Test +using SciMLTesting -const GROUP = get(ENV, "GROUP", "All") - -if GROUP == "QA" +# The QA env is activated and the root package developed into it explicitly (rather +# than via `run_tests`'s `env =` group spec) so the activate/develop/instantiate +# sequence — and the bare `include` of qa.jl into the runtests module — stays +# byte-for-byte identical to the previous hand-written runtests.jl. +function qa_group() Pkg.activate(joinpath(@__DIR__, "qa")) - Pkg.develop(PackageSpec(path = dirname(@__DIR__))) + Pkg.develop(Pkg.PackageSpec(path = dirname(@__DIR__))) Pkg.instantiate() - include(joinpath(@__DIR__, "qa", "qa.jl")) + return include(joinpath(@__DIR__, "qa", "qa.jl")) end -if GROUP == "All" || GROUP == "Core" - using DifferenceEquations - using Distributions - using LinearAlgebra - using Random - - include("linear_direct_iteration.jl") - include("kalman.jl") - include("direct_iteration.jl") - include("quadratic_direct_iteration.jl") - include("static_arrays.jl") - include("cache_reuse.jl") - include("sciml_interfaces.jl") - include("sensitivity_interface.jl") - include("linear_direct_iteration_forwarddiff.jl") - include("kalman_forwarddiff.jl") - include("conditional_likelihood.jl") - include("conditional_likelihood_forwarddiff.jl") - include("save_everystep.jl") +# Core test group. The previous runtests.jl ran these files for GROUP=All and +# GROUP=Core, with the five Enzyme/gradient files gated behind `CI != "true"` (they +# are skipped on CI). That CI guard cannot be expressed by folder-discovery — which +# would run every file in the group unconditionally — so the group is wired as an +# explicit `run_tests` `core` thunk that keeps the guard verbatim. Each file is run +# in its own `@safetestset` module (it is self-contained, carrying its own `using`s). +function core_group() + @safetestset "Linear DirectIteration" begin + include("linear_direct_iteration.jl") + end + @safetestset "Kalman" begin + include("kalman.jl") + end + @safetestset "DirectIteration (generic + quadratic)" begin + include("direct_iteration.jl") + end + @safetestset "Quadratic DirectIteration" begin + include("quadratic_direct_iteration.jl") + end + @safetestset "StaticArrays" begin + include("static_arrays.jl") + end + @safetestset "Cache reuse" begin + include("cache_reuse.jl") + end + @safetestset "SciML interfaces" begin + include("sciml_interfaces.jl") + end + @safetestset "Sensitivity interface" begin + include("sensitivity_interface.jl") + end + @safetestset "Linear DirectIteration ForwardDiff" begin + include("linear_direct_iteration_forwarddiff.jl") + end + @safetestset "Kalman ForwardDiff" begin + include("kalman_forwarddiff.jl") + end + @safetestset "ConditionalLikelihood" begin + include("conditional_likelihood.jl") + end + @safetestset "ConditionalLikelihood ForwardDiff" begin + include("conditional_likelihood_forwarddiff.jl") + end + @safetestset "save_everystep" begin + include("save_everystep.jl") + end if get(ENV, "CI", "false") != "true" - include("gradient_comparison.jl") - include("linear_direct_iteration_enzyme.jl") - include("quadratic_direct_iteration_enzyme.jl") - include("kalman_enzyme.jl") - include("conditional_likelihood_enzyme.jl") + @safetestset "Gradient comparison" begin + include("gradient_comparison.jl") + end + @safetestset "Linear DirectIteration Enzyme" begin + include("linear_direct_iteration_enzyme.jl") + end + @safetestset "Quadratic DirectIteration Enzyme" begin + include("quadratic_direct_iteration_enzyme.jl") + end + @safetestset "Kalman Enzyme" begin + include("kalman_enzyme.jl") + end + @safetestset "ConditionalLikelihood Enzyme" begin + include("conditional_likelihood_enzyme.jl") + end end + return nothing end + +# The previous runtests.jl ran the Core block (not QA) for GROUP=All, so "All" is +# curated to ["Core"]: GROUP=All and GROUP=Core both run the Core body, and QA runs +# only for GROUP=QA. +run_tests(; + core = core_group, + qa = qa_group, + all = ["Core"], +)