test/wcc: carrier ownership repair and driver-contract adaptation

Every surviving carrier now owns its artifacts: checked mkdir/mkdtemp/
fopen acquisition, one all-exit cleanup funnel per carrier, ENOENT-
tolerant checked unlinks, exact-path deletion (rm -rf only for an
owned pid-keyed dir or a .sepwork beneath one), and cleanup failure
fails a passing carrier without overwriting its diagnostic. In the
same pass the carriers adapt to the driver contract this branch lands:
--sep and WW_PKGCACHE are gone, -S and the /tmp/ww_run_<pid> scratch
contract are asserted, and rows whose runtime or reject coverage moved
to test/wcc/data fixtures or test/lang @test owners are trimmed to the
byte/artifact/diagnostic observations only they can make.

Repair and adaptation ride together because most files interleave both
in the same hunks; splitting would manufacture intermediate carrier
states that never existed and cannot run against either driver.
This commit is contained in:
2026-08-07 23:02:47 +09:00
parent b2899dd8d3
commit a95a7a316b
132 changed files with 7573 additions and 6172 deletions

View File

@@ -1,6 +1,6 @@
/*
* 989_coloimport_sep — #98 E3 flip-blocker: a co-located `_test` entry must
* not shadow the dir-package it imports under `ww test --sep`.
* not shadow the dir-package it imports under `ww test`.
*
* The driver builds the sep searchpath srcd-first (srcd = the entry file's
* own directory). When the entry is a co-located black-box test
@@ -30,7 +30,7 @@
* `-I test/wcc/data/colo98` puts widget's parent on the fallback path,
* mirroring how `lib` holds the real `lib/<mod>/` dirs.
*
* Asserts (both driver stages, COLD per-stage WW_PKGCACHE):
* Asserts (both driver stages, direct builds):
* 1. RUN-EXIT 0 — the @test resolves, builds, links, runs. Pre-fix the
* non-root importer's fold makes w6c reject → non-zero; this is the
* non-vacuity teeth (verified: revert the two-pass walker → reddens
@@ -43,13 +43,13 @@
* cstage `ww` and wwstage `ww_ww` sep-drivers, proving the `locatein`
* port is symmetric with `locate_import_in`.
*
* Light wwstage-driver test (CLAUDE.md rule 14): every intermediate is
* `-o`-redirected to /tmp, so it is phase-1 parallel-safe. Models
* Every intermediate is `-o`-redirected to /tmp for isolation. Models
* 989_septest_run conventions; 989 prefix per the sep-gate precedent.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/stat.h>
@@ -149,7 +149,7 @@ cmp_sepwork(const char *csdir, const char *wwdir, const char *label)
struct tcase {
const char *label;
const char *entry; /* the co-located `_test` entry built under --sep */
const char *entry; /* the co-located `_test` build target */
const char *incdir; /* -I dir (parent that holds the dir-package) */
const char *regpkg; /* the dir-package that must register its own unit */
};
@@ -170,9 +170,10 @@ main(void)
char td[64], cmd[8192];
int fail = 0;
snprintf(td, sizeof td, "/tmp/wwcoloimport_%d", getpid());
snprintf(cmd, sizeof cmd, "rm -rf %s", td);
runwait(cmd);
mkdir(td, 0755);
if (mkdir(td, 0755) != 0) {
perror(td);
return 1;
}
for (int i = 0; cases[i].label; i++) {
struct tcase *t = &cases[i];
@@ -182,12 +183,12 @@ main(void)
for (int s = 0; s < 2; s++) {
char prog[1024];
snprintf(prog, sizeof prog, "%s/%s.%s.bin", td, t->label, stg[s].tag);
/* COLD per-(case,stage) cache: every package compiles fresh so
* the per-pkg .s/.wwi this gate inspects are produced. */
/* Each direct build produces the per-package .s/.wwi artifacts
* this gate inspects. */
snprintf(cmd, sizeof cmd,
"WW_PKGCACHE='%s/cache.%s.%s' %s/%s test --sep -I %s -o %s %s "
"%s/%s test -I %s -o %s %s "
">/dev/null 2>&1",
td, t->label, stg[s].tag, bin, stg[s].drv, t->incdir, prog,
bin, stg[s].drv, t->incdir, prog,
t->entry);
stg[s].rc = runwait(cmd);
}
@@ -223,14 +224,34 @@ main(void)
fail += cmp_sepwork(csdir, wwdir, t->label);
}
snprintf(cmd, sizeof cmd, "rm -rf %s", td);
runwait(cmd);
for (int i = 0; cases[i].label; i++) {
const char *tags[] = { "cs", "ww" };
for (int s = 0; s < 2; s++) {
char prog[1024], work[1100];
snprintf(prog, sizeof prog, "%s/%s.%s.bin", td,
cases[i].label, tags[s]);
if (unlink(prog) != 0 && errno != ENOENT) {
perror(prog);
fail++;
}
snprintf(work, sizeof work, "%s.sepwork", prog);
snprintf(cmd, sizeof cmd, "rm -rf %s", work);
if (runwait(cmd) != 0) {
fprintf(stderr, "coloimport: cleanup failed: %s\n", work);
fail++;
}
}
}
if (rmdir(td) != 0) {
perror(td);
fail++;
}
if (fail) {
fprintf(stderr, "coloimport: %d check(s) failed\n", fail);
return 1;
}
printf("coloimport: co-located `_test` entry resolves `import <mod>` to the "
"dir-package (not the sibling file) under `ww test --sep` on both driver "
"dir-package (not the sibling file) under `ww test` on both driver "
"stages + cs==ww per-pkg .s/.wwi\n");
return 0;
}