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())
|
os.write(fd, action["send"].encode())
|
||||||
if "signalAfterMs" in action:
|
if "signalAfterMs" in action:
|
||||||
time.sleep(action["signalAfterMs"] / 1000)
|
time.sleep(action["signalAfterMs"] / 1000)
|
||||||
os.kill(pid, signal.SIGTERM)
|
os.kill(pid, getattr(signal, action.get("signalAfter", "SIGTERM")))
|
||||||
action_index += 1
|
action_index += 1
|
||||||
waited, candidate = os.waitpid(pid, os.WNOHANG)
|
waited, candidate = os.waitpid(pid, os.WNOHANG)
|
||||||
if waited == pid:
|
if waited == pid:
|
||||||
@@ -86,6 +86,8 @@ type TuiPtyAction =
|
|||||||
readonly delayMs?: number
|
readonly delayMs?: number
|
||||||
/** Terminate the process this many milliseconds after sending input. */
|
/** Terminate the process this many milliseconds after sending input. */
|
||||||
readonly signalAfterMs?: number
|
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 }
|
| { readonly waitFor: string; readonly occurrence?: number; readonly signal: 'SIGTERM'; readonly delayMs?: number }
|
||||||
| {
|
| {
|
||||||
@@ -218,7 +220,7 @@ async function runWindowsPtySmoke(
|
|||||||
const send = (): void => {
|
const send = (): void => {
|
||||||
terminal.write(action.send)
|
terminal.write(action.send)
|
||||||
if (action.signalAfterMs !== undefined) {
|
if (action.signalAfterMs !== undefined) {
|
||||||
setTimeout(() => { terminal.kill('SIGTERM') }, action.signalAfterMs)
|
setTimeout(() => { terminal.kill(action.signalAfter ?? 'SIGTERM') }, action.signalAfterMs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (action.delayMs === undefined) send()
|
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)}-`,
|
tempDirPrefix: `dsh-tui-welcome-${String(columns)}-`,
|
||||||
configPath: scriptedConfigPath,
|
configPath: scriptedConfigPath,
|
||||||
showFirstRunWelcome: true,
|
showFirstRunWelcome: true,
|
||||||
expectedExitCode: process.platform === 'win32' ? 0 : -15,
|
expectedExitCode: process.platform === 'win32' ? 0 : -9,
|
||||||
columns,
|
columns,
|
||||||
rows: 30,
|
rows: 30,
|
||||||
actions: [
|
actions: [
|
||||||
{ waitFor: `Enter ${firstRunCopy.continueLabel}`, send: '\r', signalAfterMs: 2_000 },
|
{
|
||||||
|
waitFor: `Enter ${firstRunCopy.continueLabel}`,
|
||||||
|
send: '\r',
|
||||||
|
signalAfterMs: 2_000,
|
||||||
|
signalAfter: 'SIGKILL',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
inspect: async (cwd) => {
|
inspect: async (cwd) => {
|
||||||
expect(await hasTuiFirstRunWelcomeAcknowledgement(join(cwd, '.dsh'))).toBe(true)
|
expect(await hasTuiFirstRunWelcomeAcknowledgement(join(cwd, '.dsh'))).toBe(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user