test: align package fixtures with Go semantics
This commit is contained in:
2
Makefile
2
Makefile
@@ -641,7 +641,7 @@ test-library: $(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
|
|||||||
@echo "ww test -j $(JOBS) lib/..."
|
@echo "ww test -j $(JOBS) lib/..."
|
||||||
@mkdir -p $(WWBUILD)/wwtest-lib
|
@mkdir -p $(WWBUILD)/wwtest-lib
|
||||||
@$(CURDIR)/$(BIN)/ww test -j $(JOBS) -w $(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)
|
test-bootstrap-native: $(WRAPPER_TOOLS) $(BOOTSTRAP_WRAPPER_BINS)
|
||||||
@set -e; for t in $(BOOTSTRAP_WRAPPER_BINS); do \
|
@set -e; for t in $(BOOTSTRAP_WRAPPER_BINS); do \
|
||||||
|
|||||||
@@ -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` |
|
| 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 |
|
| Package semantics | `test/package` and the native package-test coordinator |
|
||||||
| Language behavior | `test/lang/*_test.ww` through the language `@test` runtime |
|
| 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 |
|
| 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 |
|
| Compiler-output identity | `test-lang-byteid` and `test-data-byteid` plus residual byte/artifact carriers |
|
||||||
| Fixed point and self-host | `test-bootstrap` |
|
| Fixed point and self-host | `test-bootstrap` |
|
||||||
@@ -192,25 +192,30 @@ and nonempty-version-constant assertions.
|
|||||||
## Package and language behavior
|
## Package and language behavior
|
||||||
|
|
||||||
`ww test` delegates directory package requests to the native package
|
`ww test` delegates directory package requests to the native package
|
||||||
coordinator. The coordinator owns discovery, package grouping, same-package and
|
coordinator. The coordinator owns request-pattern expansion, package grouping,
|
||||||
external-package test composition, filtering, result aggregation, and its
|
same-package and external-package variant selection, filtering, result
|
||||||
internal temporary workspace. Test sources are exclusively `*_test.ww` (Go's
|
aggregation, and its internal temporary workspace. Test sources are exclusively
|
||||||
`_test.go` contract): a line-leading `@test` declaration in any other source is
|
`*_test.ww` (Go's `_test.go` contract): a line-leading `@test` declaration in
|
||||||
rejected loudly — by both driver stages at directory enumeration and by the
|
any other source is rejected loudly — by both driver stages at directory
|
||||||
coordinator at source classification. A trailing `...` path element (`ww test lib/...`,
|
enumeration and by the coordinator at source classification. A local spelling
|
||||||
Go's `./...` form) is recognized by both driver stages before path resolution
|
containing `...` (for example `ww test lib/...`, Go's `./...` form) is
|
||||||
and walks the tree rooted at the prefix: every subdirectory whose name does not
|
recognized by both driver stages before path resolution and walks from the
|
||||||
begin with `.` or `_` is descended with the same lstat/no-symlink discipline,
|
directory prefix before the first wildcard. Recursive children beginning `.`
|
||||||
each test-bearing directory becomes one package run, and source-bearing
|
or `_` and exact `testdata` subtrees are pruned; child directory symlinks are
|
||||||
directories without tests report the usual `?` line. The coordinator's
|
not followed. A wildcard cannot consume a non-terminal exact `vendor` element,
|
||||||
`-j N` schedules up to N package groups concurrently (build-then-run
|
while an explicitly vendor-rooted pattern remains legal. Every selected
|
||||||
process chains supervised with `os.exec` start/poll, no threads);
|
test-bearing directory becomes one package run, and selected source-bearing
|
||||||
emission stays strictly in group order, so the byte stream is identical
|
directories without tests report the usual `?` line. The coordinator first
|
||||||
at every `-j` level, and `-j 1` — the default — matches the former
|
launches one driver plan for the complete command-global package/action union.
|
||||||
sequential loop exactly. Measured on the 31-package `lib/...` walk:
|
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
|
7.0s sequential, 2.4s at `-j 4`. With `-c`, it publishes each exact
|
||||||
`<package>.test` binary and adjacent `<package>.test.sepwork` tree in the
|
`<package>.test` binary in the package directory; the first output owns the one
|
||||||
package directory; those become caller-owned artifacts. `-c -o <name>`
|
shared cold sepwork containing the command-global action universe. Those become
|
||||||
|
caller-owned artifacts. `-c -o <name>`
|
||||||
names that artifact instead of the fixed stem, for exactly one package:
|
names that artifact instead of the fixed stem, for exactly one package:
|
||||||
the coordinator rejects a multi-package fan-out ("cannot use -o with
|
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
|
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.
|
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
|
`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
|
caller-owned persistent package-artifact workdir: for these direct routes the
|
||||||
exist, is never cleaned by the driver, and holds one committed unit, `.wwi`,
|
directory must already exist, is never cleaned by the driver, and holds one
|
||||||
`.s`, `.o`, and dep `.a` per package plus byte copies of the invoking driver,
|
committed unit, `.wwi`, `.s`, `.o`, and dep `.a` per package plus byte copies of
|
||||||
compiler, and assembler and a small mode stamp. A package is reused only when
|
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
|
its freshly composed owner unit byte-equals the committed unit, no recompiled
|
||||||
direct dependency emitted changed export bytes, and every applicable recorded
|
direct dependency emitted changed export bytes, and every applicable recorded
|
||||||
executable byte-equals the live executable — content identity only, no mtimes,
|
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
|
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
|
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
|
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
|
time and may hold the complete command-global action universe for all selected
|
||||||
contract. This is build staleness in the Make/mk/Go sense, not a result cache:
|
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
|
tests always run, and the byte-identity and bootstrap gates keep building on
|
||||||
fresh scratch. `make clean` reclaims every workdir under `out/`.
|
fresh scratch. `make clean` reclaims every workdir under `out/`.
|
||||||
|
|
||||||
On a package or tree target, `ww test -w DIR` forwards to the coordinator,
|
On a package or tree target, `ww build/test -w DIR` forwards that exact caller
|
||||||
which keys one persistent driver workdir per package group under `DIR`
|
path as the one command-global semantic-action store; neither pattern spelling
|
||||||
(`<dir>_<pkg>` with `/` flattened) and passes it to each inner build; every
|
nor package-group name derives a persistent subdirectory. The delegated driver
|
||||||
reuse decision stays with the driver's content-identity contract above.
|
may create a missing store only after graph and request preflight, and rolls
|
||||||
`-w` and `-c` do not mix there — the coordinator rejects the combination
|
back newly created empty prefixes if later setup fails. Every reuse decision
|
||||||
rather than guess which artifact tree the caller owns. `test-library` uses
|
stays with the driver's content-identity contract above. `-w` and test `-c` do
|
||||||
exactly this: one `ww test -j $(JOBS) -w out/wwbuild/wwtest-lib -I lib/ww
|
not mix — the coordinator rejects the combination rather than guess which
|
||||||
lib/...` line owns library behavior (measured: 2.3s cold, 1.0s warm at
|
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).
|
`-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
|
`test/lang` currently uses one package per source file, so its complete gate
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package driver_test;
|
package driver_test;
|
||||||
|
|
||||||
// `ww` driver CLI observers. Ports of the retired native carriers
|
// `ww` driver CLI observers. Ports of the retired native carriers
|
||||||
// test/wcc/949_driver_flagargs.c and 949_missingpkg.c; every
|
// test/wcc/949_driver_flagargs.c and 949_missingpkg.c; the retired
|
||||||
// assertion preserved.
|
// 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
|
// flagargs (#15 B2) — `ww -V` exits 0 with stdout exactly
|
||||||
// "ww <WW_VERSION>\n" and empty stderr; 15 flag-misuse rows each exit
|
// "ww <WW_VERSION>\n" and empty stderr; 14 flag-misuse rows each exit
|
||||||
// 2 with the row's stderr fragment; and on every row plus -V the
|
// 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
|
// wwstage twin `ww_ww` matches the cstage `ww` byte-exactly on exit
|
||||||
// code, stdout and stderr (rule 10 on the driver surface). The
|
// code, stdout and stderr (rule 10 on the driver surface). The
|
||||||
// version oracle is parsed from cmd/wcc/ww.h at run time, preserving
|
// version oracle is parsed from cmd/wcc/ww.h at run time, preserving
|
||||||
// the carrier's exact-output ownership without a C toolchain
|
// the carrier's exact-output ownership without a C toolchain
|
||||||
// dependency. Rows run from a fresh scratch cwd: the `test . zzz` row
|
// dependency.
|
||||||
// takes `.` positionally, so the cwd must never be the repo tree.
|
|
||||||
//
|
//
|
||||||
// missingpkg (#16 ENFORCE-driver) — `ww build` over a source whose
|
// missingpkg (#16 ENFORCE-driver) — `ww build` over a source whose
|
||||||
// only import cannot be located exits nonzero with "cannot find
|
// 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 = {
|
@test fn flagargs() void = {
|
||||||
let a1: []str = ["build", "build", "build", "build", "build",
|
let a1: []str = ["build", "build", "build", "build", "build",
|
||||||
"run", "run", "run", "test", "test", "test", "test", "test",
|
"run", "run", "run", "test", "test", "test", "test", "test",
|
||||||
"test", "test"];
|
"test"];
|
||||||
let a2: []str = ["-o", "-I", "-L", "-l", "-zz",
|
let a2: []str = ["-o", "-I", "-L", "-l", "-zz",
|
||||||
"-o", "-l", "-zz", "-l", "-zz", "-I", "-o", "-o",
|
"-o", "-l", "-zz", "-l", "-zz", "-I", "-o", "-o",
|
||||||
"-run", "."];
|
"-run"];
|
||||||
let a3: []str = ["", "", "", "", "",
|
let a3: []str = ["", "", "", "", "",
|
||||||
"", "", "", "", "", "", "", "x",
|
"", "", "", "", "", "", "", "x",
|
||||||
"", "zzz"];
|
""];
|
||||||
let subs: []str = [
|
let subs: []str = [
|
||||||
"ww build: -o needs an argument",
|
"ww build: -o needs an argument",
|
||||||
"ww build: -I 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: -I needs an argument",
|
||||||
"ww test: -o needs an argument",
|
"ww test: -o needs an argument",
|
||||||
"ww test: -o needs -c for a package target",
|
"ww test: -o needs -c for a package target",
|
||||||
"ww test: -run needs an argument",
|
"ww test: -run needs an argument"];
|
||||||
"ww test: pattern needs a single test file"];
|
|
||||||
let i: i32 = 0;
|
let i: i32 = 0;
|
||||||
for (i < subs.len) {
|
for (i < subs.len) {
|
||||||
let td: str = testenv.fresh();
|
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,
|
// -o needs a writable stem: the output-derived .sepwork follows -o,
|
||||||
// so /dev/null would yield an uncreatable /dev/null.sepwork and
|
// so /dev/null would yield an uncreatable /dev/null.sepwork and
|
||||||
// mask the missing-package fatal.
|
// mask the missing-package fatal.
|
||||||
let av: []str = [testenv.driver("ww"), "build", src, "-o",
|
let av: []str = [testenv.driver("ww"), "build", "-o",
|
||||||
strings.concat(td, "/miss.out")];
|
strings.concat(td, "/miss.out"), src];
|
||||||
testenv.runcommand(td, td, "miss", av, tmo(), &co);
|
testenv.runcommand(td, td, "miss", av, tmo(), &co);
|
||||||
assert(co.termination == exec.termination.EXIT);
|
assert(co.termination == exec.termination.EXIT);
|
||||||
if (co.code == 0) {
|
if (co.code == 0) {
|
||||||
|
|||||||
@@ -152,8 +152,8 @@ main(void)
|
|||||||
|
|
||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
snprintf(cmd, sizeof cmd,
|
snprintf(cmd, sizeof cmd,
|
||||||
"%s/ww build -o %s %s -L %s -l c",
|
"%s/ww build -o %s -L %s -l c %s",
|
||||||
bin, outbin, src, libdir);
|
bin, outbin, libdir, src);
|
||||||
if (runwait(cmd) != 0) {
|
if (runwait(cmd) != 0) {
|
||||||
fprintf(stderr, "dyn row %d: build failed\n", i);
|
fprintf(stderr, "dyn row %d: build failed\n", i);
|
||||||
rowfail = 1;
|
rowfail = 1;
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ build_run(const char *driver, const char *src, const char *libdir,
|
|||||||
{
|
{
|
||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
snprintf(outbin, obsz, "%s/main", tmpdir);
|
snprintf(outbin, obsz, "%s/main", tmpdir);
|
||||||
snprintf(cmd, sizeof cmd, "cd %s && %s build -o %s %s -L %s -l c "
|
snprintf(cmd, sizeof cmd, "cd %s && %s build -o %s -L %s -l c %s "
|
||||||
"2>/dev/null", tmpdir, driver, outbin, src, libdir);
|
"2>/dev/null", tmpdir, driver, outbin, libdir, src);
|
||||||
if (runwait(cmd) != 0) return -1;
|
if (runwait(cmd) != 0) return -1;
|
||||||
return runwait(outbin);
|
return runwait(outbin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(cmd, sizeof cmd,
|
snprintf(cmd, sizeof cmd,
|
||||||
"%s/ww build -o %s %s -L %s -l c >/dev/null 2>&1",
|
"%s/ww build -o %s -L %s -l c %s >/dev/null 2>&1",
|
||||||
bin, stem, src, libdir);
|
bin, stem, libdir, src);
|
||||||
if (runwait(cmd) != 0) {
|
if (runwait(cmd) != 0) {
|
||||||
fprintf(stderr, "w6l_ww-dyn FAIL: cannot build generated command\n");
|
fprintf(stderr, "w6l_ww-dyn FAIL: cannot build generated command\n");
|
||||||
rc = 1;
|
rc = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user