Canonicalize tests around @safetestset (isolation, matches OrdinaryDiffEq)#45
Closed
ChrisRackauckas-Claude wants to merge 1 commit into
Closed
Conversation
…ffEq)
Wrap each independent top-level test unit in `@safetestset` so it runs in
its own fresh module, matching OrdinaryDiffEq's canonical structure
(per-unit isolation + world-age safety).
The `@safetestset` body must be self-contained: a body is macroexpanded as
one unit, so `using ConcreteStructs` followed by in-body `@concrete` usage
fails (the import hasn't taken effect when `@concrete` is resolved). The
canonical fix is `@safetestset "X" begin include("x.jl") end`, where the
included file carries its own top-level `using` lines (resolved before the
macros are reached). The unit bodies of core.jl are therefore split into
unit_tests.jl, end_to_end_tests.jl, issue_3.jl, commutation_tests.jl, each
self-contained. qa.jl's Aqua/JET units and the "Invalid usage error path"
unit in runtests.jl become `@safetestset` with their own imports.
Nested grouping `@testset`s inside a unit stay plain (the unit-level
`@safetestset` already isolates). GROUP dispatch, run logic, and assertions
are unchanged.
SafeTestsets added to test/Project.toml and test/qa/Project.toml deps +
compat ("0.1, 1").
Behavior-preserving, verified locally on Julia 1.11:
GROUP=Core: Unit 23, End-to-end 11, Issue SciML#3 1, Commutation 4, Invalid 1
GROUP=QA: Aqua 11, JET 1, Invalid 1
All: all of the above
identical to the pre-conversion baseline.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Superseded by the v1.2 folder conversion on sciml-testing-rollout (#44). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Canonicalizes the test suite around
@safetestsetso each independent top-level test unit runs in its own fresh module, matching OrdinaryDiffEq's structure (per-unit isolation + world-age safety). This is the pilot for a fan-out across SciML repos.Classification
ConcreteStructs.jl was a plain-
@testsetrepo: independent units were plain@testsetblocks at file scope, sharing module-level setup. Converted to@safetestset.Before -> after pattern
Each independent unit
@testset "X" begin BODY endbecomes@safetestset "X" begin BODY end. A@safetestsetbody expands to a fresh module and is macroexpanded as one unit, so an in-bodyusing ConcreteStructsdoes not take effect before in-body@concreteusage is resolved (UndefVarError). The canonical fix (same as OrdinaryDiffEq) is:where
x.jlcarries its own top-levelusinglines (resolved before the package macros are reached).test/core.jlis now a thin@safetestset ... include(...)dispatcher. Its four units are split into self-contained files:unit_tests.jl,end_to_end_tests.jl,issue_3.jl,commutation_tests.jl, each with its ownusinglines (ConcreteStructs, and as neededLinearAlgebra: Adjoint,Suppressor,Test, or the internalConcreteStructs: _parse_line, ...helpers).@testsets inside a unit (e.g._parse_line,_parse_headinside "Unit tests") stay plain@testset— the unit-level@safetestsetalready isolates.test/qa/qa.jl: the Aqua and JET units become@safetestsetwith their ownusinglines.test/runtests.jl: the top-level "Invalid usage error path" unit becomes@safetestset(self-containedusing ConcreteStructs; using Test);using SafeTestsetsadded at the top.SafeTestsetsadded totest/Project.tomlandtest/qa/Project.tomldeps +[compat] SafeTestsets = "0.1, 1".Unchanged
GROUP dispatch ladder, run logic, and all assertions are untouched. The
run_tests/harness migration is a separate branch.Verification (Julia 1.11, local)
Identical assertion counts to the pre-conversion baseline:
GROUP=Core: Unit tests 23, End-to-end 11, Issue Feature Request: Type Constraints #3 1, Commutation 4, Invalid usage 1 — passedGROUP=QA: Aqua 11, JET 1, Invalid usage 1 — passedAll(GROUP unset): all of the above — passedIgnore until reviewed by @ChrisRackauckas.
🤖 Generated with Claude Code