|
| 1 | +# TensorKit.jl test suite |
| 2 | + |
| 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. |
| 6 | + |
| 7 | +## Running tests |
| 8 | + |
| 9 | +```julia |
| 10 | +# Standard — works on all supported Julia versions |
| 11 | +using Pkg; Pkg.test() |
| 12 | +``` |
| 13 | + |
| 14 | +```bash |
| 15 | +# Direct invocation — requires Julia 1.12+ (workspace support) |
| 16 | +julia --project=test test/runtests.jl |
| 17 | + |
| 18 | +# Run only a specific group (directory prefix) |
| 19 | +julia --project=test test/runtests.jl symmetries |
| 20 | + |
| 21 | +# Run only a specific file |
| 22 | +julia --project=test test/runtests.jl tensors/factorizations |
| 23 | + |
| 24 | +# Fast mode: fewer sectors, fewer scalar types, AD tests skipped |
| 25 | +julia --project=test test/runtests.jl --fast |
| 26 | + |
| 27 | +# Combine --fast with a group or file filter |
| 28 | +julia --project=test test/runtests.jl --fast tensors |
| 29 | + |
| 30 | +# Control parallelism |
| 31 | +julia --project=test test/runtests.jl --jobs=4 |
| 32 | +``` |
| 33 | + |
| 34 | +## Test groups |
| 35 | + |
| 36 | +| Group | Contents | |
| 37 | +|-------|----------| |
| 38 | +| `symmetries` | Spaces and fusion trees | |
| 39 | +| `tensors` | Core tensor operations, factorizations, planar tensors, diagonal tensors | |
| 40 | +| `other` | Aqua code-quality checks, bug-fix regressions | |
| 41 | +| `chainrules` | ChainRulesCore AD tests | |
| 42 | +| `mooncake` | Mooncake AD tests | |
| 43 | +| `cuda` | CUDA GPU tests (only run when a functional GPU is present) | |
| 44 | + |
| 45 | +## Fast mode (`--fast`) |
| 46 | + |
| 47 | +Skips `chainrules` and `mooncake` groups entirely, and reduces coverage in the remaining tests: |
| 48 | + |
| 49 | +- **Sector types**: tests only `Z2Irrep`, `SU2Irrep`, `FermionParity ⊠ U1Irrep ⊠ SU2Irrep`, |
| 50 | + and `FibonacciAnyon` (instead of the full `sectorlist`) |
| 51 | +- **Space lists**: tests only `(Vtr, Vℤ₂, VSU₂)` (trivial, abelian, non-abelian) |
| 52 | +- **Scalar types**: tests only `Float64` and `ComplexF64` (instead of all integer/float variants) |
| 53 | + |
| 54 | +## `setup.jl` |
| 55 | + |
| 56 | +Defines the `TestSetup` module, which is loaded into every worker sandbox automatically. It |
| 57 | +exports: |
| 58 | + |
| 59 | +- **Spaces**: `Vtr`, `Vℤ₂`, `Vfℤ₂`, `Vℤ₃`, `VU₁`, `VfU₁`, `VCU₁`, `VSU₂`, `VfSU₂`, |
| 60 | + `VSU₂U₁`, `Vfib`, `VIB_diag`, `VIB_M` |
| 61 | +- **Sector lists**: `sectorlist` (full), `fast_sectorlist` (reduced) |
| 62 | +- **Utilities**: `randsector`, `smallset`, `hasfusiontensor`, `force_planar`, `random_fusion`, |
| 63 | + `randindextuple`, `randcircshift`, `_repartition`, `trivtuple`, `test_dim_isapprox`, `default_tol` |
| 64 | + |
| 65 | +The `fast_tests::Bool` constant is also available in every test file (injected alongside |
| 66 | +`TestSetup` via `init_code` in `runtests.jl`). |
| 67 | + |
| 68 | +## Adding a new test file |
| 69 | + |
| 70 | +Create a `.jl` file anywhere under `test/`. It is auto-discovered by `ParallelTestRunner` and |
| 71 | +must be self-contained (worker processes have no shared state). `TestSetup` and `fast_tests` are |
| 72 | +already in scope — no include needed. |
| 73 | + |
| 74 | +```julia |
| 75 | +using Test, TestExtras |
| 76 | +using TensorKit |
| 77 | + |
| 78 | +@testset "My tests" begin |
| 79 | + # fast_tests and all TestSetup exports (Vtr, sectorlist, …) are available here |
| 80 | +end |
| 81 | +``` |
0 commit comments