test(desktop): verify PATH probe child kill on timeout

This commit is contained in:
yoniebans
2026-09-10 20:08:03 +02:00
parent f2b33fb4a2
commit 8762a08b67
+10 -4
View File
@@ -138,11 +138,16 @@ test('ensureLoginShellPath is single-flight — concurrent callers share one she
assert.equal(env.PATH, '/opt/homebrew/bin:/usr/bin')
})
test('applyLoginShellPath force-settles when a hung grandchild keeps the execFile callback from firing', async () => {
test('applyLoginShellPath kills the probe child and force-settles when its callback does not fire', async () => {
const env: any = { SHELL: '/bin/zsh', PATH: '/usr/bin' }
// Simulates a probe whose shell spawns a daemon (e.g. gitstatusd) that
// keeps stdout open: execFile's callback never fires.
const execFileFn = () => ({ pid: 424242, stdin: { end() {} } })
const kills: string[] = []
const execFileFn = () => ({
stdin: { end() {} },
kill(signal) {
kills.push(signal)
return true
}
})
const start = Date.now()
const result = await applyLoginShellPath({ env, platform: 'linux', execFileFn, timeoutMs: 20 })
@@ -150,6 +155,7 @@ test('applyLoginShellPath force-settles when a hung grandchild keeps the execFil
assert.equal(result.applied, false)
assert.equal(result.reason, 'unresolved')
assert.deepEqual(kills, ['SIGKILL', 'SIGKILL'])
assert.ok(elapsed < 4000, `expected the probe to force-settle well under the test timeout, took ${elapsed}ms`)
})