test: port the assert/abort run-stderr net to ww; retire 957_assert_builtin_run
The unowned remainder is the four run-stderr assertions — msg content for fail_msg/abort_msg, MANDATORY EMPTINESS for fail_nomsg/abort_bare (rt_abort(NULL,0) writes nothing) — which the fixture protocol cannot see (run exit only). The rows build the r957_* fixture sources in place via the cstage driver; byte-id extends the lowering to wwstage (the carrier's own argument). Owned legs cited, not duplicated: all eight exit rows by the r957_assert_*/r957_abort_* fixtures, the checker rejects by r957_assert_reject_*, byte-id by the test-data-byteid blanket.
This commit is contained in:
65
test/misc/abortmsg_test.ww
Normal file
65
test/misc/abortmsg_test.ww
Normal file
@@ -0,0 +1,65 @@
|
||||
package abortmsg_test;
|
||||
|
||||
// Run-STDERR content net for the #58 assert/abort builtins, ported
|
||||
// from the retired native carrier test/wcc/957_assert_builtin_run.c.
|
||||
// The eight exit-code rows and the checker rejects are owned verbatim
|
||||
// by the r957_* fixtures, and the w6c-vs-w6c_ww byte-id by the
|
||||
// test-data-byteid blanket; the fixture protocol checks run EXIT
|
||||
// only, so the run-stderr dimension — msg content for the msg forms,
|
||||
// MANDATORY EMPTINESS for the bare forms (rt_abort(NULL, 0) writes
|
||||
// nothing) — lives here. The four abort-shaped fixture sources are
|
||||
// built IN PLACE so fixture and probe can never drift; the cstage
|
||||
// driver suffices, byte-id extends the lowering to wwstage (the
|
||||
// carrier's own argument).
|
||||
|
||||
import os;
|
||||
import os.exec;
|
||||
import strings;
|
||||
import testenv;
|
||||
import time;
|
||||
|
||||
fn fail(label: str, why: str) void = {
|
||||
let m: str = strings.concat("abortmsg FAIL: ", label, " -- ", why,
|
||||
"\n");
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
assert(false);
|
||||
};
|
||||
|
||||
fn tmo() time.duration = {
|
||||
return (240i64 * (time.second: i64)): time.duration;
|
||||
};
|
||||
|
||||
// needle "" = run stderr must be EXACTLY empty.
|
||||
fn stderrrow(label: str, fixture: str, needle: str) void = {
|
||||
let src: str = strings.concat(testenv.repo(), "/test/wcc/data/",
|
||||
fixture, "/case.ww");
|
||||
let td: str = testenv.fresh();
|
||||
let co: testenv.commandout;
|
||||
let bav: []str = [testenv.driver("ww"), "build", "-o", "bin", src];
|
||||
testenv.runcommand(td, td, "build", bav, tmo(), &co);
|
||||
if (co.termination != exec.termination.EXIT || co.code != 0) {
|
||||
fail(label, "cstage build failed");
|
||||
};
|
||||
let rav: []str = [strings.concat(td, "/bin")];
|
||||
testenv.runcommand(td, td, "run", rav, tmo(), &co);
|
||||
if (co.termination != exec.termination.EXIT || co.code != 1) {
|
||||
fail(label, "run-exit != 1");
|
||||
};
|
||||
if (needle.len != 0) {
|
||||
if (!testenv.has(co.stderr, needle)) {
|
||||
fail(label, strings.concat("run stderr missing \"",
|
||||
needle, "\""));
|
||||
};
|
||||
} else if (co.stderr.len != 0) {
|
||||
fail(label, strings.concat("run stderr not empty ",
|
||||
"(rt_abort no-msg must be (NULL, 0))"));
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
@test fn abortstderr() void = {
|
||||
stderrrow("fail_nomsg", "r957_assert_fail_nomsg", "");
|
||||
stderrrow("fail_msg", "r957_assert_fail_msg", "assert fired");
|
||||
stderrrow("abort_msg", "r957_abort_msg", "boom");
|
||||
stderrrow("abort_bare", "r957_abort_bare", "");
|
||||
};
|
||||
Reference in New Issue
Block a user