ww test: allow -c with persistent workdirs

This commit is contained in:
2026-08-20 20:40:01 +09:00
parent db5782eff9
commit 77168fd891
5 changed files with 66 additions and 45 deletions

View File

@@ -9215,18 +9215,26 @@ fn cwdwritedata(dir: str, label: str) void = {
(30i64 * (time.second: i64)): time.duration, &outc);
expectexit(&outc, 0);
assert(same(outc.stdout, seq));
// -c publishes caller-owned artifacts; a persistent workdir is a
// different ownership contract — the coordinator rejects the mix.
// The retained executable is separate from the persistent action store, so
// -c can suppress execution while reusing the same complete graph.
let wcbin: str = strings.concat(root, "/tree-wc-c.test");
let wwbin: str = strings.concat(root, "/tree-wc-ww.test");
let wcc: []str = [driver("ww"), "test", "-c", "-w", wdroot,
"-I", tree, spec];
"-o", wcbin, "-I", tree, strings.concat(tree, "/alpha")];
let wcw: []str = [driver("ww_ww"), "test", "-c", "-w", wdroot,
"-I", tree, spec];
runcommand(root, "tree-wc-c", wcc, time.second, &outc);
runcommand(root, "tree-wc-ww", wcw, time.second, &outw);
expectexit(&outc, 2);
expectexit(&outw, 2);
"-o", wwbin, "-I", tree, strings.concat(tree, "/alpha")];
runcommand(root, "tree-wc-c", wcc,
(30i64 * (time.second: i64)): time.duration, &outc);
runcommand(root, "tree-wc-ww", wcw,
(30i64 * (time.second: i64)): time.duration, &outw);
expectexit(&outc, 0);
expectexit(&outw, 0);
assert(outc.stdout.len == 0 && outc.stderr.len == 0);
assert(outw.stdout.len == 0 && outw.stderr.len == 0);
assert(os.exists(wcbin) && os.exists(wwbin));
assert(same(readfile(wcbin), readfile(wwbin)));
assert(same(outc.stderr, outw.stderr));
assert(has(outc.stderr, "wwtest package: -w conflicts with -c\n"));
clean(wcbin); clean(wwbin);
let bare: str = strings.concat(root, "/bare");
let barez: str = strings.concat(root, "/zz-bare");
@@ -12566,42 +12574,60 @@ fn runtimepath(relative: str) str = {
if (si == 0) { failurebytes = readfile(failurebin); }
else { assert(same(failurebytes, readfile(failurebin))); };
// -w keeps semantic actions persistent while -o remains a presentation
// copy. Unchanged input reuses actions; changed input replaces the copy.
// -w keeps semantic actions persistent while -c and -o remain execution
// and presentation policy. Compile-only can cold-build and invalidate;
// an unchanged running request reuses those actions and the same bytes.
rewritefile(persisttest, persistbase);
let persistwork: str = strings.concat(root, "/persist-work-", tags[si]);
let persistbin: str = strings.concat(root, "/persist.test");
if (os.exists(persistbin)) { clean(persistbin); };
let persistcompilebin: str = strings.concat(root, "/persist-compile-",
tags[si], ".test");
let persistbin: str = strings.concat(root, "/persist-run-", tags[si],
".test");
rewritefile(ctrace, ""); rewritefile(ltrace, "");
let persistcompileav: []str = [driver(stages[si]), "test", "-c",
"-w", persistwork, "-I", suite, "-o", persistcompilebin,
persist];
let persistav: []str = [driver(stages[si]), "test", "-w",
persistwork, "-I", suite, "-o", persistbin, persist];
runcommandenvdir(root, strings.concat("publish-persist-cold-", tags[si]),
runcommandenvdir(root, strings.concat("publish-persist-cold-c-", tags[si]),
persistcompileav, env, root,
(120i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(out.stdout.len == 0 && out.stderr.len == 0);
assert(readfile(ctrace).len != 0);
let basebytes: str = readfile(persistcompilebin);
if (si == 0) { persistbasebytes = strings.dup(basebytes); }
else { assert(same(persistbasebytes, basebytes)); };
rewritefile(ctrace, ""); rewritefile(ltrace, "");
runcommandenvdir(root, strings.concat("publish-persist-warm-run-", tags[si]),
persistav, env, root,
(120i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(has(out.stdout, "persistent_base ... ok\n"));
let basebytes: str = readfile(persistbin);
if (si == 0) { persistbasebytes = strings.dup(basebytes); }
else { assert(same(persistbasebytes, basebytes)); };
rewritefile(ctrace, ""); rewritefile(ltrace, "");
runcommandenvdir(root, strings.concat("publish-persist-warm-", tags[si]),
persistav, env, root,
(120i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(readfile(ctrace).len == 0);
assert(same(basebytes, readfile(persistbin)));
rewritefile(persisttest, persistchanged);
rewritefile(ctrace, ""); rewritefile(ltrace, "");
runcommandenvdir(root, strings.concat("publish-persist-change-", tags[si]),
persistav, env, root,
runcommandenvdir(root, strings.concat("publish-persist-change-c-", tags[si]),
persistcompileav, env, root,
(120i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(has(out.stdout, "persistent_changed ... ok\n"));
assert(out.stdout.len == 0 && out.stderr.len == 0);
assert(readfile(ctrace).len != 0);
let changedbytes: str = readfile(persistbin);
let changedbytes: str = readfile(persistcompilebin);
assert(!same(basebytes, changedbytes));
if (si == 0) { persistchangedbytes = strings.dup(changedbytes); }
else { assert(same(persistchangedbytes, changedbytes)); };
rewritefile(ctrace, ""); rewritefile(ltrace, "");
runcommandenvdir(root, strings.concat("publish-persist-change-run-",
tags[si]), persistav, env, root,
(120i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(has(out.stdout, "persistent_changed ... ok\n"));
assert(readfile(ctrace).len == 0);
assert(same(changedbytes, readfile(persistbin)));
assert(!os.exists(strings.concat(persistcompilebin, ".new")));
assert(!os.exists(strings.concat(persistbin, ".new")));
assert(!directoryhasnew(persistwork));
si += 1;
};