Skip to content

Commit 9c8a64e

Browse files
committed
Split JET tests into nopre group and exclude from pre tests
1 parent 31c9976 commit 9c8a64e

4 files changed

Lines changed: 122 additions & 101 deletions

File tree

.github/workflows/Tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26+
group:
27+
- Core
28+
- nopre
2629
version:
2730
- '1'
2831
- 'lts'
2932
- 'pre'
3033
arch:
3134
- x64
35+
exclude:
36+
- version: 'pre'
37+
group: 'nopre'
3238
uses: "SciML/.github/.github/workflows/tests.yml@v1"
3339
with:
40+
group: "${{ matrix.group }}"
3441
julia-version: "${{ matrix.version }}"
3542
julia-arch: "${{ matrix.arch }}"
3643
secrets: "inherit"

test/basictests.jl

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using FunctionWrappersWrappers
2+
using Test
3+
4+
@testset "FunctionWrappersWrappers.jl" begin
5+
fwplus = FunctionWrappersWrapper(+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
6+
Float64, Int));
7+
@test fwplus(4.0, 8.0) === 12.0
8+
@test fwplus(4, 8) === 12
9+
10+
fwexp2 = FunctionWrappersWrapper(
11+
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64));
12+
@test fwexp2(4.0) === 16.0
13+
@test fwexp2(4.0f0) === 16.0f0
14+
@test fwexp2(4) === 16.0
15+
end
16+
17+
@testset "Type inference" begin
18+
# Test return type inference
19+
fwplus = FunctionWrappersWrapper(+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
20+
Float64, Int))
21+
@test @inferred(fwplus(4.0, 8.0)) === 12.0
22+
@test @inferred(fwplus(4, 8)) === 12
23+
24+
fwexp2 = FunctionWrappersWrapper(
25+
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64))
26+
@test @inferred(fwexp2(4.0)) === 16.0
27+
@test @inferred(fwexp2(4.0f0)) === 16.0f0
28+
@test @inferred(fwexp2(4)) === 16.0
29+
end
30+
31+
@testset "Introspection functions" begin
32+
# Test with a simple function
33+
fwsin = FunctionWrappersWrapper(sin, (Tuple{Float64},), (Float64,))
34+
35+
@testset "unwrap" begin
36+
f = unwrap(fwsin)
37+
@test f === sin
38+
@test f(0.5) == sin(0.5)
39+
end
40+
41+
@testset "wrapped_signatures" begin
42+
sigs = wrapped_signatures(fwsin)
43+
@test sigs == (Tuple{Float64},)
44+
end
45+
46+
@testset "wrapped_return_types" begin
47+
rets = wrapped_return_types(fwsin)
48+
@test rets == (Float64,)
49+
end
50+
51+
# Test with multiple signatures
52+
fwplus = FunctionWrappersWrapper(+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
53+
Float64, Int))
54+
55+
@testset "unwrap with multiple signatures" begin
56+
f = unwrap(fwplus)
57+
@test f === +
58+
@test f(1, 2) == 3
59+
end
60+
61+
@testset "wrapped_signatures with multiple signatures" begin
62+
sigs = wrapped_signatures(fwplus)
63+
@test sigs == (Tuple{Float64, Float64}, Tuple{Int, Int})
64+
end
65+
66+
@testset "wrapped_return_types with multiple signatures" begin
67+
rets = wrapped_return_types(fwplus)
68+
@test rets == (Float64, Int)
69+
end
70+
71+
# Test with a custom function
72+
my_func(x) = x^2
73+
fwcustom = FunctionWrappersWrapper(my_func, (Tuple{Float64}, Tuple{Int}), (
74+
Float64, Int))
75+
76+
@testset "unwrap with custom function" begin
77+
f = unwrap(fwcustom)
78+
@test f === my_func
79+
@test f(3) == 9
80+
@test f(2.5) == 6.25
81+
end
82+
end

test/jet_tests.jl

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

test/runtests.jl

Lines changed: 7 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,13 @@
1-
using FunctionWrappersWrappers
21
using Test
32

4-
@testset "FunctionWrappersWrappers.jl" begin
5-
fwplus = FunctionWrappersWrapper(+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
6-
Float64, Int));
7-
@test fwplus(4.0, 8.0) === 12.0
8-
@test fwplus(4, 8) === 12
9-
10-
fwexp2 = FunctionWrappersWrapper(
11-
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64));
12-
@test fwexp2(4.0) === 16.0
13-
@test fwexp2(4.0f0) === 16.0f0
14-
@test fwexp2(4) === 16.0
15-
end
16-
17-
using JET: JET, @test_opt
18-
19-
@testset "JET static analysis" begin
20-
# Test that the main call path is type-stable (no fallback)
21-
fwplus = FunctionWrappersWrapper(+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
22-
Float64, Int))
23-
24-
# Core functionality should be type-stable
25-
@test_opt target_modules = (FunctionWrappersWrappers,) fwplus(4.0, 8.0)
26-
@test_opt target_modules = (FunctionWrappersWrappers,) fwplus(4, 8)
27-
28-
# Test single-argument wrapper
29-
fwexp2 = FunctionWrappersWrapper(
30-
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64))
31-
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4.0)
32-
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4.0f0)
33-
@test_opt target_modules = (FunctionWrappersWrappers,) fwexp2(4)
34-
35-
# Verify no errors detected by JET.report_call for core paths
36-
rep = JET.report_call(fwplus, (Float64, Float64))
37-
@test length(JET.get_reports(rep)) == 0
38-
rep = JET.report_call(fwplus, (Int, Int))
39-
@test length(JET.get_reports(rep)) == 0
40-
end
41-
42-
@testset "Type inference" begin
43-
# Test return type inference
44-
fwplus = FunctionWrappersWrapper(+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
45-
Float64, Int))
46-
@test @inferred(fwplus(4.0, 8.0)) === 12.0
47-
@test @inferred(fwplus(4, 8)) === 12
48-
49-
fwexp2 = FunctionWrappersWrapper(
50-
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64))
51-
@test @inferred(fwexp2(4.0)) === 16.0
52-
@test @inferred(fwexp2(4.0f0)) === 16.0f0
53-
@test @inferred(fwexp2(4)) === 16.0
54-
end
55-
56-
@testset "Introspection functions" begin
57-
# Test with a simple function
58-
fwsin = FunctionWrappersWrapper(sin, (Tuple{Float64},), (Float64,))
59-
60-
@testset "unwrap" begin
61-
f = unwrap(fwsin)
62-
@test f === sin
63-
@test f(0.5) == sin(0.5)
64-
end
3+
const GROUP = get(ENV, "GROUP", "All")
654

66-
@testset "wrapped_signatures" begin
67-
sigs = wrapped_signatures(fwsin)
68-
@test sigs == (Tuple{Float64},)
69-
end
70-
71-
@testset "wrapped_return_types" begin
72-
rets = wrapped_return_types(fwsin)
73-
@test rets == (Float64,)
74-
end
75-
76-
# Test with multiple signatures
77-
fwplus = FunctionWrappersWrapper(+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
78-
Float64, Int))
79-
80-
@testset "unwrap with multiple signatures" begin
81-
f = unwrap(fwplus)
82-
@test f === +
83-
@test f(1, 2) == 3
84-
end
85-
86-
@testset "wrapped_signatures with multiple signatures" begin
87-
sigs = wrapped_signatures(fwplus)
88-
@test sigs == (Tuple{Float64, Float64}, Tuple{Int, Int})
89-
end
90-
91-
@testset "wrapped_return_types with multiple signatures" begin
92-
rets = wrapped_return_types(fwplus)
93-
@test rets == (Float64, Int)
5+
@testset "FunctionWrappersWrappers.jl" begin
6+
if GROUP == "All" || GROUP == "Core"
7+
include("basictests.jl")
948
end
959

96-
# Test with a custom function
97-
my_func(x) = x^2
98-
fwcustom = FunctionWrappersWrapper(my_func, (Tuple{Float64}, Tuple{Int}), (
99-
Float64, Int))
100-
101-
@testset "unwrap with custom function" begin
102-
f = unwrap(fwcustom)
103-
@test f === my_func
104-
@test f(3) == 9
105-
@test f(2.5) == 6.25
10+
if GROUP == "All" || GROUP == "nopre"
11+
include("jet_tests.jl")
10612
end
107-
end
13+
end

0 commit comments

Comments
 (0)