test: library behavior owned by the coordinator lib/... walk

Go has no per-file test targets: the PACKAGE is the unit of testing
(`go test ./...`) and same-package test files compose together. The
59-target LIBRARY_TESTS fan-out (per-file -w workdirs, one Make rule
per suite) collapses to one line: `ww test -j $(JOBS) -w
out/wwbuild/wwtest-lib -I lib/ww lib/...` — the regex dir-route
precedent generalized. The lib/regex line and the per-file pattern
rule instance dissolve with it (test/lang keeps its own rule).

Measured before committing (-j4, strings edit row): old per-file
warm 4.7-4.9s; bare walk 5.2-5.6s — a real regression, so the
coordinator first gained the brief's persistent per-package workdir:
`-w DIR` on a package target forwards to wwpackage, which keys
DIR/<dir>_<pkg> per group and hands it to each inner `ww test -c`
build. Reuse stays entirely with the driver's existing
content-identity contract — the coordinator adds pure path policy,
no cache machinery. Both driver stages drop their package-target -w
rejects (forward instead); -w with -c stays rejected at the
coordinator (two ownership contracts). After: 3.9-4.0s on the edit
row, 1.0s warm no-op, 2.5s cold — faster than the old flow on every
row.

package_test's tree -w reject row becomes the positive contract
(cold+warm byte-stable stream, cs/ww same) plus the -c conflict
reject. libbyteid roster shape DECIDED: per-file fx entries stay —
every enrolled file is still standalone-buildable, so coverage is
byte-for-byte unchanged; the dir-mode entry form arrives only with
the B3 shared-helper split that first needs it. Docs: owner table,
target table, -w contract paragraph.
This commit is contained in:
2026-08-08 19:35:50 +09:00
parent 0ecdf75a0d
commit 5a263cb115
6 changed files with 115 additions and 80 deletions

View File

@@ -572,14 +572,36 @@ fn packagepath(relative: str) str = {
assert(has(outc.stderr,
"ww test: -o needs -c for a package target\n"));
let wdc: []str = [driver("ww"), "test", "-w", root, spec];
let wdw: []str = [driver("ww_ww"), "test", "-w", root, spec];
runcommand(root, "tree-w-c", wdc, time.second, &outc);
runcommand(root, "tree-w-ww", wdw, time.second, &outw);
// -w on a package target forwards to the coordinator: one
// persistent driver workdir per package group under the root,
// reuse owned by the driver's content-identity contract. The
// byte stream must match the plain run, cold and warm.
let wdroot: str = strings.concat(root, "/wd");
assert(os.mkdir(wdroot, 448i32) == 0);
let wdc: []str = [driver("ww"), "test", "-w", wdroot, spec];
let wdw: []str = [driver("ww_ww"), "test", "-w", wdroot, spec];
runcommand(root, "tree-w-c", wdc,
(30i64 * (time.second: i64)): time.duration, &outc);
runcommand(root, "tree-w-ww", wdw,
(30i64 * (time.second: i64)): time.duration, &outw);
expectexit(&outc, 0);
expectexit(&outw, 0);
assert(same(outc.stdout, outw.stdout));
assert(same(outc.stdout, seq));
runcommand(root, "tree-w-warm", wdc,
(30i64 * (time.second: i64)): time.duration, &outc);
expectexit(&outc, 0);
assert(same(outc.stdout, seq));
// -c publishes caller-owned artifacts; a persistent workdir is a
// different ownership contract — the coordinator rejects the mix.
let wcc: []str = [driver("ww"), "test", "-c", "-w", wdroot, spec];
let wcw: []str = [driver("ww_ww"), "test", "-c", "-w", wdroot, spec];
runcommand(root, "tree-wc-c", wcc, time.second, &outc);
runcommand(root, "tree-wc-ww", wcw, time.second, &outw);
expectexit(&outc, 2);
expectexit(&outw, 2);
assert(same(outc.stderr, outw.stderr));
assert(has(outc.stderr, "ww test: -w needs a single test file\n"));
assert(has(outc.stderr, "wwtest package: -w conflicts with -c\n"));
let bare: str = strings.concat(root, "/bare");
assert(os.mkdir(bare, 448i32) == 0);