Skip to content

Canonicalize test units with @safetestset#79

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

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

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

What

Canonicalizes the test suite so each independent top-level test unit runs in its own module via @safetestset, matching the canonical OrdinaryDiffEq structure (isolation between tests + world-age safety).

Changes

Core group (runtests.jl):

  • The two inline @testset bodies — "Core Tests" and "Analytical Solutions" — were extracted verbatim into new self-contained files test/core_tests.jl and test/analytical_tests.jl, each carrying its own using DiffEqFinancial, Statistics, StochasticDiffEq, Test. The units now read @safetestset "X" begin include("x.jl") end.
  • "Interface Compatibility" (already a self-contained include("interface_tests.jl")) becomes @safetestset.
  • The outer @testset "DiffEqFinancial.jl" grouping wrapper is kept (@safetestset nests fine inside @testset).

QA group (test/qa/qa.jl):

  • The three units — Explicit Imports, JET Tests, AllocCheck — become @safetestset. Each included file (explicit_imports.jl, jet_tests.jl, alloc_tests.jl) already carries its own using lines. Using the include(file) body form is required here so the package macros @test_opt / @check_allocs are defined (via the file's top-level using) before they are parsed.

Deps:

  • Added SafeTestsets (1bc83da4-3b8d-516f-aca4-4fe02f6d838f) to the main Project.toml [extras] + [targets].test + [compat] SafeTestsets = "0.1, 1".
  • Added the same to test/qa/Project.toml (the QA group activates its own env).

Behavior-preserving: identical tests, assertions, and GROUP dispatch ladder. Nested grouping @testsets inside units are left as plain @testset (the unit-level @safetestset already isolates).

Verification

Verified locally with julia +1.11:

  • GROUP=Core Pkg.test() — passes (3 isolated units: Core Tests; Interface Compatibility 17/17; Analytical Solutions 42/42).
  • GROUP=QA Pkg.test() — passes (Explicit Imports, JET, AllocCheck all run as @safetestset).

Note: the "Core Tests" unit contains a pre-existing flaky unseeded Monte Carlo assertion testerr < 0.25 on a 1M-trajectory GBM mean. Across repeated runs testerr was observed ranging ~0.006–0.35, so it fails with small probability independent of this change (the body is byte-identical to the original and there is no RNG seeding anywhere in the suite). Not addressed here.


Draft — please ignore until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code

Convert the independent top-level test units to @safetestset so each runs in
its own module (isolation + world-age safety), matching the canonical
OrdinaryDiffEq structure.

- Core group: "Core Tests" and "Analytical Solutions" inline bodies extracted
  verbatim into self-contained test/core_tests.jl and test/analytical_tests.jl
  (each carrying its own `using DiffEqFinancial, Statistics, StochasticDiffEq,
  Test`), then included from @safetestset units. "Interface Compatibility"
  (already a self-contained include) becomes @safetestset.
- QA group: the three qa.jl units (Explicit Imports, JET, AllocCheck) become
  @safetestset; each included file already carries its own imports. The package
  macros (@test_opt, @check_allocs) resolve correctly because each unit is just
  `include(file)` and the file's `using` runs before the macro is parsed.
- Add SafeTestsets to the main Project.toml [extras]/[targets].test + [compat]
  and to test/qa/Project.toml (QA runs in its own activated env).

Behavior-preserving: identical tests, assertions, and GROUP dispatch. Nested
grouping @testsets inside units left as plain @testset.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor Author

superseded by the v1.2 folder conversion on sciml-testing-rollout

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