Skip to content

std.testing Katana Harness

Janus now ships the SPEC-241 std.testing Katana harness.

The completed surface keeps testing inside ordinary Janus:

use std.testing
test "reread count is preserved" do
const reread = try read_index(...)
try testing.expect_equal[usize](1, reread.count)
end

The shipped harness covers:

  • test "..." do ... end discovery through janus test
  • core assertions: expect, expect_equal, expect_not_equal, expect_equal_slices, expect_error, expect_no_error, expect_approx_abs, and expect_approx_rel
  • Zig-heritage migration aliases for expectEqual and expectEqualSlices
  • source-location diagnostics with expected/actual values
  • slice mismatch diagnostics with length and first differing index
  • TestCtx and capability-backed resource helpers
  • subtest paths selectable with --only
  • dynamic skips, tag skips, xfail, and xpass reporting
  • compile-fail tests with structured diagnostic checks
  • explicit golden updates through --update-golden
  • opt-in benchmarks through --bench
  • runner-enforced TestingAllocator leak detection

The runner now fails a test when allocator accounting is unbalanced at test end, even if the test body forgot to call expect_no_leaks.

leak detected
allocations: 1
frees: 0
outstanding: 1

That is the right default for a systems language. Leaks are not vibes; they are observable evidence.

Terminal window
janus test <source.jan>
janus test <source.jan> --only "suite/case"
janus test <source.jan> --skip-tag slow
janus test <source.jan> --seed 12345
janus test <source.jan> --jobs 8
janus test <source.jan> --bench
janus test <source.jan> --json
janus test <source.jan> --update-golden
janus test --help

janus test --help now reports command help instead of treating --help as a file path.

Terminal window
./scripts/zb
./scripts/zb test-std-testing
./scripts/zb test-gap38-testing-allocator
git diff --check

The dedicated test-std-testing gate proves assertions, error helpers, diagnostics, subtest filtering, skips, xfail/xpass, compile-fail tests, goldens, benchmark reporting, service authority checks, and leak reporting.