Skip to content

Canonicalize test units to @safetestset#106

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:canonicalize-safetestset
Draft

Canonicalize test units to @safetestset#106
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:canonicalize-safetestset

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

Wraps each independent top-level test unit in @safetestset so it runs in its own module, matching OrdinaryDiffEq's canonical structure (isolation between units + world-age safety). Behavior-preserving: the same units run under the same GROUP dispatch with the same assertions — only the unit wrapper changes.

Changes

  • test/runtests.jl: the 8 Core units @testset "X" begin include("x.jl") end become @safetestset "X" begin include("x.jl") end. Each included file (algorithm_tests.jl, saving_tests.jl, mass_matrix_tests.jl, jac_tests.jl, callbacks.jl, initialization_tests.jl, mtk_initialization_tests.jl, explicit_imports.jl) is already self-contained with its own using/import lines, and the include() form runs statements sequentially so imports (and package macros like ModelingToolkit's @variables/@mtkcompile) resolve correctly inside the fresh module.
  • test/qa/qa.jl: the Aqua and JET units become @safetestset, each carrying its own using ODEInterfaceDiffEq, <Tool>, Test. The existing @test_broken lines (tracked in QA: Aqua/JET findings marked @test_broken pending fix #105) are preserved verbatim. The outer @testset "Quality Assurance" grouping wrapper in runtests.jl is left as-is.
  • Deps: added SafeTestsets to the main Project.toml [extras] + [targets].test + [compat] SafeTestsets = "0.1, 1", and to test/qa/Project.toml (the QA group activates its own env).

The GROUP-dispatch ladder, run path, and all assertions are unchanged. Nested grouping @testsets inside a unit (e.g. the per-iip/per-alg testsets in the initialization files) stay plain @testset — the unit-level @safetestset already isolates them.

Verification

GROUP=Core run locally via Pkg.test (Julia 1.11) — passed:

Explicit Imports |    2      2
Algorithms       |     0           (exercises solve() calls, no @test — unchanged)
Saving           |    3      3
Mass Matrix      |    4      4
Jacobian Tests   |    1      1
Callback Tests   |    2      2
Initialization Tests     |   13     13
MTK Initialization Tests |   55     55
     Testing ODEInterfaceDiffEq tests passed

Ignore until reviewed by @ChrisRackauckas.

Wrap each independent top-level test unit in `@safetestset` so it runs in
its own module, matching OrdinaryDiffEq's canonical structure (isolation
between units + world-age safety).

- test/runtests.jl: the 8 Core units `@testset "X" begin include(...) end`
  become `@safetestset "X" begin include(...) end`. Each included file is
  already self-contained with its own `using`/`import` lines, and the
  include() form runs statements sequentially so imports take effect before
  any package macros are reached.
- test/qa/qa.jl: the Aqua and JET units become `@safetestset`, each carrying
  its own `using ODEInterfaceDiffEq, <Tool>, Test`. `@test_broken` lines
  preserved verbatim.
- Added SafeTestsets to the test deps: main Project.toml [extras] +
  [targets].test + [compat] SafeTestsets = "0.1, 1", and test/qa/Project.toml
  (the QA group activates its own env).

Behavior-preserving: same units run under the same GROUP dispatch, same
assertions. GROUP=Core verified locally (Pkg.test passed: Explicit Imports 2,
Saving 3, Mass Matrix 4, Jacobian 1, Callbacks 2, Initialization 13,
MTK Initialization 55; Algorithms exercises solve calls with no @test).

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants