test: retarget Pattern-B gates to sep .sepwork layout; 915 off private global (M4 E3, #93)

The driver flip moves build artifacts from next-to-source <stem>.s to a
.sepwork/ scratch dir. 29 Pattern-B gates now build `ww build --sep -o <stem>`
and read <stem>.sepwork/__root.s (multi-package gates concat all
<stem>.sepwork/*.s, since cross-package labels live in per-package .s).
All intermediates redirect to /tmp (WW_PKGCACHE + -o), so the corpus runs
parallel-safe with no source-tree pollution. Tests pass now (--sep is live)
and survive the flip.

915 additionally retargeted off strconv's PRIVATE left_shift_table (a let,
not export) — which separate compilation correctly hides — onto a test-local
package that exports its own probe table (#96). The combined path only linked
it via a single-unit private leak; encapsulation is now honored under sep.

Test-only; all 5 *_ww binaries HOLD. 989_m1mangle_run deferred (blocked by
#99, imported-package fn main mangling under sep).
This commit is contained in:
2026-06-18 11:12:04 +09:00
parent 24ca570a7e
commit eb6083e54a
30 changed files with 583 additions and 324 deletions

View File

@@ -63,14 +63,17 @@ main(void)
char cwd[1024];
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
/* Ensure mandelbrot.o exists. The example's Makefile produces it
* via the C-side `ww build`. Re-run that so the test is
* self-contained. */
char cmd[4096];
/* #93 sep layout: build the example via `ww build --sep` into a
* private /tmp stem (NOT next to the tracked example source), then
* link <stem>.sepwork/__root.o — the self-contained single-package
* object the flip emits in place of the old next-to-source .o. */
char cmd[4096], mbstem[256], mbobj[320];
snprintf(mbstem, sizeof mbstem, "/tmp/wwld_%d_mb", getpid());
snprintf(mbobj, sizeof mbobj, "%s.sepwork/__root.o", mbstem);
snprintf(cmd, sizeof cmd,
"cd %s/examples/mandelbrot && %s/ww build mandelbrot.ww "
"-L /usr/lib -l c >/dev/null 2>&1",
cwd, bin);
"cd %s/examples/mandelbrot && WW_PKGCACHE=%s.pkgc %s/ww build --sep "
"-o %s mandelbrot.ww -L /usr/lib -l c >/dev/null 2>&1",
cwd, mbstem, bin, mbstem);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: cannot build mandelbrot.o via C driver\n");
return 1;
@@ -82,9 +85,9 @@ main(void)
/* C-side w6l with the dynamic flags. */
snprintf(cmd, sizeof cmd,
"%s/w6l -o %s %s/examples/mandelbrot/mandelbrot.o -L /usr/lib "
"%s/w6l -o %s %s -L /usr/lib "
"-l c %s/out/lib/libwwrt.a 2>/dev/null",
bin, co, cwd, cwd);
bin, co, mbobj, cwd);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: C w6l errored\n");
unlink(co);
@@ -93,9 +96,9 @@ main(void)
/* ww-side w6l with the same flags. */
snprintf(cmd, sizeof cmd,
"%s/w6l_ww -o %s %s/examples/mandelbrot/mandelbrot.o -L /usr/lib "
"%s/w6l_ww -o %s %s -L /usr/lib "
"-l c %s/out/lib/libwwrt.a 2>/dev/null",
bin, wo, cwd, cwd);
bin, wo, mbobj, cwd);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: ww w6l errored\n");
unlink(co); unlink(wo);
@@ -119,5 +122,8 @@ main(void)
}
free(bc); free(bw);
unlink(co); unlink(wo);
/* #93: the sep scratch + tmpdir-pinned pkgcache. */
snprintf(cmd, sizeof cmd, "rm -rf %s.sepwork %s.pkgc %s", mbstem, mbstem, mbstem);
if (system(cmd)) {}
return rc;
}