diff options
author | ZyX <kp-pav@yandex.ru> | 2017-07-15 18:56:45 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-07-15 18:56:45 +0300 |
commit | 69719e658c48bb5e95a7b57d5813ed4dc48e68e3 (patch) | |
tree | c4f8584a7437ea6127389b26ff6876404cb58ce7 /test/functional/autocmd/termclose_spec.lua | |
parent | 7ab152aaa58f493e54d03a15960b8a288196e588 (diff) | |
parent | 8898793adeb3a82fe50da4258c30940e10ebcc9d (diff) | |
download | rneovim-69719e658c48bb5e95a7b57d5813ed4dc48e68e3.tar.gz rneovim-69719e658c48bb5e95a7b57d5813ed4dc48e68e3.tar.bz2 rneovim-69719e658c48bb5e95a7b57d5813ed4dc48e68e3.zip |
Merge branch 'master' into colored-cmdline
Diffstat (limited to 'test/functional/autocmd/termclose_spec.lua')
-rw-r--r-- | test/functional/autocmd/termclose_spec.lua | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/test/functional/autocmd/termclose_spec.lua b/test/functional/autocmd/termclose_spec.lua index d4beab22e4..8cc49c0d4c 100644 --- a/test/functional/autocmd/termclose_spec.lua +++ b/test/functional/autocmd/termclose_spec.lua @@ -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>")') |