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:
@@ -20,7 +20,7 @@
|
||||
* d exports an aggregate STRUCT def (info), an aggregate ARRAY def (arr),
|
||||
* and three reader fns; root sums them at RUNTIME.
|
||||
*
|
||||
* Asserts (all COLD — per-stage WW_PKGCACHE wipes the package cache):
|
||||
* Asserts (direct builds compile every package):
|
||||
* 1. Build + LINK + run, BOTH stages -> exit EXPECT_EXIT. The link+run is
|
||||
* the external-DATA-ref proof: the importer's CALL d.geta / d.getelem /
|
||||
* d.getb and d's own LEAQ d.info/d.arr(SB) refs resolve against the dep
|
||||
@@ -32,12 +32,12 @@
|
||||
* value-serialized `export def info: s = ` form (NON-VACUITY: proves the
|
||||
* producer took the new aggregate arm, not the scalar arm).
|
||||
*
|
||||
* Light wwstage-driver test (CLAUDE.md rule 14): all intermediates are
|
||||
* `-o`-redirected to /tmp, so it is phase-1 parallel-safe. Models
|
||||
* All intermediates are `-o`-redirected to /tmp for isolation. Models
|
||||
* 989_seproot_export_run.c conventions; 989 prefix per the sep-gate precedent.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -117,9 +117,8 @@ write_file(const char *path, const char *body)
|
||||
{
|
||||
FILE *f = fopen(path, "wb");
|
||||
if (!f) return -1;
|
||||
fputs(body, f);
|
||||
fclose(f);
|
||||
return 0;
|
||||
if (fputs(body, f) == EOF) { fclose(f); return -1; }
|
||||
return fclose(f);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -127,20 +126,22 @@ main(void)
|
||||
{
|
||||
const char *bin = absbin();
|
||||
if (!bin) return 1;
|
||||
char td[64], cmd[8192], p[1024];
|
||||
int fail = 0;
|
||||
char td[] = "/tmp/wwsepstructdef_XXXXXX";
|
||||
char cmd[8192], p[1024];
|
||||
int fail = 0, cleanup_fail = 0, have_lib = 0, have_d = 0;
|
||||
|
||||
snprintf(td, sizeof td, "/tmp/wwsepstructdef_%d", getpid());
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", td);
|
||||
runwait(cmd);
|
||||
mkdir(td, 0755);
|
||||
if (mkdtemp(td) == NULL) return 1;
|
||||
|
||||
/* lib/d — the dep package exporting aggregate-init defs + reader fns.
|
||||
* The struct type must be EXPORTED so the prototype names a visible
|
||||
* type (an exported def over an unexported type is a separate loud
|
||||
* reject, check_exported_type). */
|
||||
snprintf(p, sizeof p, "%s/lib", td); mkdir(p, 0755);
|
||||
snprintf(p, sizeof p, "%s/lib/d", td); mkdir(p, 0755);
|
||||
snprintf(p, sizeof p, "%s/lib", td);
|
||||
if (mkdir(p, 0755) != 0) { fail++; goto out; }
|
||||
have_lib = 1;
|
||||
snprintf(p, sizeof p, "%s/lib/d", td);
|
||||
if (mkdir(p, 0755) != 0) { fail++; goto out; }
|
||||
have_d = 1;
|
||||
snprintf(p, sizeof p, "%s/lib/d/mod.ww", td);
|
||||
if (write_file(p,
|
||||
"package d;\n"
|
||||
@@ -167,14 +168,14 @@ main(void)
|
||||
|
||||
for (int s = 0; s < 2; s++) {
|
||||
snprintf(stg[s].prog, sizeof stg[s].prog, "%s/prog.%s", td, stg[s].tag);
|
||||
/* Per-stage fresh WW_PKGCACHE -> every package compiles COLD, so the
|
||||
/* Each direct build compiles every package, so the
|
||||
* `.s`/`.wwi`/`.unit.ww` this gate inspects are always produced. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"WW_PKGCACHE='%s/cache.%s' timeout 240 %s/%s build --sep "
|
||||
"timeout 240 %s/%s build "
|
||||
"-I %s/lib -o %s %s >/dev/null 2>&1",
|
||||
td, stg[s].tag, bin, stg[s].drv, td, stg[s].prog, rootww);
|
||||
bin, stg[s].drv, td, stg[s].prog, rootww);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "sepstructdef FAIL: %s build --sep (pre-fix: the "
|
||||
fprintf(stderr, "sepstructdef FAIL: %s build (pre-fix: the "
|
||||
"aggregate-init def aborts the producer with \"node kind 15\")\n",
|
||||
stg[s].drv);
|
||||
fail++;
|
||||
@@ -238,8 +239,31 @@ main(void)
|
||||
}
|
||||
|
||||
out:
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", td);
|
||||
runwait(cmd);
|
||||
for (int s = 0; s < 2; s++) {
|
||||
const char *tag = s == 0 ? "cs" : "ww";
|
||||
snprintf(p, sizeof p, "%s/prog.%s.sepwork", td, tag);
|
||||
snprintf(cmd, sizeof cmd, "rm -rf -- '%s'", p);
|
||||
if (runwait(cmd) != 0) cleanup_fail = 1;
|
||||
snprintf(p, sizeof p, "%s/prog.%s", td, tag);
|
||||
if (unlink(p) != 0 && errno != ENOENT) cleanup_fail = 1;
|
||||
}
|
||||
snprintf(p, sizeof p, "%s/root.ww", td);
|
||||
if (unlink(p) != 0 && errno != ENOENT) cleanup_fail = 1;
|
||||
if (have_d) {
|
||||
snprintf(p, sizeof p, "%s/lib/d/mod.ww", td);
|
||||
if (unlink(p) != 0 && errno != ENOENT) cleanup_fail = 1;
|
||||
snprintf(p, sizeof p, "%s/lib/d", td);
|
||||
if (rmdir(p) != 0 && errno != ENOENT) cleanup_fail = 1;
|
||||
}
|
||||
if (have_lib) {
|
||||
snprintf(p, sizeof p, "%s/lib", td);
|
||||
if (rmdir(p) != 0 && errno != ENOENT) cleanup_fail = 1;
|
||||
}
|
||||
if (rmdir(td) != 0) cleanup_fail = 1;
|
||||
if (cleanup_fail) {
|
||||
fprintf(stderr, "sepstructdef FAIL: cleanup incomplete under %s\n", td);
|
||||
fail++;
|
||||
}
|
||||
if (fail) {
|
||||
fprintf(stderr, "sepstructdef: %d check(s) failed\n", fail);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user