cmd: build directory package test variants
This commit is contained in:
@@ -2839,6 +2839,67 @@ independent of transitive source interfaces (for example, `alloc` lowers to the
|
||||
runtime allocator without requiring an `rt.wwi` compiler input), while the
|
||||
linker still receives every reachable package archive plus the runtime archive.
|
||||
|
||||
### 11.7 Implemented directory package-test slice
|
||||
|
||||
Directory tests now enter that same local package loader and build path. The
|
||||
supported manifest-free commands are `ww test DIR`, `ww test DIR/...`, and
|
||||
their existing `-run`, `-filter`, `-list`, `-timeout-ms`, `-j`, `-c`, and `-w`
|
||||
forms. `ww test -c -o test.bin DIR` names the result when the selected directory
|
||||
has one test variant; the coordinator rejects one output name for a multi-variant
|
||||
or recursive request. Explicit `ww test FILE` retains its compatibility path.
|
||||
|
||||
The test coordinator still discovers requested directories, enumerates the
|
||||
test package names, schedules independent binaries, executes them, and emits
|
||||
captured results in byte-sorted package order. It no longer concatenates a
|
||||
generated production/test root or resolves imports. Instead it asks the Cstage
|
||||
or WWstage command to build one of two non-importable root variants from the
|
||||
real directory:
|
||||
|
||||
- `same-test` selects the byte-sorted production files followed by the
|
||||
byte-sorted matching `package p` test files. They form one compiler unit, so
|
||||
tests can use private production declarations.
|
||||
- `external-test` selects only matching `package p_test` files. Its `import p`
|
||||
is a direct edge to a distinct production node for the same canonical
|
||||
directory. That node selects every production file, emits `p.wwi` and `p.a`,
|
||||
and exposes no private declaration to the external root.
|
||||
|
||||
Every non-root dependency is always a production variant, so dependency
|
||||
`*_test.ww` files never enter the graph. Imports that occur only in selected
|
||||
test files add edges only to that test root. The compiler unit for each package
|
||||
contains only its byte-sorted direct dependency `.wwi` artifacts; the final
|
||||
test link still receives the root object and the complete reverse-topological
|
||||
archive closure. The compiler-generated `-T` dispatcher owns the implicit
|
||||
direct test-runtime support edge and remains embedded in each independent test
|
||||
root. The command resolves that edge from the selected toolchain source tree,
|
||||
not the user search path. Normally its graph qualifier is `test`, so an explicit
|
||||
source `import test` coalesces with the same canonical package. When a real user
|
||||
package occupies that identity, the command presents the runtime edge to the
|
||||
compiler under the reserved `__wwtest` qualifier. This keeps a production
|
||||
package named `test` available to external tests while preserving raw `w6c -T`
|
||||
compatibility, whose default unresolved qualifier remains `test`.
|
||||
|
||||
The selected test root and a production variant reached by its imports or test
|
||||
runtime closure are the only sanctioned pair of graph nodes that may share a
|
||||
physical directory. This also lets a toolchain package's own tests coexist with
|
||||
the production variant required by the test runtime. A same-package root
|
||||
already defines those production symbols, so the duplicate production archive
|
||||
is omitted from its final link while that node's dependency archives remain in
|
||||
the closure. All ordinary logical and physical package-identity collision
|
||||
checks remain unchanged. Recursive
|
||||
discovery groups by physical directory before sorting filenames, and persistent
|
||||
coordinator work directories use an injective escaped `(directory, test
|
||||
package)` key. Every `*_test.ww` package variant is built even when a file only
|
||||
declares helpers and contains no `@test`, so its package clause and imports are
|
||||
still checked by the shared loader. Every built variant is run, and a successful
|
||||
compiler-owned dispatcher with empty output is reported as `[no tests]`.
|
||||
|
||||
This ownership split follows Go 1.26.5's separation of production,
|
||||
same-package-test, external-test, and generated test-main inputs in
|
||||
[`cmd/go/internal/load/test.go`](https://go.googlesource.com/go/+/refs/tags/go1.26.5/src/cmd/go/internal/load/test.go),
|
||||
while retaining WW's compiler-owned dispatcher. Direct compile dependencies and
|
||||
the separately expanded link closure follow the boundary in
|
||||
[`cmd/go/internal/work/action.go`](https://go.googlesource.com/go/+/refs/tags/go1.26.5/src/cmd/go/internal/work/action.go).
|
||||
|
||||
## 12. Candidate architectures and hard-gate decision
|
||||
|
||||
Five candidates were developed as coherent systems, not as feature bins.
|
||||
|
||||
Reference in New Issue
Block a user