fix: preserve bun:test sub-APIs in relink test wrapper

The previous commit wrapped bun:test's `test` to bump the per-test
timeout default to 15s but cast the wrapper `as typeof _bunTest`
without copying the sub-properties (`.only`, `.skip`, `.each`,
`.todo`, `.failing`, `.if`) from the original. The cast was a lie:
the wrapper was a plain function, not the full callable with those
chained properties attached.

The file doesn't use any of them today, but a future test.only or
test.skip would fail with a cryptic "undefined is not a function."
Object.assign the original _bunTest's properties onto the wrapper so
sub-APIs chain correctly forever.

Surfaced by /ship's adversarial subagent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-04-17 05:54:29 +08:00
parent d7349a1c6c
commit dca4c6306c
+6 -2
View File
@@ -7,8 +7,12 @@ import * as os from 'os';
// Every test in this file shells out to gstack-config + gstack-relink (bash scripts
// invoking subprocess work). Under parallel bun test load, subprocess spawn contends
// with other suites and each test can drift ~200ms past the 5s default. Bump to 15s.
const test = ((name: any, fn: any, timeout?: number) =>
_bunTest(name, fn, timeout ?? 15_000)) as typeof _bunTest;
// Object.assign preserves test.only / test.skip / test.each / test.todo sub-APIs.
const test = Object.assign(
((name: any, fn: any, timeout?: number) =>
_bunTest(name, fn, timeout ?? 15_000)) as typeof _bunTest,
_bunTest,
);
const ROOT = path.resolve(import.meta.dir, '..');
const BIN = path.join(ROOT, 'bin');