Skip to content

Canonicalize tests to @safetestset for module isolation#145

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

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

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

What

Wrap each independent Core test unit in @safetestset so it runs in its own module, matching the canonical OrdinaryDiffEq test structure (isolation between tests + world-age safety).

"New Nodes Tests" and "Quality Assurance" were already @safetestset. This converts the remaining Core units from @testset to @safetestset in test/runtests.jl:

  • Tuple Nodes, Bisect Search Tests, Indexing and Creation Tests, Values Indexing, Get Indices Tests, Additional Fields Test, Dynamic DiffEq Tests, Single Layer DiffEq Tests.

The @time wrappers and the GROUP dispatch ladder are unchanged.

Self-containment fixes required by per-module isolation

Under the old plain-@testset structure, include() ran in Main, so some files relied on names leaking in from earlier-run files. With each unit now its own module, those files were made self-contained:

  • bisect_search_tests.jl had no imports and relied on using MultiScaleArrays leaking from the runtests.jl @eval using ... into Main. Added using MultiScaleArrays, Test.
  • values_indexing.jl and get_indices.jl referenced Cell/Population/Tissue/Embryo with their struct definitions commented out, relying on those types leaking from indexing_and_creation_tests.jl (run earlier in Main). Restored (uncommented) the identical struct definitions.

All other included files already carried their own using blocks and struct definitions. Inner grouping @testsets inside a unit stay plain @testset (the unit-level @safetestset already isolates).

Deps

  • Bumped SafeTestsets compat to "0.1, 1" in the main Project.toml.
  • Added SafeTestsets to test/qa/Project.toml ([deps] + [compat]); the QA group activates its own env.

Verification

Behavior-preserving: same tests run under the same GROUP dispatch, same assertions.

Verified locally on Julia 1.11, GROUP=Core — all units pass:
Indexing and Creation 133, Values Indexing 55, Get Indices 19, Dynamic DiffEq 3, Single Layer DiffEq 4, New Nodes 1; Additional Fields runs with no assertions (as on master); final "Testing MultiScaleArrays tests passed".

🤖 Generated with Claude Code


This PR is a draft. Ignore until reviewed by @ChrisRackauckas.

Wrap each independent Core test unit in `@safetestset` so it runs in its
own module, matching the canonical OrdinaryDiffEq structure (isolation
between tests + world-age safety). "New Nodes Tests" and "Quality Assurance"
were already `@safetestset`; this converts the remaining seven Core units
(Tuple Nodes, Bisect Search Tests, Indexing and Creation Tests, Values
Indexing, Get Indices Tests, Additional Fields Test, Dynamic DiffEq Tests,
Single Layer DiffEq Tests) from `@testset` to `@safetestset`. The `@time`
wrappers and the GROUP dispatch ladder are unchanged.

Self-containment fixes required by per-module isolation:
- bisect_search_tests.jl had no imports and relied on `using MultiScaleArrays`
  leaking from the runtests.jl `@eval using ...` into Main; added
  `using MultiScaleArrays, Test`.
- values_indexing.jl and get_indices.jl referenced Cell/Population/Tissue/Embryo
  with their struct definitions commented out, relying on those types leaking
  from indexing_and_creation_tests.jl (run earlier in Main). Restored
  (uncommented) the identical struct definitions so each file is self-contained
  as its own module.

All other included files already carried their own `using` blocks and struct
definitions. Inner grouping `@testset`s inside a unit stay plain `@testset`
(the unit-level `@safetestset` already isolates).

Deps: bump SafeTestsets compat to "0.1, 1" in the main Project.toml and add
SafeTestsets to test/qa/Project.toml ([deps] + [compat]).

Behavior-preserving: same tests run under the same GROUP dispatch, same
assertions. Verified locally on Julia 1.11: GROUP=Core passes (all units green,
"Testing MultiScaleArrays tests passed").

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

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