test/package: wire the runtime fixture set into package_test

test/package/runtime/ was a manual README-driven corpus with no
target. Its unique surface — the driver's single-file ww test leg,
the unmet-expected-abort outcome, and the published -c binary's own
CLI (repeated globs, -list, -timeout-ms, direct-binary timeout and
descendant handling) — is now asserted by three new @test fns in
package_test.ww; the README drops its manual-run instructions.
This commit is contained in:
2026-08-08 00:39:53 +09:00
parent 0b23f9fb31
commit 90af21e132
2 changed files with 180 additions and 42 deletions

View File

@@ -442,3 +442,163 @@ fn packagepath(relative: str) str = {
"/route_test.test.sepwork/__root.s"))));
clean(root);
};
fn runtimepath(relative: str) str = {
return strings.concat(repo(), "/test/package/runtime/", relative);
};
// The single-FILE `ww test <file>` route wraps the same in-binary test
// runtime as the directory-package route (cases/*), but through the
// driver's single-file leg. One row per outcome class keeps that leg's
// wiring honest; the runtime-internal classifications themselves are
// owned by the cases/* tests above.
@test fn singlefile_runtime_outcomes() void = {
let root: str = fresh();
let out: commandout;
let successav: []str = [driver("ww"), "test",
runtimepath("success_test.ww")];
runcommand(root, "sf-success", successav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(has(out.stdout, "alpha_pass ... ok\n"));
assert(has(out.stdout,
"beta_skip ... SKIP: synthetic unavailable feature\n"));
assert(has(out.stdout, "gamma_expected_abort ... ok\n"));
assert(has(out.stdout, "delta_pass ... ok\n"));
assert(has(out.stdout,
"3 passed, 0 failed, 1 skipped, 0 harness errors\n"));
assert(has(out.stdout,
"4 discovered, 4 selected, 4 started, 4 completed\n"));
let failav: []str = [driver("ww"), "test",
runtimepath("fail_test.ww")];
runcommand(root, "sf-fail", failav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 1);
assert(has(out.stdout, "assertion_failure ... FAIL (exit 1)\n"));
let multiav: []str = [driver("ww"), "test",
runtimepath("multiple_fail_test.ww")];
runcommand(root, "sf-multi", multiav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 1);
assert(has(out.stdout,
"0 passed, 2 failed, 0 skipped, 0 harness errors\n"));
let unmetav: []str = [driver("ww"), "test",
runtimepath("expected_abort_return_test.ww")];
runcommand(root, "sf-unmet", unmetav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 1);
assert(has(out.stdout,
"expected_abort_must_happen ... FAIL (expected abort)\n"));
let premav: []str = [driver("ww"), "test",
runtimepath("premature_exit_test.ww")];
runcommand(root, "sf-premature", premav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 1);
assert(has(out.stdout,
"clean_exit_without_completion ... HARNESS (incomplete result)\n"));
let sigav: []str = [driver("ww"), "test",
runtimepath("signal_test.ww")];
runcommand(root, "sf-signal", sigav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 1);
assert(has(out.stdout, "signal_is_not_exit ... FAIL (signal 15)\n"));
clean(root);
};
// The published test binary's OWN command surface: repeated glob args,
// -list (with and without a glob), and -timeout-ms. Only a direct
// invocation of the `-c` artifact proves these; every driver route
// parses its flags before the binary sees them.
@test fn published_binary_cli() void = {
let root: str = fresh();
let out: commandout;
let stem: str = strings.concat(root, "/rtsuccess");
let cav: []str = [driver("ww"), "test", "-c", "-o", stem,
runtimepath("success_test.ww")];
runcommand(root, "publish", cav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
let gav: []str = [stem, "alpha*", "delta*"];
runcommand(root, "globs", gav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(has(out.stdout, "alpha_pass ... ok\n"));
assert(has(out.stdout, "delta_pass ... ok\n"));
assert(has(out.stdout,
"2 passed, 0 failed, 0 skipped, 0 harness errors\n"));
assert(has(out.stdout,
"4 discovered, 2 selected, 2 started, 2 completed\n"));
let lav: []str = [stem, "-list"];
runcommand(root, "list", lav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(same(out.stdout,
"alpha_pass\nbeta_skip\ngamma_expected_abort\ndelta_pass\n"));
let lgav: []str = [stem, "-list", "gamma*"];
runcommand(root, "list-glob", lgav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(same(out.stdout, "gamma_expected_abort\n"));
let tav: []str = [stem, "-timeout-ms=50", "alpha*"];
runcommand(root, "cli-timeout", tav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(has(out.stdout,
"1 passed, 0 failed, 0 skipped, 0 harness errors\n"));
clean(root);
};
// Direct-binary timeout classification and descendant handling. The
// runcommand deadline bounds the no-hang claims: a runner waiting on a
// SIGTERM-blocking or process-group-escaped pipe writer would trip it.
@test fn direct_binary_timeout_and_descendants() void = {
let root: str = fresh();
let out: commandout;
let tstem: str = strings.concat(root, "/rttimeout");
let tcav: []str = [driver("ww"), "test", "-c", "-o", tstem,
runtimepath("timeout_test.ww")];
runcommand(root, "publish-timeout", tcav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
let trun: []str = [tstem, "-timeout-ms=50"];
runcommand(root, "run-timeout", trun,
(20i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 1);
assert(has(out.stdout, "hang_times_out ... FAIL(timeout)\n"));
let lstem: str = strings.concat(root, "/rtlinger");
let lcav: []str = [driver("ww"), "test", "-c", "-o", lstem,
runtimepath("lingering_descendant_test.ww")];
runcommand(root, "publish-linger", lcav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
let lrun: []str = [lstem, "-timeout-ms=250"];
runcommand(root, "run-linger", lrun,
(20i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(has(out.stdout,
"returning_test_clears_descendant ... ok\n"));
let estem: str = strings.concat(root, "/rtescaped");
let ecav: []str = [driver("ww"), "test", "-c", "-o", estem,
runtimepath("escaped_descendant_test.ww")];
runcommand(root, "publish-escaped", ecav,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
let erun: []str = [estem, "-timeout-ms=250"];
runcommand(root, "run-escaped", erun,
(20i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 0);
assert(has(out.stdout,
"escaped_writer_does_not_hold_runner ... ok\n"));
clean(root);
};