aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd/termxx_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
commit1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch)
treecd08258054db80bb9a11b1061bb091c70b76926a /test/functional/autocmd/termxx_spec.lua
parenteaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-aucmd_textputpost.tar.gz
rneovim-aucmd_textputpost.tar.bz2
rneovim-aucmd_textputpost.zip
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'test/functional/autocmd/termxx_spec.lua')
-rw-r--r--test/functional/autocmd/termxx_spec.lua63
1 files changed, 43 insertions, 20 deletions
diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua
index 0a33f1b2ac..332a936e3f 100644
--- a/test/functional/autocmd/termxx_spec.lua
+++ b/test/functional/autocmd/termxx_spec.lua
@@ -1,5 +1,6 @@
local luv = require('luv')
local helpers = require('test.functional.helpers')(after_each)
+local thelpers = require('test.functional.terminal.helpers')
local clear, command, nvim, testprg =
helpers.clear, helpers.command, helpers.nvim, helpers.testprg
@@ -8,6 +9,7 @@ local eval, eq, neq, retry =
local matches = helpers.matches
local ok = helpers.ok
local feed = helpers.feed
+local meths = helpers.meths
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
local skip = helpers.skip
@@ -16,12 +18,13 @@ local is_os = helpers.is_os
describe('autocmd TermClose', function()
before_each(function()
clear()
- nvim('set_option', 'shell', testprg('shell-test'))
+ nvim('set_option_value', 'shell', testprg('shell-test'), {})
command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=')
end)
-
local function test_termclose_delete_own_buf()
+ -- The terminal process needs to keep running so that TermClose isn't triggered immediately.
+ nvim('set_option_value', 'shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
command('autocmd TermClose * bdelete!')
command('terminal')
matches('^TermClose Autocommands for "%*": Vim%(bdelete%):E937: Attempt to delete a buffer that is in use: term://',
@@ -48,7 +51,8 @@ describe('autocmd TermClose', function()
end)
it('triggers when long-running terminal job gets stopped', function()
- nvim('set_option', 'shell', is_os('win') and 'cmd.exe' or 'sh')
+ skip(is_os('win'))
+ nvim('set_option_value', 'shell', is_os('win') and 'cmd.exe' or 'sh', {})
command('autocmd TermClose * let g:test_termclose = 23')
command('terminal')
command('call jobstop(b:terminal_job_id)')
@@ -57,8 +61,8 @@ describe('autocmd TermClose', function()
it('kills job trapping SIGTERM', function()
skip(is_os('win'))
- nvim('set_option', 'shell', 'sh')
- nvim('set_option', 'shellcmdflag', '-c')
+ nvim('set_option_value', 'shell', 'sh', {})
+ nvim('set_option_value', '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')}}) ]])
@@ -77,8 +81,8 @@ describe('autocmd TermClose', function()
it('kills PTY job trapping SIGHUP and SIGTERM', function()
skip(is_os('win'))
- nvim('set_option', 'shell', 'sh')
- nvim('set_option', 'shellcmdflag', '-c')
+ nvim('set_option_value', 'shell', 'sh', {})
+ nvim('set_option_value', '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')}, ]]
@@ -98,12 +102,13 @@ describe('autocmd TermClose', function()
it('reports the correct <abuf>', function()
command('set hidden')
+ command('set shellcmdflag=EXE')
command('autocmd TermClose * let g:abuf = expand("<abuf>")')
command('edit foo')
command('edit bar')
eq(2, eval('bufnr("%")'))
- command('terminal')
+ command('terminal ls')
retry(nil, nil, function() eq(3, eval('bufnr("%")')) end)
command('buffer 1')
@@ -143,19 +148,37 @@ it('autocmd TermEnter, TermLeave', function()
-- TermLeave is also triggered by :quit.
command('split foo')
+ feed('<Ignore>') -- Add input to separate two RPC requests
command('wincmd w')
feed('i')
command('q!')
- eq(
- {
- {'TermOpen', 'n'},
- {'TermEnter', 't'},
- {'TermLeave', 'n'},
- {'TermEnter', 't'},
- {'TermLeave', 'n'},
- {'TermEnter', 't'},
- {'TermClose', 't'},
- {'TermLeave', 'n'},
- },
- eval('g:evs'))
+ feed('<Ignore>') -- Add input to separate two RPC requests
+ eq({
+ {'TermOpen', 'n'},
+ {'TermEnter', 't'},
+ {'TermLeave', 'n'},
+ {'TermEnter', 't'},
+ {'TermLeave', 'n'},
+ {'TermEnter', 't'},
+ {'TermClose', 't'},
+ {'TermLeave', 'n'},
+ }, eval('g:evs'))
+end)
+
+describe('autocmd TextChangedT', function()
+ clear()
+ local screen = thelpers.screen_setup()
+
+ it('works', function()
+ command('autocmd TextChangedT * ++once let g:called = 1')
+ thelpers.feed_data('a')
+ retry(nil, nil, function() eq(1, meths.get_var('called')) end)
+ end)
+
+ it('cannot delete terminal buffer', function()
+ command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]])
+ thelpers.feed_data('a')
+ screen:expect({any = 'E937: '})
+ matches('^E937: Attempt to delete a buffer that is in use: term://', meths.get_vvar('errmsg'))
+ end)
end)