test: flaky terminal channel exitcode check #39580

Problem:
The `nvim_get_chan_info()` terminal channel test used `shell-test INTERACT` to verify that `jobstop()` reports an unhandled `SIGHUP` as exit code `129`.

`INTERACT` reads from stdin with `fgets()`, so closing the PTY could race with `SIGHUP` delivery. If `fgets()` observed EOF first, `shell-test` exited normally with code `0`, causing intermittent failures on slower sanitizer builds.

Solution:
Add a `shell-test HOLD` mode that prints a readiness prompt and then waits without reading stdin. Use it for the `SIGHUP` assertion so PTY EOF cannot make the helper exit normally before the signal path is observed.
This commit is contained in:
David Balatero
2026-05-05 11:45:41 -04:00
committed by GitHub
parent 10b739aac1
commit 78111e5371
2 changed files with 15 additions and 2 deletions

View File

@@ -2977,9 +2977,10 @@ describe('API', function()
-- :terminal with args + stopped process (shell-test).
command('enew')
argv = { n.testprg('shell-test'), 'INTERACT' }
-- Use a process that doesn't read stdin, so PTY EOF can't race SIGHUP.
argv = { n.testprg('shell-test'), 'HOLD' }
fn.jobstart(argv, { term = true })
screen:expect({ any = { vim.pesc('interact $') } })
screen:expect({ any = { vim.pesc('holding $') } })
eq(1, eval('jobstop(&channel)'))
eval('jobwait([&channel], 1000)') -- Wait.
local expected3 = term_channel_info(5, 3, argv)