Canonicalize tests to @safetestset for per-unit module isolation#315
Closed
ChrisRackauckas-Claude wants to merge 1 commit into
Closed
Canonicalize tests to @safetestset for per-unit module isolation#315ChrisRackauckas-Claude wants to merge 1 commit into
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
Convert each independent test unit in runtests.jl from `@testset "X" begin
include("x.jl") end` to `@safetestset "X" begin include("x.jl") end` so that
every unit runs in its own freshly-evaluated module (isolation between tests
plus world-age safety), matching OrdinaryDiffEq's canonical structure. The
outer `@testset "DiffEqCallbacks"` summary wrapper and the GROUP-dispatch
ladder (QA / Core / NoPre) are left unchanged.
Make the now-isolated units self-contained:
- independentlylinearizedtests.jl previously relied on `ReturnCode` leaking
into shared Main from a sibling file; add `using SciMLBase: ReturnCode`
(same source periodic_tests.jl already imports it from).
- integrating_GK_sum_tests.jl relied on helper functions defined at file
scope in integrating_GK_tests.jl leaking through shared Main. Extract those
shared helpers (compute_dGdp, compute_dGdp_nt, simple_linear_system,
adjoint_linear[_inplace], analytical_derivative, callback_saving_linear[_inplace])
verbatim into test/integrating_GK_shared.jl and have both files include it.
Add SafeTestsets to the test deps (root [extras]/[targets].test + [compat],
and test/nopre/Project.toml since the NoPre group activates its own env).
Behavior-preserving: no assertion logic changed; the same @test/@test_throws
run, and the full GROUP=Core suite passes locally (329 passing, 0 fail/error).
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 (#316). |
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
Converts each independent test unit in
test/runtests.jlfromto
so every unit runs in its own freshly-evaluated module — giving isolation between tests and world-age safety, matching OrdinaryDiffEq's canonical test structure. The outer
@testset "DiffEqCallbacks"summary wrapper and theGROUP-dispatch ladder (QA / Core / NoPre), including thePkg.activate("nopre")/develop/instantiateblock, are unchanged.Self-containment fixes (latent bugs surfaced by isolation)
Two units previously relied on symbols leaking through the shared
Mainnamespace when all files wereincluded into the same module. With per-module isolation these becameUndefVarErrors, so the missing dependencies are now made explicit:independentlylinearizedtests.jlusedReturnCode.Defaultbut only importedTest, DiffEqCallbacks;ReturnCodeleaked in from a sibling file. Addedusing SciMLBase: ReturnCode(the same sourceperiodic_tests.jlalready imports it from).integrating_GK_sum_tests.jlreused helper functions (compute_dGdp,simple_linear_system,adjoint_linear,adjoint_linear_inplace,analytical_derivative,callback_saving_linear,callback_saving_linear_inplace) that were defined at file scope inintegrating_GK_tests.jland leaked throughMain. Those helpers were extracted verbatim into a newtest/integrating_GK_shared.jl, and both files nowincludeit.No assertion logic was changed; the same
@test/@test_throwslines run. Nested grouping@testsets inside a unit stay plain@testset(the unit-level@safetestsetalready isolates).Deps
Added
SafeTestsetsto the test dependencies: root[extras]+[targets].test+[compat] SafeTestsets = "0.1, 1", and totest/nopre/Project.toml([deps]+[compat]) since theNoPregroup activates its own environment.Verification
GROUP=CorePkg.test()run locally on Julia 1.11: 329 passing, 0 failed, 0 errored (Testing DiffEqCallbacks tests passed). NoPre/QA groups will be exercised by CI.Ignore until reviewed by @ChrisRackauckas.
🤖 Generated with Claude Code