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:
@@ -37,6 +37,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -53,20 +54,24 @@ runwait(const char *cmd)
|
||||
static int
|
||||
run_row(const char *driver, const char *fixdir, const char *tag)
|
||||
{
|
||||
/* Scratch dir OUT of the repo: the driver's sep `<stem>.sepwork/`
|
||||
* follows the build output stem, so point -o into /tmp so both the
|
||||
* binary and its .sepwork land there and die with rm -rf. */
|
||||
/* Keep the output and its caller-owned `<stem>.sepwork/` in one
|
||||
* invocation-owned directory outside the repository. */
|
||||
char td[64];
|
||||
snprintf(td, sizeof td, "/tmp/usepr_%d_%s", getpid(), tag);
|
||||
mkdir(td, 0755);
|
||||
char rmcmd[128];
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", td);
|
||||
if (mkdir(td, 0755) != 0) {
|
||||
fprintf(stderr, "use_promote_alias[%s]: mkdir %s: %s\n",
|
||||
tag, td, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
char src[64];
|
||||
snprintf(src, sizeof src, "pos_%s.ww", tag);
|
||||
char bin[2048];
|
||||
char bin[2048], sepdir[2048], rmcmd[2112];
|
||||
snprintf(bin, sizeof bin, "%s/out", td);
|
||||
snprintf(sepdir, sizeof sepdir, "%s.sepwork", bin);
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", sepdir);
|
||||
char cmd[2048];
|
||||
int failed = 0, got;
|
||||
/* cd into the fixture dir so the driver's source-dir-first
|
||||
* import search resolves `use <tag>mod;`; -o points OUT of the repo. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
@@ -75,17 +80,37 @@ run_row(const char *driver, const char *fixdir, const char *tag)
|
||||
fprintf(stderr,
|
||||
"use_promote_alias[%s]: build failed — SK_USE→SK_X "
|
||||
"promotion likely dropped use_alias\n", tag);
|
||||
runwait(rmcmd);
|
||||
return 1;
|
||||
failed = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
int got = runwait(bin);
|
||||
runwait(rmcmd);
|
||||
got = runwait(bin);
|
||||
if (got != 42) {
|
||||
fprintf(stderr,
|
||||
"use_promote_alias[%s]: exit=%d want=42\n", tag, got);
|
||||
return 1;
|
||||
failed = 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
{
|
||||
int cleanup_failed = 0;
|
||||
if (runwait(rmcmd) != 0) {
|
||||
fprintf(stderr, "use_promote_alias[%s]: remove %s failed\n",
|
||||
tag, sepdir);
|
||||
cleanup_failed = 1;
|
||||
}
|
||||
if (unlink(bin) != 0 && errno != ENOENT) {
|
||||
fprintf(stderr, "use_promote_alias[%s]: unlink %s: %s\n",
|
||||
tag, bin, strerror(errno));
|
||||
cleanup_failed = 1;
|
||||
}
|
||||
if (rmdir(td) != 0) {
|
||||
fprintf(stderr, "use_promote_alias[%s]: rmdir %s: %s\n",
|
||||
tag, td, strerror(errno));
|
||||
cleanup_failed = 1;
|
||||
}
|
||||
if (!failed && cleanup_failed) failed = 1;
|
||||
}
|
||||
return failed;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user