Sfoglia il codice sorgente

test(tui): force-stop resumed PTY acceptance

NI0317 1 mese fa
parent
commit
cd23acb366
2 ha cambiato i file con 11 aggiunte e 4 eliminazioni
  1. 4 2
      apps/cli/tests/pty-harness.ts
  2. 7 2
      apps/cli/tests/tui-keyless-smoke.e2e.ts

+ 4 - 2
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()

+ 7 - 2
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)