diff --git a/Project.toml b/Project.toml index 384df60..658509c 100644 --- a/Project.toml +++ b/Project.toml @@ -16,13 +16,16 @@ ModelingToolkit = "8, 9, 10, 11" ParameterizedFunctions = "5" PrecompileTools = "1" Reexport = "0.2, 1.0" +SafeTestsets = "0.1, 1" +SciMLTesting = "1" Test = "<0.0.1, 1" julia = "1.10" [extras] ParameterizedFunctions = "65888b18-ceab-5e60-b2b9-181511a3b968" -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 = ["Test", "ParameterizedFunctions", "Pkg"] +test = ["Test", "ParameterizedFunctions", "SafeTestsets", "SciMLTesting"] diff --git a/test/interface_tests.jl b/test/interface_tests.jl index 0e189b8..1aa6607 100644 --- a/test/interface_tests.jl +++ b/test/interface_tests.jl @@ -1,6 +1,7 @@ # Interface compatibility tests for MATLABDiffEq.jl # These tests verify type checking and interface compliance +using MATLABDiffEq using Test @testset "Interface Compatibility" begin diff --git a/test/matlab_runtime_tests.jl b/test/matlab_runtime_tests.jl new file mode 100644 index 0000000..682cf16 --- /dev/null +++ b/test/matlab_runtime_tests.jl @@ -0,0 +1,37 @@ +# These tests require MATLAB runtime to be available. +# They test the actual ODE solving functionality. +using DiffEqBase, MATLABDiffEq, ParameterizedFunctions + +f = @ode_def_bare LotkaVolterra begin + dx = a * x - b * x * y + dy = -c * y + d * x * y +end a b c d +p = [1.5, 1, 3, 1] +tspan = (0.0, 10.0) +u0 = [1.0, 1.0] +prob = ODEProblem(f, u0, tspan, p) +sol = solve(prob, MATLABDiffEq.ode45()) + +function lorenz(du, u, p, t) + du[1] = 10.0(u[2] - u[1]) + du[2] = u[1] * (28.0 - u[3]) - u[2] + return du[3] = u[1] * u[2] - (8 / 3) * u[3] +end +u0 = [1.0; 0.0; 0.0] +tspan = (0.0, 100.0) +prob = ODEProblem(lorenz, u0, tspan) +sol = solve(prob, MATLABDiffEq.ode45()) + +algs = [ + MATLABDiffEq.ode23 + MATLABDiffEq.ode45 + MATLABDiffEq.ode113 + MATLABDiffEq.ode23s + MATLABDiffEq.ode23t + MATLABDiffEq.ode23tb + MATLABDiffEq.ode15s +] + +for alg in algs + sol = solve(prob, alg()) +end diff --git a/test/qa/Project.toml b/test/qa/Project.toml index 798ad79..820e95a 100644 --- a/test/qa/Project.toml +++ b/test/qa/Project.toml @@ -2,6 +2,8 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" MATLABDiffEq = "e2752cbe-bcf4-5895-8727-84ebc14a76bd" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [sources] @@ -10,5 +12,7 @@ MATLABDiffEq = {path = "../.."} [compat] Aqua = "0.8" JET = "0.9, 0.10, 0.11" +SafeTestsets = "0.1, 1" +SciMLTesting = "1" Test = "<0.0.1, 1" julia = "1.10" diff --git a/test/qa/qa.jl b/test/qa/qa.jl index 9a37f3a..a91975a 100644 --- a/test/qa/qa.jl +++ b/test/qa/qa.jl @@ -1,11 +1,12 @@ -using MATLABDiffEq, Aqua, JET -using Test +using SafeTestsets -@testset "Aqua" begin +@safetestset "Aqua" begin + using MATLABDiffEq, Aqua Aqua.test_all(MATLABDiffEq) end -@testset "JET static analysis" begin +@safetestset "JET static analysis" begin + using MATLABDiffEq, JET, Test rep = JET.report_package(MATLABDiffEq; target_modules = (MATLABDiffEq,)) @test length(JET.get_reports(rep)) == 0 end diff --git a/test/runtests.jl b/test/runtests.jl index 21ff27b..a18a7cc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,64 +1,2 @@ -using Pkg -using Test -using DiffEqBase, MATLABDiffEq, ParameterizedFunctions - -const GROUP = get(ENV, "GROUP", "Core") - -# QA (Aqua + JET) runs in an isolated environment (test/qa) so its tooling deps -# never enter the main test target's resolve. On Julia < 1.11 the [sources] table -# is ignored, so develop the package by path to test the PR branch code. -function activate_qa_env() - Pkg.activate(joinpath(@__DIR__, "qa")) - Pkg.develop(PackageSpec(path = dirname(@__DIR__))) - return Pkg.instantiate() -end - -if GROUP == "Core" || GROUP == "All" - # Interface tests - these test type validation without needing MATLAB runtime - include("interface_tests.jl") - - # Static type-stability tests - these also run without MATLAB - include("jet_tests.jl") - - # The following tests require MATLAB runtime to be available - # They test the actual ODE solving functionality - - f = @ode_def_bare LotkaVolterra begin - dx = a * x - b * x * y - dy = -c * y + d * x * y - end a b c d - p = [1.5, 1, 3, 1] - tspan = (0.0, 10.0) - u0 = [1.0, 1.0] - prob = ODEProblem(f, u0, tspan, p) - sol = solve(prob, MATLABDiffEq.ode45()) - - function lorenz(du, u, p, t) - du[1] = 10.0(u[2] - u[1]) - du[2] = u[1] * (28.0 - u[3]) - u[2] - return du[3] = u[1] * u[2] - (8 / 3) * u[3] - end - u0 = [1.0; 0.0; 0.0] - tspan = (0.0, 100.0) - prob = ODEProblem(lorenz, u0, tspan) - sol = solve(prob, MATLABDiffEq.ode45()) - - algs = [ - MATLABDiffEq.ode23 - MATLABDiffEq.ode45 - MATLABDiffEq.ode113 - MATLABDiffEq.ode23s - MATLABDiffEq.ode23t - MATLABDiffEq.ode23tb - MATLABDiffEq.ode15s - ] - - for alg in algs - sol = solve(prob, alg()) - end -end - -if GROUP == "QA" - activate_qa_env() - include("qa/qa.jl") -end +using SciMLTesting +run_tests()