test: contain sepwork scratch per-driver tmpdir, fix /tmp+in-repo leak (#8)
The wcc test drivers ran `ww build <bare-/tmp src>` with no -o, so the compiler's <stem>.sepwork scratch landed beside the source and was never cleaned: unbounded /tmp growth (2195 stale dirs observed) that fills tmpfs and fabricates phantom test failures + silent harness aborts, and for in-repo fixture builds leaked .sepwork into the tracked tree. Each leaking build now writes its source + output inside a per-invocation tmpdir, passes -o <tmpdir>/<stem> so the .sepwork lands inside it, and rm -rf's the tmpdir on every exit path -- including fopen-fail and the expected-fail reject builds (scratch is mkdir'd before the build can fail). `ww run` and explicit-`-o`/byte-id helpers are left as-is; the 990/993 byte-id comparison logic is byte-for-byte unchanged. Two items filed separately (this commit holds the no-Makefile / no-main.c rail): - #13: a stale <src>.s byte-id readback (749) silently no-ops since separate-compile emits .s to <ostem>.sepwork/__root.s; documented inline. - #14: build-system Makefile recipes build selfhost/cmd/*/main.ww with no -o and leak main.sepwork in-tree (bounded, gitignored; own commit). One concern -- sepwork leak hygiene -- across 228 drivers; uniform transform applied per-file and two-round reviewed. make test: all 402 passed, zero net-new /tmp scratch, zero test-driven in-repo .sepwork.
This commit is contained in:
@@ -97,23 +97,26 @@ probe_smoke(const char *bin)
|
||||
char tmpdir[64];
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/wwsh_%d", getpid());
|
||||
mkdir(tmpdir, 0755);
|
||||
char rmcmd[128];
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
|
||||
/* #8: -o routes the binary + .sepwork scratch into tmpdir; without it
|
||||
* the scratch lands next to the in-repo fixture as
|
||||
* selfhost/test/smoke.sepwork and races concurrent gates. rm -rf
|
||||
* clears the now-non-empty tmpdir on every exit path. */
|
||||
char cmd[2048];
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/ww build %s/selfhost/test/smoke.ww >/dev/null 2>&1",
|
||||
tmpdir, bin, cwd);
|
||||
"timeout 180 %s/ww build -o %s/smoke %s/selfhost/test/smoke.ww "
|
||||
">/dev/null 2>&1", bin, tmpdir, cwd);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "smoke FAIL: ww build did not succeed\n");
|
||||
runwait(rmcmd);
|
||||
return -1;
|
||||
}
|
||||
char outbin[256], runcmd[512];
|
||||
snprintf(outbin, sizeof outbin, "%s/smoke", tmpdir);
|
||||
snprintf(runcmd, sizeof runcmd, "timeout 180 %s", outbin);
|
||||
int rc = runwait(runcmd);
|
||||
unlink(outbin);
|
||||
char tmp[1024];
|
||||
snprintf(tmp, sizeof tmp, "%s/smoke.s", tmpdir); unlink(tmp);
|
||||
snprintf(tmp, sizeof tmp, "%s/smoke.o", tmpdir); unlink(tmp);
|
||||
rmdir(tmpdir);
|
||||
runwait(rmcmd);
|
||||
if (rc != 42) {
|
||||
fprintf(stderr, "smoke FAIL: exit=%d (want 42; the number "
|
||||
"names which probe in selfhost/test/smoke.ww broke)\n", rc);
|
||||
|
||||
Reference in New Issue
Block a user