Skip to content

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

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#155
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:canonicalize-safetestset

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

What

Converts the independent top-level test units in test/runtests.jl from plain @testset to @safetestset, so each unit runs in its own freshly generated module. This matches the canonical OrdinaryDiffEq test structure (isolation between tests + world-age safety).

How

Each unit body is extracted into its own self-contained file and invoked as @safetestset "X" begin include("x.jl") end:

Unit File
Explicit Imports explicit_imports.jl (already self-contained upstream)
Examples examples_tests.jl (set_log_level + parametrized example loop)
Creation creation_tests.jl (includes test_create/test_pycreate/test_jfem)
assign assign_tests.jl
Interface interface_tests.jl
  • Each new extracted file carries its own using FEniCS / using Test.
  • The include() form (not an inline @safetestset body) is used so imports run before any FEniCS symbols are resolved, and include paths resolve relative to test/ as before.
  • The parametrized example loop and other inner @testsets stay plain @testset — the unit-level @safetestset already isolates them.
  • SafeTestsets added to test deps ([extras] + [targets].test, [compat] SafeTestsets = "0.1, 1").

Same units run in the same order with the same assertions; only the isolation mechanism changed.

Verification

FEniCS requires the FEniCS Python stack (CI runs in the cmhyett/julia-fenics container), which isn't available for a local run here. Verified statically: Meta.parseall is clean on all test files, each @safetestset carries its needed imports, the @safetestset "X" begin include(...) end shape was smoke-tested against SafeTestsets, and the files pass Runic --check. CI will run the actual suite.


Ignore until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code

Convert the independent top-level test units in test/runtests.jl from
plain `@testset` to `@safetestset`, so each unit runs in its own freshly
generated module (matching the canonical OrdinaryDiffEq structure for
isolation between tests and world-age safety).

Each unit body is extracted into its own self-contained file and invoked
as `@safetestset "X" begin include("x.jl") end`:
  - explicit_imports.jl (Explicit Imports; already self-contained upstream)
  - examples_tests.jl   (Examples: set_log_level + parametrized example loop)
  - creation_tests.jl   (Creation: includes test_create/test_pycreate/test_jfem)
  - assign_tests.jl     (assign)
  - interface_tests.jl  (Interface)

Each new extracted file carries its own `using FEniCS` / `using Test`.
The include() form (rather than an inline @safetestset body) is used so
imports run before any FEniCS symbols are resolved, and include paths
resolve relative to test/ as before. The parametrized example loop and
other inner testsets stay plain @testset since the unit-level
@safetestset already isolates them.

Add SafeTestsets to test deps ([extras] + [targets].test, compat "0.1, 1").

Same units run in the same order with the same assertions; only the
isolation mechanism changed. FEniCS requires the FEniCS Python stack
(CI container cmhyett/julia-fenics), so this is verified statically
(Meta.parseall clean on all test files; each @safetestset has its
imports); CI will run the suite.

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 SciMLTesting v1.2 PR #154 (grouped-tests + run_tests + @safetestset). Closing this canonicalize-only PR.

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