test(tui): force-stop resumed PTY acceptance
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user