test: prove package-source test execution cwd

This commit is contained in:
2026-08-20 16:25:43 +09:00
parent 5f75fcb113
commit 6e9591d4b4
4 changed files with 955 additions and 1 deletions

View File

@@ -225,10 +225,32 @@ including a combined internal/external directory:
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
rejected at the driver ("needs -c for a package target") because a plain
run always executes from the temp root. Without `-c`, it removes the
run leaves no caller-owned artifact for `-o` to name. Without `-c`, it removes the
temporary binary and scratch with its workspace. The language runtime
owns individual `@test` functions.
Every actually executed directory product gives its single generated binary
the product's canonical absolute physical source directory as child cwd. A
fresh per-run environment removes inherited exact uppercase `PWD` entries and
appends one `PWD` with that same directory, matching Go 1.26.5's observable
`AppendPWD` plus last-value-wins `os/exec` behavior. The coordinator's cwd and
environment do not change, and overlapping `-j N` children share no writable
environment vector. Relative ordinary data, `testdata`, and writes resolve in
the tested directory. Production and test-only dependency initializers run in
that product process and see its directory; separately testing the dependency
creates a separate process using the dependency directory. Equivalent direct,
recursive, redundant, absolute, and root-symlink spellings converge before
this runtime field is assigned.
The physical directory remains distinct from exact dotted package identity and
from production, internal, external, recompiled, support, and generated-main
action identity. Only product execution uses it. Compiler, assembler, archiver,
linker, support, and generated-main commands retain their build-plan cwd and
environment. `ww build`, `ww test -c`, `-c -o`, and no-selected-test products
start no test child. A published test binary run directly and the raw
single-file compatibility path inherit the user's cwd/environment and contain
no forced package-directory behavior.
Before package grouping, both directory drivers and the shared recursive
coordinator apply Go 1.26.5's filename OS/architecture rule for WW's fixed
`linux/amd64` target. The basename stem ends at its first dot; a final `_test`
@@ -291,6 +313,23 @@ exact-argv, command, and persistent-workdir observers, the package suite proves
archive-only link argv and exact warm/rejection-state behavior without
duplicating those broader mechanisms in this observer.
The same package owner contains the focused
`directory_test_execution_working_directory` observer. It constructs
independent temporary directories from an unrelated caller cwd and compares
Cstage/WWstage output for production/internal/external/combined and every
test-only shape; production and test-only dependency initialization;
recompiled external self-import; duplicate inherited `PWD`; ordinary data,
`testdata`, and relative writes; direct/recursive/redundant/absolute/symlink
roots; reversed request and creation order; serial and parallel products;
filters, list, and no-match execution; failure and timeout; build/no-test and
compile-only paths; direct published binaries and raw single-file execution;
build-tool cwd/argv/environment; persistent data-only reuse and artifact bytes;
and deterministic post-build child-`chdir` failure isolated from a successful
sibling. It pads the inherited environment beyond former fixed observer sizes,
requires one appended product `PWD`, and sweeps the persistent workdir for
staged residue. Command-global bounded-memory failure remains independently
owned by `allocation_failure_is_command_global`.
The same package owner contains the focused
`platform_filename_source_selection` observer. It independently generates the
suffix matrix, production/internal/external sources, wrong-target import and
@@ -387,6 +426,14 @@ real directory test products always run, while no-selected-test directories do
not create a process. The byte-identity and bootstrap gates keep building on
fresh scratch. `make clean` reclaims every workdir under `out/`.
Directory-product cwd and `PWD` are request-time child-process metadata, not
persisted action inputs or results. A runtime directory-entry failure therefore
does not erase a successfully committed compilation generation. Changing only
ordinary fixture data causes no unit/export/assembly/object/archive/main/binary
change and no producer work beyond the same established warm final relink,
while the next always-run product observes the new bytes. Build workdir format
remains 18, test workdir format remains 19, and semantic storage remains 3.
Fold keys and first-spelling tables are request-only loader state and are never
stored in a workdir. They do not alter successful unit bytes, action/storage
keys, or tool records, so build format 18, test format 19, and semantic storage