From cd23acb366c4205df9b4d7461630720ebcfd3778 Mon Sep 17 00:00:00 2001 From: NI0317 Date: Fri, 31 Jul 2026 10:25:02 +0800 Subject: [PATCH] test(tui): force-stop resumed PTY acceptance --- apps/cli/tests/pty-harness.ts | 6 ++++-- apps/cli/tests/tui-keyless-smoke.e2e.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/cli/tests/pty-harness.ts b/apps/cli/tests/pty-harness.ts index b8225a8f50..844de8cb0b 100644 --- a/apps/cli/tests/pty-harness.ts +++ b/apps/cli/tests/pty-harness.ts @@ -57,7 +57,7 @@ while time.monotonic() < deadline: os.write(fd, action["send"].encode()) if "signalAfterMs" in action: time.sleep(action["signalAfterMs"] / 1000) - os.kill(pid, signal.SIGTERM) + os.kill(pid, getattr(signal, action.get("signalAfter", "SIGTERM"))) action_index += 1 waited, candidate = os.waitpid(pid, os.WNOHANG) if waited == pid: @@ -86,6 +86,8 @@ type TuiPtyAction = readonly delayMs?: number /** Terminate the process this many milliseconds after sending input. */ readonly signalAfterMs?: number + /** Signal used by {@link signalAfterMs}; defaults to `SIGTERM`. */ + readonly signalAfter?: 'SIGTERM' | 'SIGKILL' } | { readonly waitFor: string; readonly occurrence?: number; readonly signal: 'SIGTERM'; readonly delayMs?: number } | { @@ -218,7 +220,7 @@ async function runWindowsPtySmoke( const send = (): void => { terminal.write(action.send) if (action.signalAfterMs !== undefined) { - setTimeout(() => { terminal.kill('SIGTERM') }, action.signalAfterMs) + setTimeout(() => { terminal.kill(action.signalAfter ?? 'SIGTERM') }, action.signalAfterMs) } } if (action.delayMs === undefined) send() diff --git a/apps/cli/tests/tui-keyless-smoke.e2e.ts b/apps/cli/tests/tui-keyless-smoke.e2e.ts index 12c018f255..a53c8941b2 100644 --- a/apps/cli/tests/tui-keyless-smoke.e2e.ts +++ b/apps/cli/tests/tui-keyless-smoke.e2e.ts @@ -223,11 +223,16 @@ describe('dsh TUI keyless smoke (real Loader tree in a PTY)', () => { tempDirPrefix: `dsh-tui-welcome-${String(columns)}-`, configPath: scriptedConfigPath, showFirstRunWelcome: true, - expectedExitCode: process.platform === 'win32' ? 0 : -15, + expectedExitCode: process.platform === 'win32' ? 0 : -9, columns, rows: 30, actions: [ - { waitFor: `Enter ${firstRunCopy.continueLabel}`, send: '\r', signalAfterMs: 2_000 }, + { + waitFor: `Enter ${firstRunCopy.continueLabel}`, + send: '\r', + signalAfterMs: 2_000, + signalAfter: 'SIGKILL', + }, ], inspect: async (cwd) => { expect(await hasTuiFirstRunWelcomeAcknowledgement(join(cwd, '.dsh'))).toBe(true)