diff --git a/Makefile b/Makefile index d7057fa3..87b56360 100644 --- a/Makefile +++ b/Makefile @@ -641,7 +641,7 @@ test-library: $(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \ @echo "ww test -j $(JOBS) lib/..." @mkdir -p $(WWBUILD)/wwtest-lib @$(CURDIR)/$(BIN)/ww test -j $(JOBS) -w $(WWBUILD)/wwtest-lib \ - -I $(CURDIR)/lib/ww lib/... + lib/... test-bootstrap-native: $(WRAPPER_TOOLS) $(BOOTSTRAP_WRAPPER_BINS) @set -e; for t in $(BOOTSTRAP_WRAPPER_BINS); do \ diff --git a/docs/test-system-v2.md b/docs/test-system-v2.md index 4f56b9fa..8bb32109 100644 --- a/docs/test-system-v2.md +++ b/docs/test-system-v2.md @@ -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 | The package coordinator's `lib/...` tree walk (`ww test -j N -I lib/ww lib/...`) | +| Library behavior | The package coordinator's `lib/...` tree walk (`ww test -j N 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` | @@ -192,25 +192,30 @@ and nonempty-version-constant assertions. ## Package and language behavior `ww test` delegates directory package requests to the native package -coordinator. The coordinator owns discovery, package grouping, same-package and -external-package test composition, filtering, result aggregation, and its -internal temporary workspace. Test sources are exclusively `*_test.ww` (Go's -`_test.go` contract): a line-leading `@test` declaration in any other source is -rejected loudly — by both driver stages at directory enumeration and by the -coordinator at source classification. A trailing `...` path element (`ww test lib/...`, -Go's `./...` form) is recognized by both driver stages before path resolution -and walks the tree rooted at the prefix: every subdirectory whose name does not -begin with `.` or `_` is descended with the same lstat/no-symlink discipline, -each test-bearing directory becomes one package run, and source-bearing -directories without tests report the usual `?` line. The coordinator's -`-j N` schedules up to N package groups concurrently (build-then-run -process chains supervised with `os.exec` start/poll, no threads); -emission stays strictly in group order, so the byte stream is identical -at every `-j` level, and `-j 1` — the default — matches the former -sequential loop exactly. Measured on the 31-package `lib/...` walk: +coordinator. The coordinator owns request-pattern expansion, package grouping, +same-package and external-package variant selection, filtering, result +aggregation, and its internal temporary workspace. Test sources are exclusively +`*_test.ww` (Go's `_test.go` contract): a line-leading `@test` declaration in +any other source is rejected loudly — by both driver stages at directory +enumeration and by the coordinator at source classification. A local spelling +containing `...` (for example `ww test lib/...`, Go's `./...` form) is +recognized by both driver stages before path resolution and walks from the +directory prefix before the first wildcard. Recursive children beginning `.` +or `_` and exact `testdata` subtrees are pruned; child directory symlinks are +not followed. A wildcard cannot consume a non-terminal exact `vendor` element, +while an explicitly vendor-rooted pattern remains legal. Every selected +test-bearing directory becomes one package run, and selected source-bearing +directories without tests report the usual `?` line. The coordinator first +launches one driver plan for the complete command-global package/action union. +After that shared build completes, `-j N` schedules up to N successful selected +test binaries concurrently under `os.exec` start/poll supervision (no threads); +emission stays strictly in group order, so the byte stream is identical at +every `-j` level, and `-j 1` — the default — matches the former sequential +run loop exactly. Measured on the 31-package `lib/...` walk: 7.0s sequential, 2.4s at `-j 4`. With `-c`, it publishes each exact -`.test` binary and adjacent `.test.sepwork` tree in the -package directory; those become caller-owned artifacts. `-c -o ` +`.test` binary in the package directory; the first output owns the one +shared cold sepwork containing the command-global action universe. Those become +caller-owned artifacts. `-c -o ` names that artifact instead of the fixed stem, for exactly one package: the coordinator rejects a multi-package fan-out ("cannot use -o with multiple packages", Go's `go test -o` rule), and `-o` without `-c` is @@ -234,10 +239,11 @@ and make cleanup failure fail the command. Make recipes build driver-produced tools in invocation-owned directories and apply the same exact cleanup rule. `ww build -w DIR` and single-file `ww test -w DIR` replace that scratch with a -caller-owned persistent package-artifact workdir: the directory must already -exist, is never cleaned by the driver, and holds one committed unit, `.wwi`, -`.s`, `.o`, and dep `.a` per package plus byte copies of the invoking driver, -compiler, and assembler and a small mode stamp. A package is reused only when +caller-owned persistent package-artifact workdir: for these direct routes the +directory must already exist, is never cleaned by the driver, and holds one +committed unit, `.wwi`, `.s`, `.o`, and dep `.a` per package plus byte copies of +the invoking driver, compiler, and assembler and a small mode stamp. A package +is reused only when its freshly composed owner unit byte-equals the committed unit, no recompiled direct dependency emitted changed export bytes, and every applicable recorded executable byte-equals the live executable — content identity only, no mtimes, @@ -248,19 +254,23 @@ that neither unit bytes nor compiler identity can name. Recompiled artifacts land at staged `.new` names and commit by rename with the unit renamed last, so an interrupted build forces a recompile rather than a false reuse; the link always reruns. One workdir serves one invocation at a -time and one (root, mode) shape; both driver stages implement the identical -contract. This is build staleness in the Make/mk/Go sense, not a result cache: +time and may hold the complete command-global action universe for all selected +roots and isolated variants; semantic identity, rather than request shape, +controls reuse. Both driver stages implement the identical contract. 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` -(`_` 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 +On a package or tree target, `ww build/test -w DIR` forwards that exact caller +path as the one command-global semantic-action store; neither pattern spelling +nor package-group name derives a persistent subdirectory. The delegated driver +may create a missing store only after graph and request preflight, and rolls +back newly created empty prefixes if later setup fails. Every reuse decision +stays with the driver's content-identity contract above. `-w` and test `-c` do +not mix — 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 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 diff --git a/test/tool/driver_test.ww b/test/tool/driver_test.ww index b6a70fe5..bfdb6647 100644 --- a/test/tool/driver_test.ww +++ b/test/tool/driver_test.ww @@ -1,18 +1,18 @@ package driver_test; // `ww` driver CLI observers. Ports of the retired native carriers -// test/wcc/949_driver_flagargs.c and 949_missingpkg.c; every -// assertion preserved. +// test/wcc/949_driver_flagargs.c and 949_missingpkg.c; the retired +// second-positional single-file-only assertion now belongs to package-root +// selection, while the remaining driver assertions stay here. // // flagargs (#15 B2) — `ww -V` exits 0 with stdout exactly -// "ww \n" and empty stderr; 15 flag-misuse rows each exit +// "ww \n" and empty stderr; 14 flag-misuse rows each exit // 2 with the row's stderr fragment; and on every row plus -V the // wwstage twin `ww_ww` matches the cstage `ww` byte-exactly on exit // code, stdout and stderr (rule 10 on the driver surface). The // version oracle is parsed from cmd/wcc/ww.h at run time, preserving // the carrier's exact-output ownership without a C toolchain -// dependency. Rows run from a fresh scratch cwd: the `test . zzz` row -// takes `.` positionally, so the cwd must never be the repo tree. +// dependency. // // missingpkg (#16 ENFORCE-driver) — `ww build` over a source whose // only import cannot be located exits nonzero with "cannot find @@ -168,13 +168,13 @@ fn runrootargv(dir: str, root: str, name: str, drv: str, @test fn flagargs() void = { let a1: []str = ["build", "build", "build", "build", "build", "run", "run", "run", "test", "test", "test", "test", "test", - "test", "test"]; + "test"]; let a2: []str = ["-o", "-I", "-L", "-l", "-zz", "-o", "-l", "-zz", "-l", "-zz", "-I", "-o", "-o", - "-run", "."]; + "-run"]; let a3: []str = ["", "", "", "", "", "", "", "", "", "", "", "", "x", - "", "zzz"]; + ""]; let subs: []str = [ "ww build: -o needs an argument", "ww build: -I needs an argument", @@ -189,8 +189,7 @@ fn runrootargv(dir: str, root: str, name: str, drv: str, "ww test: -I needs an argument", "ww test: -o needs an argument", "ww test: -o needs -c for a package target", - "ww test: -run needs an argument", - "ww test: pattern needs a single test file"]; + "ww test: -run needs an argument"]; let i: i32 = 0; for (i < subs.len) { let td: str = testenv.fresh(); @@ -231,8 +230,8 @@ fn runrootargv(dir: str, root: str, name: str, drv: str, // -o needs a writable stem: the output-derived .sepwork follows -o, // so /dev/null would yield an uncreatable /dev/null.sepwork and // mask the missing-package fatal. - let av: []str = [testenv.driver("ww"), "build", src, "-o", - strings.concat(td, "/miss.out")]; + let av: []str = [testenv.driver("ww"), "build", "-o", + strings.concat(td, "/miss.out"), src]; testenv.runcommand(td, td, "miss", av, tmo(), &co); assert(co.termination == exec.termination.EXIT); if (co.code == 0) { diff --git a/test/wcc/810_dyn.c b/test/wcc/810_dyn.c index 9bfc6a49..880c1108 100644 --- a/test/wcc/810_dyn.c +++ b/test/wcc/810_dyn.c @@ -152,8 +152,8 @@ main(void) char cmd[1024]; snprintf(cmd, sizeof cmd, - "%s/ww build -o %s %s -L %s -l c", - bin, outbin, src, libdir); + "%s/ww build -o %s -L %s -l c %s", + bin, outbin, libdir, src); if (runwait(cmd) != 0) { fprintf(stderr, "dyn row %d: build failed\n", i); rowfail = 1; diff --git a/test/wcc/989_dynentry_run.c b/test/wcc/989_dynentry_run.c index 8fa6a092..4138ef80 100644 --- a/test/wcc/989_dynentry_run.c +++ b/test/wcc/989_dynentry_run.c @@ -72,8 +72,8 @@ build_run(const char *driver, const char *src, const char *libdir, { char cmd[1024]; snprintf(outbin, obsz, "%s/main", tmpdir); - snprintf(cmd, sizeof cmd, "cd %s && %s build -o %s %s -L %s -l c " - "2>/dev/null", tmpdir, driver, outbin, src, libdir); + snprintf(cmd, sizeof cmd, "cd %s && %s build -o %s -L %s -l c %s " + "2>/dev/null", tmpdir, driver, outbin, libdir, src); if (runwait(cmd) != 0) return -1; return runwait(outbin); } diff --git a/test/wcc/996_dyn_ww.c b/test/wcc/996_dyn_ww.c index 076379d8..2cd995b9 100644 --- a/test/wcc/996_dyn_ww.c +++ b/test/wcc/996_dyn_ww.c @@ -114,8 +114,8 @@ main(void) } snprintf(cmd, sizeof cmd, - "%s/ww build -o %s %s -L %s -l c >/dev/null 2>&1", - bin, stem, src, libdir); + "%s/ww build -o %s -L %s -l c %s >/dev/null 2>&1", + bin, stem, libdir, src); if (runwait(cmd) != 0) { fprintf(stderr, "w6l_ww-dyn FAIL: cannot build generated command\n"); rc = 1;