fix(scripts): make the test stubs drain, and the raw-mode guard testable (#2147)
Copilot review round 5 — four findings, all in the suppressed block.
1+4. The regression stubs did `console.log(MARKER); process.exit(1)`.
Writing to a PIPE is asynchronous and `process.exit()` tears the
process down without draining, so the marker can be lost outright —
and then the stub that pins the paint-then-die path fails as "exited
before rendering", the neighbouring branch and the wrong diagnostic
for the thing it guards.
Worth recording that I met this mechanism last round and did not join
the dots: probing the drain race, a 4MB write followed by
`process.exit()` reached the parent with the marker missing
entirely. That was noted as a reason the repro failed, while the same
construct stayed in the stubs. Both now set `process.exitCode` and
let the loop drain — still exiting immediately after the write — with
a comment, since `process.exit()` is the more obvious spelling and
will read as a simplification to the next person. Same fix for the
`console.error("boom")` stub, whose assertion had the same exposure.
2. DEFAULTS claimed "every one is a hard floor as well as a default",
which contradicts `normalizeMs` (any finite positive value passes)
and the suite two files over, which passes 400ms against a 2000ms
default. It rejects the shape a bad env var produces, not smallness.
3. The raw-mode forbidden-output check was unreachable from any test:
the real PTY happy path only exercises the pattern NOT matching, so
a regression breaking it would stay green forever — an
acceptance-criterion guard with nothing guarding it, which is the
recursive form of this PR's own complaint.
Now a `runRenderSmoke` option (`forbidOutput`), so it runs inside the
tested state machine and against the fully drained output.
`smoke:tui` passes its pattern in and drops the post-hoc check. It
can only turn a pass into a failure, never rewrite an existing
failure's message: a crash reason is more useful than "and it also
printed X", which is usually a symptom of that crash. Three tests —
matching, not matching, and that asymmetry.
Verified: test:scripts 213/213; `smoke:tui OK — rendered "MCP Servers" at
360ms and was still running 2000ms later`; and the no-PTY shim still
fails through the refactored path.
Signed-off-by: Cliff Hall <cliff@futurescale.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
4af38c719c
commit
e15dd8abee
1 changed files with 103 additions and 19 deletions
|
|
@ -152,6 +152,16 @@ try {
|
|||
USERPROFILE: work,
|
||||
},
|
||||
},
|
||||
// Belt and braces for the acceptance criterion this fix is measured
|
||||
// against. Survival already implies it today, since the raw-mode throw is
|
||||
// fatal — but if Ink ever degrades it to a warning, a TUI with no keyboard
|
||||
// input would survive happily, and this smoke is the only thing watching.
|
||||
forbidOutput: {
|
||||
pattern: RAW_MODE_ERROR,
|
||||
reason:
|
||||
`TUI rendered and survived, but still logged the raw-mode error — ` +
|
||||
`the pseudoterminal did not take effect (flavor: ${pty.flavor})`,
|
||||
},
|
||||
warn: (m) => console.warn(m.replace(/^render-smoke/, "smoke:tui")),
|
||||
});
|
||||
} finally {
|
||||
|
|
@ -163,17 +173,6 @@ try {
|
|||
removeSafe(work, { label: "smoke:tui" });
|
||||
}
|
||||
|
||||
// Belt and braces for the acceptance criterion this fix is measured against.
|
||||
// Survival already implies it today, since the raw-mode throw is fatal — but
|
||||
// if Ink ever degrades to a warning instead, a TUI with no keyboard input would
|
||||
// otherwise pass silently, and this smoke is the only thing watching.
|
||||
if (result.code === 0 && RAW_MODE_ERROR.test(result.output)) {
|
||||
fail(
|
||||
`TUI rendered and survived, but still logged the raw-mode error — the ` +
|
||||
`pseudoterminal did not take effect (flavor: ${pty.flavor})`,
|
||||
);
|
||||
}
|
||||
|
||||
if (result.code === 0) {
|
||||
console.log(`smoke:tui OK — ${result.message}`);
|
||||
process.exit(0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue