build(justfile): run the test recipes under the memory fence

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-10-02 16:15:02 +02:00
parent bc4ac93fd9
commit 1107928870
+9 -5
View File
@@ -28,14 +28,15 @@ build:
# The test gate: the suite, no cache, the coverage floor.
test:
#!/usr/bin/env perl
system(q{go}, q{test}, q{-count=1}, q{-timeout}, q{10m},
my @fence = qw{systemd-run --user --scope -p MemoryMax=4G -p MemorySwapMax=0};
system(@fence, q{go}, q{test}, q{-count=1}, q{-timeout}, q{10m},
q{-coverprofile}, q{coverage.out}, qw({{packages}})) == 0
or die qq{the test suite failed\n};
# The packages outside the coverage set carry tests of their own: the CLI's
# exit codes and manual-page guard, and the debugger's architecture-neutral
# units. They run without a profile, because a thin main and a ptrace-bound
# package would drag the floor down rather than measure the product.
system(q{go}, q{test}, q{-count=1}, q{-timeout}, q{10m},
system(@fence, q{go}, q{test}, q{-count=1}, q{-timeout}, q{10m},
q{./cmd/...}, q{./debug/...}) == 0
or die qq{the tests outside the coverage set failed\n};
open(my $c, q{-|}, q{go}, q{tool}, q{cover}, q{-func=coverage.out}) or die qq{cover: $!};
@@ -48,15 +49,18 @@ test:
# The same suite under the race detector. The expensive one.
race:
go test -race -count=1 -timeout 10m {{packages}}
# Ceiling 16G, not the default 4G: with every package in parallel the race
# footprint peaks over 8G (8G died in the parser package, 16G passed,
# measured 2026-10-02), and the wide machine at the keyboard can carry it.
systemd-run --user --scope -p MemoryMax=16G -p MemorySwapMax=0 go test -race -count=1 -timeout 10m {{packages}}
# Fast scoped run for iterating. This is the one that runs after every edit.
unit pkgs=packages run=".*":
go test {{pkgs}} -run '{{run}}'
systemd-run --user --scope -p MemoryMax=4G -p MemorySwapMax=0 go test {{pkgs}} -run '{{run}}'
# Time-boxed fuzz of one target in one package. The package is required; never a gate.
fuzz target pkg fuzztime="60s":
go test -run '^$' -fuzz '{{target}}' -fuzztime={{fuzztime}} {{pkg}}
systemd-run --user --scope -p MemoryMax=4G -p MemorySwapMax=0 go test -run '^$' -fuzz '{{target}}' -fuzztime={{fuzztime}} {{pkg}}
# Benchmarks. On an idle machine only.
bench pkgs=packages: