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:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 956_modqualdestr_run — runtime + byte-id + stamp regression net for
|
||||
* 956_modqualdestr_run — byte-id + stamp regression net for
|
||||
* #6a-A: module-qualified destructure binding types.
|
||||
*
|
||||
* THE GAP: the wwstage N_MLET handler (check.ww) backfilled destructure
|
||||
@@ -23,17 +23,16 @@
|
||||
* Sibling of 956_tuprecv_f64_run (same-module float destructure, bare
|
||||
* N_IDENT callee) and 953_f64crossmod_run (single-call module-qualified
|
||||
* f64). Single-file multi-package form (like 953) so w6c/w6c_ww see the
|
||||
* cross-module call without -I plumbing. Each row carries three
|
||||
* dimensions:
|
||||
* (a) cstage `ww build` + run, asserting the exit code (cstage is the
|
||||
* reference — correct pre- and post-fix).
|
||||
* (b) w6c vs w6c_ww `.s` cmp — rule-10 byte-id; pre-fix the float row
|
||||
* cross-module call without -I plumbing. Runtime values now live in
|
||||
* r956_modqual_* fixtures. This carrier retains two dimensions:
|
||||
* (a) w6c vs w6c_ww `.s` cmp — rule-10 byte-id; pre-fix the float row
|
||||
* diverges (w6c_ww loud-aborts, emits no .s).
|
||||
* (c) #6a-A stamp gate: w6c_ww must emit no `asserttyped:` diagnostic
|
||||
* (b) #6a-A stamp gate: w6c_ww must emit no `asserttyped:` diagnostic
|
||||
* on the destructure binding idents. Pre-fix fires on every use.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -50,7 +49,6 @@ runwait(const char *cmd)
|
||||
struct row {
|
||||
const char *label;
|
||||
const char *src;
|
||||
int want_exit;
|
||||
};
|
||||
|
||||
static const struct row rows[] = {
|
||||
@@ -73,7 +71,7 @@ static const struct row rows[] = {
|
||||
"\tif (g != 9.0) { return 1; };\n"
|
||||
"\tif (exp != 1i64) { return 2; };\n"
|
||||
"\treturn 0;\n"
|
||||
"};\n", 0 },
|
||||
"};\n" },
|
||||
/* DOMINANT CLASS-A — module-qualified INTEGER destructure (the
|
||||
* checked.addXX shape: `let (res, ov) = checked.addi64(a, b)`). cgen's
|
||||
* structural classifier already routed the integer codegen, so this
|
||||
@@ -92,7 +90,7 @@ static const struct row rows[] = {
|
||||
"\tif (res != 15i64) { return 1; };\n"
|
||||
"\tif (ov) { return 2; };\n"
|
||||
"\treturn (res: i32);\n"
|
||||
"};\n", 15 },
|
||||
"};\n" },
|
||||
/* MIXED — module-qualified (f64, str) destructure: the float rides
|
||||
* the SSE cursor (X0), the str rides the integer cursor (AX,DX,CX).
|
||||
* Confirms the stamp distributes correctly onto a wide-header binding
|
||||
@@ -111,7 +109,7 @@ static const struct row rows[] = {
|
||||
"\tif (g != 4.0) { return 1; };\n"
|
||||
"\tif (s.len != 5) { return 2; };\n"
|
||||
"\treturn (f: i32);\n"
|
||||
"};\n", 4 },
|
||||
"};\n" },
|
||||
/* CLASS-CLOSURE — NON-destructure cross-module same-leaf shadow. The
|
||||
* #6a-A fix lives at the exprtype N_CALL root, so it closes the whole
|
||||
* class, not just the destructure surface (same coverage-trap as the
|
||||
@@ -135,8 +133,8 @@ static const struct row rows[] = {
|
||||
"\treturn (r.0: i32) + (r.1: i32);\n"
|
||||
"};\n"
|
||||
"package alpha;\n"
|
||||
"export fn dup() (i64, str) = { return (9i64, \"wrong\"); };\n", 10 },
|
||||
{ NULL, NULL, 0 }
|
||||
"export fn dup() (i64, str) = { return (9i64, \"wrong\"); };\n" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -180,66 +178,52 @@ main(void)
|
||||
|
||||
int n = 0, fail = 0;
|
||||
for (int i = 0; rows[i].src; i++, n++) {
|
||||
/* src, outbin, cs.s, ww.s, err all live under one tmpdir so
|
||||
* the compiler's path-derived .sepwork scratch stays inside it
|
||||
* and a single rm -rf reclaims everything (V3). */
|
||||
char tmpdir[64], rmcmd[160];
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/wwmqd_%d_d_%d",
|
||||
getpid(), i);
|
||||
mkdir(tmpdir, 0755);
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
|
||||
|
||||
char src[128];
|
||||
snprintf(src, sizeof src, "%s/wwmqd_%d_%d.ww",
|
||||
tmpdir, getpid(), i);
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (f == NULL) { fail++; runwait(rmcmd); continue; }
|
||||
fputs(rows[i].src, f);
|
||||
fclose(f);
|
||||
|
||||
char cmd[2048];
|
||||
|
||||
/* (a) cstage build + run. */
|
||||
char outbin[128];
|
||||
snprintf(outbin, sizeof outbin, "%s/wwmqd_%d_%d",
|
||||
tmpdir, getpid(), i);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s/ww build -o %s %s",
|
||||
bin, outbin, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: cstage build failed\n",
|
||||
rows[i].label);
|
||||
/* Every compiler input, output, and capture lives under one
|
||||
* collision-safe directory owned by this row. */
|
||||
char tmpdir[] = "/tmp/wwmqd_XXXXXX";
|
||||
if (mkdtemp(tmpdir) == NULL) {
|
||||
fprintf(stderr, "row[%s]: mkdtemp failed\n", rows[i].label);
|
||||
fail++;
|
||||
runwait(rmcmd);
|
||||
continue;
|
||||
}
|
||||
|
||||
int got = runwait(outbin);
|
||||
if (got != rows[i].want_exit) {
|
||||
fprintf(stderr, "row[%s]: cstage exit %d, want %d\n",
|
||||
rows[i].label, got, rows[i].want_exit);
|
||||
char src[128];
|
||||
snprintf(src, sizeof src, "%s/case.ww", tmpdir);
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "row[%s]: source open failed\n", rows[i].label);
|
||||
fail++;
|
||||
goto row_cleanup;
|
||||
}
|
||||
int writefail = fputs(rows[i].src, f) == EOF;
|
||||
if (fclose(f) != 0) writefail = 1;
|
||||
if (writefail) {
|
||||
fprintf(stderr, "row[%s]: source write failed\n", rows[i].label);
|
||||
fail++;
|
||||
goto row_cleanup;
|
||||
}
|
||||
|
||||
/* (b) cs==ww byte-id gate: emit .s from both stages, cmp. */
|
||||
char cmd[2048];
|
||||
|
||||
/* cs==ww byte-id gate: emit .s from both stages, cmp. */
|
||||
char cs_s[128], ws_s[128];
|
||||
snprintf(cs_s, sizeof cs_s, "%s/wwmqd_%d_%d_cs.s",
|
||||
tmpdir, getpid(), i);
|
||||
snprintf(ws_s, sizeof ws_s, "%s/wwmqd_%d_%d_ww.s",
|
||||
tmpdir, getpid(), i);
|
||||
snprintf(cs_s, sizeof cs_s, "%s/cs.s", tmpdir);
|
||||
snprintf(ws_s, sizeof ws_s, "%s/ww.s", tmpdir);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null",
|
||||
w6c, cs_s, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c failed\n", rows[i].label);
|
||||
fail++; runwait(rmcmd); continue;
|
||||
fail++;
|
||||
goto row_cleanup;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null",
|
||||
w6c_ww, ws_s, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww failed\n",
|
||||
rows[i].label);
|
||||
fail++; runwait(rmcmd); continue;
|
||||
fail++;
|
||||
goto row_cleanup;
|
||||
}
|
||||
if (slurp_eq(cs_s, ws_s) != 0) {
|
||||
fprintf(stderr,
|
||||
@@ -248,24 +232,45 @@ main(void)
|
||||
fail++;
|
||||
}
|
||||
|
||||
/* (c) #6a-A stamp gate: the module-qualified destructure
|
||||
/* The module-qualified destructure
|
||||
* binding must carry a checker type stamp, so w6c_ww emits no
|
||||
* `asserttyped:` diagnostic on its idents. Non-vacuous —
|
||||
* pre-fix (HEAD) w6c_ww fires asserttyped on every binding use
|
||||
* (and the float row loud-aborts in cgen above). */
|
||||
char errf[128];
|
||||
snprintf(errf, sizeof errf,
|
||||
"%s/wwmqd_%d_%d_err.txt", tmpdir, getpid(), i);
|
||||
snprintf(errf, sizeof errf, "%s/err.txt", tmpdir);
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s -o /dev/null %s 2>%s", w6c_ww, src, errf);
|
||||
runwait(cmd);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww stamp probe failed\n",
|
||||
rows[i].label);
|
||||
fail++;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "grep -q asserttyped %s", errf);
|
||||
if (runwait(cmd) == 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww emitted asserttyped "
|
||||
"(destructure binding unstamped)\n", rows[i].label);
|
||||
fail++;
|
||||
}
|
||||
runwait(rmcmd);
|
||||
|
||||
row_cleanup:
|
||||
{
|
||||
int cleanfail = 0;
|
||||
char path[128];
|
||||
const char *children[] = {
|
||||
"case.ww", "cs.s", "ww.s", "err.txt", NULL
|
||||
};
|
||||
for (int j = 0; children[j]; j++) {
|
||||
snprintf(path, sizeof path, "%s/%s", tmpdir, children[j]);
|
||||
if (unlink(path) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
}
|
||||
if (rmdir(tmpdir) != 0) cleanfail = 1;
|
||||
if (cleanfail) {
|
||||
fprintf(stderr, "row[%s]: temporary cleanup failed\n",
|
||||
rows[i].label);
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fail) {
|
||||
@@ -273,7 +278,7 @@ main(void)
|
||||
fail, n);
|
||||
return 1;
|
||||
}
|
||||
printf("modqualdestr: %d/%d ok (cstage run + cs==ww byte-id + "
|
||||
printf("modqualdestr: %d/%d ok (cs==ww byte-id + "
|
||||
"stamp)\n", n, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user