Attributes
All attributes live in sparkles.test_runner.attributes and are plain marker types — a test annotated with them remains an ordinary unittest block for any other runner. Import them unconditionally (not under version (unittest)): unittest UDAs are resolved even in builds that do not compile the unittest bodies.
@betterC
The test is -betterC-compatible (no GC, exceptions, TypeInfo, druntime).
- Runs normally under
dub test. --better-cextracts it into a standalone druntime-free program.- The body may only use the module's public symbols; templates/CTFE-able code by default, plus modules opted in with
--include-import.
@ctfe
The test runs at compile time instead of runtime.
- Evaluated through CTFE by a runner-generated probe compiled with
-o- -unittest(semantic analysis only) after-i/-efiltering — so filters control which tests execute, and--help/--listwork even when an@ctfetest would fail. - Reported as
⚙ … (compile time)on success,✗ … (compile time)plus the compiler's CTFE error trail on failure; never executed at runtime. - The body must be CTFE-able; needs a D compiler on
PATH(or$DC/--compiler) at run time. - Named after (and forward-compatible with) DMD 2.113's
@__ctfefunction attribute.
@wasm
The test is WebAssembly-compatible.
- Runs normally under
dub test. --wasmcross-compiles it towasm32with LDC and runs it undernode/deno/bun/wasmtime.- All
@betterCconstraints apply, and with a stock LDC the module's import chain must avoid druntime headers that do not supportwasm32.
@benchmark / @benchmark(iterations: N)
The test is a benchmark.
- Skipped by normal runs (counted in the summary); measured by
--bench. iterationspins the count;0(default) auto-scales. Batched timing (benchIter/whole-body) pins the per-sample iteration count; a per-callbenchCaseruns exactly N timed calls, one sample each.- The whole body is the measured unit by default. From
sparkles.test_runner.bench:benchItermeasures a sub-section,benchCaseemits many rows from one test (a matrix, withMetricthroughput columns), andblackBoxis the optimizer barrier. --perfadds Linuxperf_eventhardware-counter columns (IPC, instructions/iter, cache/branch miss rates) to the--benchtable.
Combining
Attributes compose freely — e.g. @betterC @wasm opts one test into both extra environments; @("name") string UDAs keep naming the test.