Skip to content

Commit 3b858e6

Browse files
committed
use new JET functionality for skipping tests
1 parent 0ee4de6 commit 3b858e6

5 files changed

Lines changed: 42 additions & 8 deletions

File tree

‎test/Project.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ AllocCheck = "0.2"
3838
ChainRulesTestUtils = "1"
3939
Combinatorics = "1"
4040
cuTENSOR = "6"
41-
JET = "0.9, 0.10, 0.11, 0.12"
41+
JET = "0.9, 0.12"
42+
Mooncake = "0.5.45"
4243
ParallelTestRunner = "2"
4344
Test = "1"
4445
TestExtras = "0.2,0.3"

‎test/README.md‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# TensorKit.jl test suite
22

3-
Tests use [ParallelTestRunner.jl](https://github.com/vchuravy/ParallelTestRunner.jl) for parallel
4-
execution. Each test file runs in its own worker process. Shared helpers are loaded automatically
5-
via `init_code` — test files do not need to include `setup.jl` themselves.
3+
Tests use [ParallelTestRunner.jl](https://github.com/vchuravy/ParallelTestRunner.jl) for parallel execution.
4+
Each test file runs in its own worker process.
5+
Shared helpers are loaded automatically via `init_code` — test files do not need to include `setup.jl` themselves.
66

77
## Running tests
88

@@ -37,17 +37,25 @@ julia --project=test test/runtests.jl --jobs=4
3737
|-------|----------|
3838
| `symmetries` | Spaces and fusion trees |
3939
| `tensors` | Core tensor operations, factorizations, planar tensors, diagonal tensors |
40-
| `other` | Aqua code-quality checks, bug-fix regressions |
40+
| `other` | Aqua code-quality checks, JET static analysis, bug-fix regressions |
4141
| `chainrules` | ChainRulesCore AD tests |
4242
| `mooncake` | Mooncake AD tests |
4343
| `cuda` | CUDA GPU tests (only run when a functional GPU is present) |
4444

45+
JET only functions on the Julia versions it supports, which it reports through `JET.JET_AVAILABLE`.
46+
`runtests.jl` drops the JET-dependent files from the testsuite when that is `false`:
47+
`other/jet` (whole-package analysis, which additionally requires the JET 0.12 generation)
48+
and `mooncake/tangent` (reaches JET through Mooncake's extension).
49+
50+
Mooncake caps which JET versions it accepts, so the `Mooncake = "0.5.45"` floor in
51+
`test/Project.toml` is what lets JET 0.12 be resolved at all — with an older Mooncake the
52+
resolver settles on JET 0.11 and `other/jet` is silently dropped.
53+
4554
## Fast mode (`--fast`)
4655

4756
Skips `chainrules` and `mooncake` groups entirely, and reduces coverage in the remaining tests:
4857

49-
- **Sector types**: tests only `Z2Irrep`, `SU2Irrep`, `FermionParity ⊠ U1Irrep ⊠ SU2Irrep`,
50-
and `FibonacciAnyon` (instead of the full `sectorlist`)
58+
- **Sector types**: tests only `Z2Irrep`, `SU2Irrep`, `FermionParity ⊠ U1Irrep ⊠ SU2Irrep`, and `FibonacciAnyon` (instead of the full `sectorlist`)
5159
- **Space lists**: tests only `(Vtr, Vℤ₂, VSU₂)` (trivial, abelian, non-abelian)
5260
- **Scalar types**: tests only `Float64` and `ComplexF64` (instead of all integer/float variants)
5361

‎test/mooncake/tangent.jl‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ rng = Random.default_rng()
1010
spacelist = ad_spacelist(fast_tests)
1111
eltypes = (Float64, ComplexF64)
1212

13+
# `test_data` reaches JET through Mooncake's extension, so it needs a functional JET; this is also
14+
# gated in runtests.jl. JET < 0.12 does not define `JET_AVAILABLE`.
15+
jet_available = !isdefined(JET, :JET_AVAILABLE) || JET.JET_AVAILABLE
16+
1317
# only run on Linux since allocation tests are broken on other versions
14-
Sys.islinux() && @timedtestset "Mooncake - Tangent type: $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
18+
jet_available && Sys.islinux() && @timedtestset "Mooncake - Tangent type: $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
1519
A = randn(T, V[1] ⊗ V[2] ⊗ V[3] ← (V[4] ⊗ V[5])')
1620
Mooncake.TestUtils.test_data(rng, A)
1721

‎test/other/jet.jl‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using TensorKit
2+
using Test
3+
using JET
4+
5+
# also gated in runtests.jl; JET < 0.12 does not define `JET_AVAILABLE`
6+
if isdefined(JET, :JET_AVAILABLE) && JET.JET_AVAILABLE
7+
JET.test_package(TensorKit; target_modules = (TensorKit,))
8+
else
9+
@info "Full JET functionality is unavailable on Julia $VERSION; skipping JET analysis"
10+
end

‎test/runtests.jl‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ CUDA.functional() || filter!(!startswith("cuda") ∘ first, testsuite)
1313
using AMDGPU
1414
AMDGPU.functional() || filter!(!startswith("amd") ∘ first, testsuite)
1515

16+
# JET tests: JET ≥ 0.12 (Julia 1.12+) signals through `JET_AVAILABLE` whether it is functional,
17+
# and loads empty stubs when it is not. Older JET versions, still needed on Julia < 1.12, do not
18+
# define it, hence the `isdefined` check instead of `using JET: JET_AVAILABLE`.
19+
using JET: JET
20+
const jet_new_generation = isdefined(JET, :JET_AVAILABLE)
21+
const jet_available = !jet_new_generation || JET.JET_AVAILABLE
22+
# whole-package analysis is pinned to the JET 0.12 generation, so its reports need not be curated for several JET/Julia combinations
23+
(jet_new_generation && jet_available) || delete!(testsuite, "other/jet")
24+
# Mooncake's tangent tests reach JET through Mooncake's extension: any functional JET works, the empty stubs do not
25+
jet_available || delete!(testsuite, "mooncake/tangent")
26+
1627
# On Buildkite (GPU CI runner): only run CUDA and AMDGPU tests
1728
if get(ENV, "BUILDKITE", "false") == "true"
1829
f(str) = startswith(first(str), "cuda") || startswith(first(str), "amd")

0 commit comments

Comments
 (0)