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

@@ -26,7 +26,7 @@ categories out of the ordinary developer target.
| Compile success/rejection, stage-routed diagnostics, and runtime exit | `test/wcc/data/*/case.ww`, executed by `wwfixture` |
| Package semantics | `test/package` and the native package-test coordinator |
| Language behavior | `test/lang/*_test.ww` through the language `@test` runtime |
| Library behavior | Library-owned `@test` sources named by `LIBRARY_TESTS` |
| Library behavior | The package coordinator's `lib/...` tree walk (`ww test -j N -I lib/ww lib/...`) |
| Standalone library-source compilation | Four real source paths named by `LIBRARY_STANDALONE_SOURCES`, compiled directly by both frontends |
| Compiler-output identity | `test-lang-byteid` and `test-data-byteid` plus residual byte/artifact carriers |
| Fixed point and self-host | `test-bootstrap` |
@@ -101,7 +101,7 @@ outright; git history is the archive.
| `test-compiler` | Complete fixture corpus plus residual compiler/integration carriers |
| `test-package` | Package planning, grouping, routing, and package runtime only |
| `test-lang` | Language-owned `@test` behavior |
| `test-library` | Library-owned `@test` behavior plus four direct standalone-source C/WW compilation checks |
| `test-library` | The coordinator's `lib/...` walk plus four direct standalone-source C/WW compilation checks |
| `test-commit` | Unit + compiler + package + language + library behavior |
| `test-byteid` | Compiler-output identity gates |
| `test-bootstrap` | Fixed-point bootstrap plus the 950/991995 native gates |
@@ -246,6 +246,16 @@ This is build staleness in the Make/mk/Go sense, not a result cache: tests
always run, and the byte-identity and bootstrap gates keep building on fresh
scratch. `make clean` reclaims every workdir under `out/`.
On a package or tree target, `ww test -w DIR` forwards to the coordinator,
which keys one persistent driver workdir per package group under `DIR`
(`<dir>_<pkg>` with `/` flattened) and passes it to each inner build; every
reuse decision stays with the driver's content-identity contract above.
`-w` and `-c` do not mix there — the coordinator rejects the combination
rather than guess which artifact tree the caller owns. `test-library` uses
exactly this: one `ww test -j $(JOBS) -w out/wwbuild/wwtest-lib -I lib/ww
lib/...` line owns library behavior (measured: 2.3s cold, 1.0s warm at
`-j 4`, vs 4.7s for the retired 59-target per-file fan-out).
`test/lang` currently uses one package per source file, so its complete gate
still performs independent package builds. That remaining source layout is not
hidden behind caching or concurrency; it is outside the small `test` target.