mirror of
https://github.com/neovim/neovim.git
synced 2026-04-26 17:24:18 +00:00
Merge pull request #6823 from blueyed/fix-term-stop
fix SIGTERM/SIGHUP for jobs
This commit is contained in:
@@ -14,13 +14,52 @@ describe('TermClose event', function()
|
||||
nvim('set_option', 'shellcmdflag', 'EXE')
|
||||
end)
|
||||
|
||||
it('triggers when terminal job ends', function()
|
||||
it('triggers when fast-exiting terminal job stops', function()
|
||||
command('autocmd TermClose * let g:test_termclose = 23')
|
||||
command('terminal')
|
||||
command('call jobstop(b:terminal_job_id)')
|
||||
retry(nil, nil, function() eq(23, eval('g:test_termclose')) end)
|
||||
end)
|
||||
|
||||
it('triggers when long-running terminal job gets stopped', function()
|
||||
nvim('set_option', 'shell', 'sh')
|
||||
command('autocmd TermClose * let g:test_termclose = 23')
|
||||
command('terminal')
|
||||
command('call jobstop(b:terminal_job_id)')
|
||||
retry(nil, nil, function() eq(23, eval('g:test_termclose')) end)
|
||||
end)
|
||||
|
||||
it('kills job trapping SIGTERM', function()
|
||||
nvim('set_option', 'shell', 'sh')
|
||||
nvim('set_option', 'shellcmdflag', '-c')
|
||||
command([[ let g:test_job = jobstart('trap "" TERM && echo 1 && sleep 60', { ]]
|
||||
.. [[ 'on_stdout': {-> execute('let g:test_job_started = 1')}, ]]
|
||||
.. [[ 'on_exit': {-> execute('let g:test_job_exited = 1')}}) ]])
|
||||
retry(nil, nil, function() eq(1, eval('get(g:, "test_job_started", 0)')) end)
|
||||
|
||||
local start = os.time()
|
||||
command('call jobstop(g:test_job)')
|
||||
retry(nil, nil, function() eq(1, eval('get(g:, "test_job_exited", 0)')) end)
|
||||
local duration = os.time() - start
|
||||
eq(2, duration)
|
||||
end)
|
||||
|
||||
it('kills pty job trapping SIGHUP and SIGTERM', function()
|
||||
nvim('set_option', 'shell', 'sh')
|
||||
nvim('set_option', 'shellcmdflag', '-c')
|
||||
command([[ let g:test_job = jobstart('trap "" HUP TERM && echo 1 && sleep 60', { ]]
|
||||
.. [[ 'pty': 1,]]
|
||||
.. [[ 'on_stdout': {-> execute('let g:test_job_started = 1')}, ]]
|
||||
.. [[ 'on_exit': {-> execute('let g:test_job_exited = 1')}}) ]])
|
||||
retry(nil, nil, function() eq(1, eval('get(g:, "test_job_started", 0)')) end)
|
||||
|
||||
local start = os.time()
|
||||
command('call jobstop(g:test_job)')
|
||||
retry(nil, nil, function() eq(1, eval('get(g:, "test_job_exited", 0)')) end)
|
||||
local duration = os.time() - start
|
||||
eq(4, duration)
|
||||
end)
|
||||
|
||||
it('reports the correct <abuf>', function()
|
||||
command('set hidden')
|
||||
command('autocmd TermClose * let g:abuf = expand("<abuf>")')
|
||||
|
||||
Reference in New Issue
Block a user