Skip to content

Canonicalize tests to @safetestset for per-unit module isolation#178

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

Canonicalize tests to @safetestset for per-unit module isolation#178
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:canonicalize-safetestset

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

Summary

Converts each independent top-level test unit in the Static.jl suite from a plain @testset to a @safetestset, so every unit runs in its own fresh module. This matches the canonical OrdinaryDiffEq test structure and gives test isolation plus world-age safety. Each converted unit carries its own using lines so its body is self-contained.

Changes

  • test/core_tests.jl: the 11 top-level @testset units (StaticSymbol, StaticInt, StaticBool, operators, static interface, promote_shape, tuple utilities, invperm, NDIndex, StaticFloat64, string/print/show) plus the include("ranges.jl") and Allocation Tests units are now @safetestset. Nested grouping @testsets inside a unit (reduce_tup, constructors, trig) stay plain @testset — the unit-level @safetestset already isolates them.
  • The maybe_static_length block (which was bare top-level code, never in a testset) is kept in its own top-level module rather than a @safetestset. Its @inferred helpers must be defined at module scope; defining them inside a testset function degrades the inferred return type to Any (the original code deliberately kept them out of any testset for exactly this reason). The module wrapper still gives it per-unit isolation.
  • test/ranges.jl: now carries its own using Static, Test (previously relied on leakage from core_tests.jl).
  • test/qa/qa.jl: Aqua and ExplicitImports are now separate @safetestsets, each with its own imports.
  • Deps: add SafeTestsets to the root Project.toml ([extras] / [targets].test / [compat]) and to test/qa/Project.toml ([deps] / [compat]).

Behavior preservation

Same tests run under the same GROUP dispatch with the same assertions — only the per-unit wrapper changed. The GROUP-dispatch ladder and runtests.jl structure are untouched.

Verification

Verified locally on Julia 1.11:

  • GROUP=Core Pkg.test() — passes (all units green; Allocation Tests 34/34).
  • GROUP=QA Pkg.test() — passes (Aqua 9 pass / 1 pre-existing broken, ExplicitImports 2/2).

This PR is a draft. Please ignore until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code

Convert each independent top-level test unit in the Static.jl suite from a
plain `@testset` to a `@safetestset` so it runs in its own fresh module,
matching the canonical OrdinaryDiffEq structure (test isolation + world-age
safety). Each converted unit carries its own `using` lines so its body is
self-contained.

- test/core_tests.jl: the 11 top-level `@testset` units (StaticSymbol,
  StaticInt, StaticBool, operators, static interface, promote_shape, tuple
  utilities, invperm, NDIndex, StaticFloat64, string/print/show) plus the
  `include("ranges.jl")` and Allocation Tests units are now `@safetestset`.
  Nested grouping `@testset`s inside a unit (reduce_tup, constructors, trig)
  stay plain `@testset` since the unit-level `@safetestset` already isolates.
- The `maybe_static_length` block stays in a top-level `module` (its
  `@inferred` helpers must be defined at module scope, not inside a testset
  function, or inference degrades to `Any`).
- test/ranges.jl now carries its own `using Static, Test`.
- test/qa/qa.jl: Aqua and ExplicitImports are now separate `@safetestset`s.
- Add SafeTestsets to root Project.toml ([extras]/[targets].test/[compat])
  and test/qa/Project.toml ([deps]/[compat]).

Behavior-preserving: same tests run under the same GROUP dispatch, same
assertions. Verified locally with `GROUP=Core` and `GROUP=QA` Pkg.test on
julia 1.11 — both pass.

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 (#177).

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