test(prune): don't enforce wall-clock budget under -race (#4624)

TestPruneLargeFixture's <5s budget is invalid under the race detector (~20s vs ~1.2s). The Main integration cmd/bd shard runs with -race; gate the timing assertion on a build-tag raceEnabled flag so only non-race builds enforce it. Correctness assertions still run under -race.
This commit is contained in:
Julian Knutsen 2026-07-07 01:04:25 -07:00 • committed by GitHub
commit d84fb1e5ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 2 deletions

View file

@ -97,8 +97,12 @@ func TestPruneLargeFixture(t *testing.T) {
t.Fatalf("buildReferencedSet error: %v", err)
}
// Performance assertion (NFR-02).
if elapsed > maxDurationSeconds*time.Second {
// Performance assertion (NFR-02). The race detector adds multi-x overhead
// that invalidates a wall-clock budget (buildReferencedSet measures ~4x
// slower under -race), so only enforce the bound in non-race builds. The
// correctness assertions below still run under -race, which is where the
// large-fixture pass earns its keep as a data-race check.
if !raceEnabled && elapsed > maxDurationSeconds*time.Second {
t.Errorf("buildReferencedSet took %v; must complete in <%ds on 10K-bead fixture", elapsed, maxDurationSeconds)
}

View file

@ -0,0 +1,6 @@
//go:build !race
package main
// raceEnabled is false in non-race builds; see race_detector_on_test.go.
const raceEnabled = false

View file

@ -0,0 +1,9 @@
//go:build race
package main
// raceEnabled reports whether the test binary was built with the race
// detector (-race). Wall-clock performance budgets are unreliable under
// race instrumentation (it adds multi-x overhead), so timing-sensitive
// benches consult this flag before enforcing a duration bound.
const raceEnabled = true