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:
@@ -24,6 +24,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -40,29 +41,46 @@ runwait(const char *cmd)
|
||||
static int
|
||||
run_pos(const char *driver, const char *fixdir, const char *tag)
|
||||
{
|
||||
/* -o into a /tmp tmpdir so the binary AND `<stem>.sepwork/` land
|
||||
* outside the repo; the cd keeps source-dir-first import search
|
||||
/* -o puts the binary and caller-owned `<stem>.sepwork/` under the
|
||||
* acquired directory; the cd keeps source-dir-first import search
|
||||
* resolving `use mod1; use mod2;`. */
|
||||
char td[1024];
|
||||
char td[1024], outbin[1024], sepwork[1100];
|
||||
snprintf(td, sizeof td, "/tmp/smprefer_%d_%s", getpid(), tag);
|
||||
mkdir(td, 0755);
|
||||
|
||||
char rmcmd[1152];
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", td);
|
||||
if (mkdir(td, 0755) != 0) {
|
||||
fprintf(stderr, "samemod_prefer[%s]: mkdir %s failed\n", tag, td);
|
||||
return 1;
|
||||
}
|
||||
snprintf(outbin, sizeof outbin, "%s/pos", td);
|
||||
snprintf(sepwork, sizeof sepwork, "%s/pos.sepwork", td);
|
||||
|
||||
char cmd[2048];
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s build -o %s/pos pos.ww >/dev/null 2>&1",
|
||||
fixdir, driver, td);
|
||||
int fail = 0;
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr,
|
||||
"samemod_prefer[%s]: pos.ww build failed — bare-leaf "
|
||||
"`read` lookup likely cross-bound\n", tag);
|
||||
runwait(rmcmd);
|
||||
return 1;
|
||||
fail = 1;
|
||||
}
|
||||
runwait(rmcmd);
|
||||
return 0;
|
||||
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", sepwork);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "samemod_prefer[%s]: cleanup %s failed\n",
|
||||
tag, sepwork);
|
||||
fail = 1;
|
||||
}
|
||||
if (unlink(outbin) != 0 && errno != ENOENT) {
|
||||
fprintf(stderr, "samemod_prefer[%s]: cleanup %s failed\n",
|
||||
tag, outbin);
|
||||
fail = 1;
|
||||
}
|
||||
if (rmdir(td) != 0) {
|
||||
fprintf(stderr, "samemod_prefer[%s]: cleanup %s failed\n", tag, td);
|
||||
fail = 1;
|
||||
}
|
||||
return fail;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user