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:
@@ -2,20 +2,20 @@
|
||||
* 989_seproot_export_run — sep-build of a ROOT unit whose `export fn`
|
||||
* references an unexported LOCAL type (#69, BUG-1).
|
||||
*
|
||||
* Root cause it guards: the `--sep` producer loop compiled EVERY package,
|
||||
* Root cause it guards: the separate-compilation producer compiled EVERY package,
|
||||
* INCLUDING the root build-target, with the `.wwi`-producer `-I` flag.
|
||||
* `-I` triggers wwi_emit -> check_exported_type, which rejects an exported
|
||||
* declaration that references an unexported type. A terminal binary's root
|
||||
* legitimately has such a decl (`export fn use(a: *t)` over an unexported
|
||||
* local `type t`) — fine, because the root is never imported, so its `.wwi`
|
||||
* is never consumed. The combined build never passes `-I` -> builds+runs;
|
||||
* the sep build rejected the root -> blocked every real tool's sep-build.
|
||||
* is never consumed. Historically, the separately compiled root was also
|
||||
* passed `-I`, so it rejected and blocked every real tool build.
|
||||
* Fix: for pi==root the producer invokes `w6c -c -o` WITHOUT `-I`.
|
||||
*
|
||||
* Graph (smallest reproducing shape): root -> { c (one real dep package) }.
|
||||
* The root exports `use(a: *t)` over the unexported local `type t`.
|
||||
*
|
||||
* Asserts (all COLD — per-stage WW_PKGCACHE wipes the package cache):
|
||||
* Asserts (direct builds compile every package):
|
||||
* 1. Build + run, BOTH stages -> exit EXPECT_EXIT. Pre-fix the root w6c
|
||||
* pass exited 1 ("exported declaration references unexported type"),
|
||||
* so the build never produced a binary.
|
||||
@@ -28,8 +28,7 @@
|
||||
* for BOTH compilers (w6c, w6c_ww). This is the bug, isolated.
|
||||
* 4. The root `.s` is produced and defines the exported fn symbol.
|
||||
*
|
||||
* 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_sepdotpath_run.c conventions; 989 prefix per the sep-gate precedent.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
@@ -38,6 +37,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define EXPECT_EXIT 37
|
||||
|
||||
@@ -124,16 +124,27 @@ main(void)
|
||||
const char *bin = absbin();
|
||||
if (!bin) return 1;
|
||||
char td[64], cmd[8192], p[1024];
|
||||
int fail = 0;
|
||||
int fail = 0, have_lib = 0, have_c = 0;
|
||||
|
||||
snprintf(td, sizeof td, "/tmp/wwseproot_%d", getpid());
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", td);
|
||||
runwait(cmd);
|
||||
mkdir(td, 0755);
|
||||
if (mkdir(td, 0755) != 0) {
|
||||
fprintf(stderr, "seproot FAIL: cannot acquire %s\n", td);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* lib/c — one real dep package the root imports. */
|
||||
snprintf(p, sizeof p, "%s/lib", td); mkdir(p, 0755);
|
||||
snprintf(p, sizeof p, "%s/lib/c", td); mkdir(p, 0755);
|
||||
snprintf(p, sizeof p, "%s/lib", td);
|
||||
if (mkdir(p, 0755) != 0) {
|
||||
fprintf(stderr, "seproot FAIL: cannot create %s\n", p);
|
||||
fail++; goto out;
|
||||
}
|
||||
have_lib = 1;
|
||||
snprintf(p, sizeof p, "%s/lib/c", td);
|
||||
if (mkdir(p, 0755) != 0) {
|
||||
fprintf(stderr, "seproot FAIL: cannot create %s\n", p);
|
||||
fail++; goto out;
|
||||
}
|
||||
have_c = 1;
|
||||
snprintf(p, sizeof p, "%s/lib/c/mod.ww", td);
|
||||
if (write_file(p, "package c;\nexport fn cval() i32 = { return 5; };\n"))
|
||||
{ fail++; goto out; }
|
||||
@@ -158,14 +169,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`/`.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, "seproot FAIL: %s build --sep (pre-fix: -I on root "
|
||||
fprintf(stderr, "seproot FAIL: %s build (pre-fix: -I on root "
|
||||
"rejects export-fn-over-unexported-type)\n", stg[s].drv);
|
||||
fail++;
|
||||
continue;
|
||||
@@ -260,8 +271,46 @@ main(void)
|
||||
}
|
||||
|
||||
out:
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", td);
|
||||
runwait(cmd);
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"rm -rf -- '%s/prog.cs.sepwork' '%s/prog.ww.sepwork'", td, td);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "seproot FAIL: cannot clean .sepwork trees\n");
|
||||
fail++;
|
||||
}
|
||||
{
|
||||
char path[1200];
|
||||
snprintf(path, sizeof path, "%s/root.ww", td);
|
||||
if (unlink(path) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", path); fail++; }
|
||||
snprintf(path, sizeof path, "%s/prog.cs", td);
|
||||
if (unlink(path) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", path); fail++; }
|
||||
snprintf(path, sizeof path, "%s/prog.ww", td);
|
||||
if (unlink(path) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", path); fail++; }
|
||||
snprintf(path, sizeof path, "%s/nv.w6c.wwi", td);
|
||||
if (unlink(path) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", path); fail++; }
|
||||
snprintf(path, sizeof path, "%s/nv.w6c.s", td);
|
||||
if (unlink(path) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", path); fail++; }
|
||||
snprintf(path, sizeof path, "%s/nv.w6c_ww.wwi", td);
|
||||
if (unlink(path) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", path); fail++; }
|
||||
snprintf(path, sizeof path, "%s/nv.w6c_ww.s", td);
|
||||
if (unlink(path) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", path); fail++; }
|
||||
}
|
||||
if (have_c) {
|
||||
snprintf(p, sizeof p, "%s/lib/c", td);
|
||||
{
|
||||
char path[1200];
|
||||
snprintf(path, sizeof path, "%s/mod.ww", p);
|
||||
if (unlink(path) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", path); fail++; }
|
||||
}
|
||||
if (rmdir(p) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", p); fail++; }
|
||||
}
|
||||
if (have_lib) {
|
||||
snprintf(p, sizeof p, "%s/lib", td);
|
||||
if (rmdir(p) != 0 && errno != ENOENT) { fprintf(stderr, "seproot FAIL: cannot remove %s\n", p); fail++; }
|
||||
}
|
||||
if (rmdir(td) != 0 && errno != ENOENT) {
|
||||
fprintf(stderr, "seproot FAIL: cannot remove %s\n", td);
|
||||
fail++;
|
||||
}
|
||||
if (fail) {
|
||||
fprintf(stderr, "seproot: %d check(s) failed\n", fail);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user