Skip to content

Commit 1f63884

Browse files
Canonicalize tests to @safetestset for module isolation
Wrap each independent top-level test unit in `@safetestset` so it runs in its own module, matching the canonical OrdinaryDiffEq structure (per-unit isolation + world-age safety). The GROUP dispatch ladder (All/Core/nopre), the nopre activated-env path, and all assertions are unchanged. Units converted: - runtests.jl: `@testset "FunctionWrappersWrappers.jl" begin include("basictests.jl") end` -> `@safetestset ... begin include("basictests.jl") end`. basictests.jl already carries its own `using FunctionWrappersWrappers` / `using Test`, and its inner grouping `@testset`s stay plain (the file-level @safetestset already isolates the unit as one module). - runtests.jl: "BigFloat support" and "UnionAll return types" -> @safetestset, each with self-contained `using FunctionWrappersWrappers` / `using Test`. - nopre/jet_tests.jl: "JET static analysis" -> @safetestset. Because the body uses the `@test_opt` package macro (which must be imported before the body is macroexpanded), the body was extracted to nopre/jet_tests_impl.jl (top-level `using JET: @test_opt` runs before any `@test_opt` is parsed) and the @safetestset just does `include("jet_tests_impl.jl")` — the canonical OrdinaryDiffEq shape. Inline would hit `UndefVarError: @test_opt`. Add SafeTestsets to test deps: main Project.toml [extras]/[targets].test/[compat] and nopre/Project.toml [deps] (the nopre env is activated + instantiated at run time, so instantiate resolves SafeTestsets without a pre-baked Manifest entry). Verified locally on Julia 1.11: GROUP=All passes (21 + 5 + 2) and GROUP=nopre passes (7 + 5 + 2). Runic-clean. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f45aed9 commit 1f63884

5 files changed

Lines changed: 45 additions & 32 deletions

File tree

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ TruncatedStacktraces = "781d530d-4396-4725-bb49-402e4bee1e77"
1111
[compat]
1212
FunctionWrappers = "1"
1313
PrecompileTools = "1"
14+
SafeTestsets = "0.1, 1"
1415
TruncatedStacktraces = "1"
1516
julia = "1.10"
1617

1718
[extras]
1819
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
20+
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
1921
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2022

2123
[targets]
22-
test = ["Pkg", "Test"]
24+
test = ["Pkg", "Test", "SafeTestsets"]

test/nopre/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[deps]
22
FunctionWrappersWrappers = "77dc65aa-8811-40c2-897b-53d922fa7daf"
33
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
4+
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
45
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/nopre/jet_tests.jl

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
1-
using FunctionWrappersWrappers
2-
using JET: JET, @test_opt
3-
using Test
1+
using SafeTestsets
42

5-
@testset "JET static analysis" begin
6-
# Test that the main call path is type-stable (no fallback)
7-
fwplus = FunctionWrappersWrapper(
8-
+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
9-
Float64, Int,
10-
)
11-
)
12-
13-
# Core functionality should be type-stable
14-
@test_opt target_modules = (FunctionWrappersWrappers,) fwplus(4.0, 8.0)
15-
@test_opt target_modules = (FunctionWrappersWrappers,) fwplus(4, 8)
16-
17-
# Test single-argument wrapper
18-
fwexp2 = FunctionWrappersWrapper(
19-
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64)
20-
)
21-
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4.0)
22-
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4.0f0)
23-
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4)
24-
25-
# Verify no errors detected by JET.report_call for core paths
26-
rep = JET.report_call(fwplus, (Float64, Float64))
27-
@test length(JET.get_reports(rep)) == 0
28-
rep = JET.report_call(fwplus, (Int, Int))
29-
@test length(JET.get_reports(rep)) == 0
3+
@safetestset "JET static analysis" begin
4+
include("jet_tests_impl.jl")
305
end

test/nopre/jet_tests_impl.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using FunctionWrappersWrappers
2+
using JET: JET, @test_opt
3+
using Test
4+
5+
# Test that the main call path is type-stable (no fallback)
6+
fwplus = FunctionWrappersWrapper(
7+
+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
8+
Float64, Int,
9+
)
10+
)
11+
12+
# Core functionality should be type-stable
13+
@test_opt target_modules = (FunctionWrappersWrappers,) fwplus(4.0, 8.0)
14+
@test_opt target_modules = (FunctionWrappersWrappers,) fwplus(4, 8)
15+
16+
# Test single-argument wrapper
17+
fwexp2 = FunctionWrappersWrapper(
18+
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64)
19+
)
20+
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4.0)
21+
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4.0f0)
22+
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4)
23+
24+
# Verify no errors detected by JET.report_call for core paths
25+
rep = JET.report_call(fwplus, (Float64, Float64))
26+
@test length(JET.get_reports(rep)) == 0
27+
rep = JET.report_call(fwplus, (Int, Int))
28+
@test length(JET.get_reports(rep)) == 0

test/runtests.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using Test, Pkg
2+
using SafeTestsets
23

34
const GROUP = get(ENV, "GROUP", "All")
45

56
if GROUP == "All" || GROUP == "Core"
6-
@testset "FunctionWrappersWrappers.jl" begin
7+
@safetestset "FunctionWrappersWrappers.jl" begin
78
include("basictests.jl")
89
end
910
end
@@ -15,7 +16,10 @@ if GROUP == "nopre"
1516
include("nopre/jet_tests.jl")
1617
end
1718

18-
@testset "BigFloat support" begin
19+
@safetestset "BigFloat support" begin
20+
using FunctionWrappersWrappers
21+
using Test
22+
1923
fwplus_big = FunctionWrappersWrapper(
2024
+,
2125
(Tuple{BigFloat, BigFloat}, Tuple{Float64, Float64}),
@@ -36,7 +40,10 @@ end
3640
@test fwsin_big(1.0) === sin(1.0)
3741
end
3842

39-
@testset "UnionAll return types" begin
43+
@safetestset "UnionAll return types" begin
44+
using FunctionWrappersWrappers
45+
using Test
46+
4047
# Test that UnionAll types (like AbstractArray{Float64}) work as return types
4148
function double_array(x::AbstractArray{Float64})
4249
return x .* 2

0 commit comments

Comments
 (0)