From 553b8c35da38e13cd664bfcee45135f319405a70 Mon Sep 17 00:00:00 2001 From: Chinesezjc Date: Tue, 25 Aug 2026 17:11:34 +0800 Subject: [PATCH] test(pwsh-local): accept graceful SIGTERM exit as service-disposal death On Linux, pwsh may trap SIGTERM and exit cleanly when the subprocess service is disposed, so the handle status is 'completed' rather than 'killed'. The test already proved the process tree is gone via kill(pid,0); both statuses satisfy the contract. --- .../shell/pwsh-local/tests/executor.spec.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/shell/pwsh-local/tests/executor.spec.ts b/packages/shell/pwsh-local/tests/executor.spec.ts index e26211b268..53047a62c8 100644 --- a/packages/shell/pwsh-local/tests/executor.spec.ts +++ b/packages/shell/pwsh-local/tests/executor.spec.ts @@ -471,10 +471,12 @@ describe.skipIf(!hasPwsh)('process lifecycle ownership (the subprocess service, await managerFiber.dispose() expect(() => process.kill(pid, 0)).toThrow() await proc.done - // POSIX reports the kill as a signal; Windows reports a forced - // termination as exit 1 with no signal (indistinguishable from a crash), - // so the status stamp follows the platform's exit facts. - expect(proc.status).toBe(process.platform === 'win32' ? 'completed' : 'killed') + // Service disposal confirmed the tree is gone (kill(pid,0) throws above). + // On POSIX the stamp depends on whether the shell traps SIGTERM and exits + // cleanly (completed) or is killed by the signal (killed); Windows forced + // termination (taskkill, no signals) also stamps completed. Both mean the + // process no longer survives the service. + expect(['killed', 'completed']).toContain(proc.status) }) it('service disposal settles running handles and leaves settled ones untouched', async () => { @@ -493,6 +495,11 @@ describe.skipIf(!hasPwsh)('process lifecycle ownership (the subprocess service, // A settled process was untouched; the live one was terminated and joined. expect(finished.status).toBe('completed') await running.done - expect(running.status).toBe(process.platform === 'win32' ? 'completed' : 'killed') + // The live handle was terminated and joined; on POSIX the stamp depends + // on whether the shell traps SIGTERM and exits cleanly (completed) or is + // killed by the signal (killed); Windows forced termination (taskkill, no + // signals) also stamps completed. Both mean the process no longer + // survives the service. + expect(['killed', 'completed']).toContain(running.status) }) })