mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-01 04:36:26 +00:00
test(server): wait for the shell prompt between terminal protocol helpers (#11357)
The three protocol-query tests typed the next helper command as soon as
the previous helper printed its OK line. That helper was still running,
so the shell printed its prompt and the typed-ahead command's output on
one row ("$ OSC_COLOR_OK:12:..."). The checks need the line to start
with, or equal, the OK text, so they waited until the 5 s timeout.
Each command now waits for the prompt before it is typed. A timeout
also prints the screen, so the next failure shows what it saw.
Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
74f629bee1
commit
41aceb042b
@@ -90,7 +90,10 @@ async function waitForState(
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
}
|
||||
|
||||
throw new Error("Timeout waiting for terminal state predicate to match");
|
||||
const lines = getLines(await readTerminalState(session)).filter((line) => line.length > 0);
|
||||
throw new Error(
|
||||
`Timeout waiting for terminal state predicate to match.\nScreen:\n${lines.join("\n")}`,
|
||||
);
|
||||
}
|
||||
|
||||
async function waitForTitle(
|
||||
@@ -359,6 +362,13 @@ function lastNonEmptyLineIsPrompt(state: TerminalState): boolean {
|
||||
return last === "$";
|
||||
}
|
||||
|
||||
// Type a command only once the shell shows its prompt. Typed ahead while the
|
||||
// previous helper still runs, its output lands on the prompt row ("$ OK:...").
|
||||
async function runAtPrompt(session: TerminalSession, command: string): Promise<void> {
|
||||
await waitForState(session, lastNonEmptyLineIsPrompt);
|
||||
session.send({ type: "input", data: `${command}\r` });
|
||||
}
|
||||
|
||||
function removeZshShellIntegrationRuntimeDir(): void {
|
||||
rmSync(join(tmpdir(), `${userInfo().username || "unknown"}-paseo-zsh-${process.pid}`), {
|
||||
recursive: true,
|
||||
@@ -1196,7 +1206,7 @@ describe.skipIf(isPlatform("win32"))("terminal POSIX-only", () => {
|
||||
);
|
||||
await waitForLines(session, ["$"]);
|
||||
|
||||
session.send({ type: "input", data: 'echo "CFGBG=$COLORFGBG"\r' });
|
||||
await runAtPrompt(session, 'echo "CFGBG=$COLORFGBG"');
|
||||
await waitForOutputLine(session, "CFGBG=0;15");
|
||||
|
||||
for (const [code, expected] of [
|
||||
@@ -1204,7 +1214,7 @@ describe.skipIf(isPlatform("win32"))("terminal POSIX-only", () => {
|
||||
[11, "rgb:abab/cdcd/efef"],
|
||||
[12, "rgb:4444/5555/6666"],
|
||||
] as const) {
|
||||
session.send({ type: "input", data: `${process.execPath} ${helperPath} ${code}\r` });
|
||||
await runAtPrompt(session, `${process.execPath} ${helperPath} ${code}`);
|
||||
await waitForState(session, (state) =>
|
||||
getLines(state).some((line) => line.startsWith(`OSC_COLOR_OK:${code}:`)),
|
||||
);
|
||||
@@ -1239,7 +1249,7 @@ describe.skipIf(isPlatform("win32"))("terminal POSIX-only", () => {
|
||||
[11, "rgb:1010/1d1d/2b2b"],
|
||||
[12, "rgb:3737/4949/5c5c"],
|
||||
] as const) {
|
||||
session.send({ type: "input", data: `${process.execPath} ${helperPath} ${code}\r` });
|
||||
await runAtPrompt(session, `${process.execPath} ${helperPath} ${code}`);
|
||||
await waitForState(session, (state) =>
|
||||
getLines(state).some((line) => line.startsWith(`OSC_COLOR_OK:${code}:`)),
|
||||
);
|
||||
@@ -1269,15 +1279,15 @@ describe.skipIf(isPlatform("win32"))("terminal POSIX-only", () => {
|
||||
await waitForLines(session, ["$"]);
|
||||
|
||||
// DSR 996 query reports light (2) initially
|
||||
session.send({ type: "input", data: `${process.execPath} ${schemeHelper} query\r` });
|
||||
await runAtPrompt(session, `${process.execPath} ${schemeHelper} query`);
|
||||
await waitForOutputLine(session, "SCHEME_QUERY_OK:2");
|
||||
|
||||
// DECRQM 2031 reports reset (2) before enabling and set (1) after enabling
|
||||
session.send({ type: "input", data: `${process.execPath} ${schemeHelper} decrqm\r` });
|
||||
await runAtPrompt(session, `${process.execPath} ${schemeHelper} decrqm`);
|
||||
await waitForOutputLine(session, "DECRQM_OK:2:1");
|
||||
|
||||
// Start mode 2031 watcher
|
||||
session.send({ type: "input", data: `${process.execPath} ${schemeHelper} watch\r` });
|
||||
await runAtPrompt(session, `${process.execPath} ${schemeHelper} watch`);
|
||||
await waitForOutputLine(session, "SCHEME_WATCH_READY");
|
||||
|
||||
// Same polarity update (another light palette) does NOT emit a 997 report
|
||||
@@ -1301,10 +1311,10 @@ describe.skipIf(isPlatform("win32"))("terminal POSIX-only", () => {
|
||||
await waitForOutputLine(session, "SCHEME_DONE:1,2");
|
||||
|
||||
// Subsequent OSC 11 and DSR 996 queries immediately reflect the updated dark palette
|
||||
session.send({ type: "input", data: `${process.execPath} ${oscHelper} 11\r` });
|
||||
await runAtPrompt(session, `${process.execPath} ${oscHelper} 11`);
|
||||
await waitForOutputLine(session, "OSC_COLOR_OK:11:ESC]11;rgb:1818/1b1b/1a1aESC\\");
|
||||
|
||||
session.send({ type: "input", data: `${process.execPath} ${schemeHelper} query\r` });
|
||||
await runAtPrompt(session, `${process.execPath} ${schemeHelper} query`);
|
||||
await waitForOutputLine(session, "SCHEME_QUERY_OK:1");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user