From aa840ab5668aa9bc013461a48da771f778b39e49 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 1 Mar 2023 09:56:25 +0800 Subject: test(termxx_spec): fix TermClose bdelete test flakiness (#22463) Problem: If shell-test finishes before the next RPC call, TermClose has already been triggered, so the test fails. Solution: Add INTERACT argument so that shell-test keeps running. --- test/functional/autocmd/termxx_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/autocmd/termxx_spec.lua') diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index 0a33f1b2ac..63b5617eef 100644 --- a/test/functional/autocmd/termxx_spec.lua +++ b/test/functional/autocmd/termxx_spec.lua @@ -22,6 +22,8 @@ describe('autocmd TermClose', function() local function test_termclose_delete_own_buf() + -- The terminal process needs to keep running so that TermClose isn't triggered immediately. + nvim('set_option', '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://', -- cgit From 9d574f8dd7248a4cf8dcbe615f3058d34efb7ac3 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Mar 2023 22:56:16 +0100 Subject: ci: bump to windows 2022 Skip failing funcitonaltests. Use jobstart() instead termopen() for oldtests to prevent CI freezing. --- test/functional/autocmd/termxx_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/autocmd/termxx_spec.lua') diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index 63b5617eef..a9980dda04 100644 --- a/test/functional/autocmd/termxx_spec.lua +++ b/test/functional/autocmd/termxx_spec.lua @@ -50,6 +50,7 @@ describe('autocmd TermClose', function() end) it('triggers when long-running terminal job gets stopped', function() + skip(is_os('win')) nvim('set_option', 'shell', is_os('win') and 'cmd.exe' or 'sh') command('autocmd TermClose * let g:test_termclose = 23') command('terminal') -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- test/functional/autocmd/termxx_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/functional/autocmd/termxx_spec.lua') diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index a9980dda04..9ec1469c03 100644 --- a/test/functional/autocmd/termxx_spec.lua +++ b/test/functional/autocmd/termxx_spec.lua @@ -16,14 +16,14 @@ 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', 'shell', string.format('"%s" INTERACT', testprg('shell-test'))) + 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://', @@ -51,7 +51,7 @@ describe('autocmd TermClose', function() it('triggers when long-running terminal job gets stopped', function() skip(is_os('win')) - nvim('set_option', 'shell', is_os('win') and 'cmd.exe' or 'sh') + 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)') @@ -60,8 +60,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')}}) ]]) @@ -80,8 +80,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')}, ]] -- cgit From f0d618667a8a460b2c6135da19c74f0a4ad52128 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Jul 2023 08:53:59 +0800 Subject: test: check that TextChangedT cannot delete terminal buffer (#24437) --- test/functional/autocmd/termxx_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/functional/autocmd/termxx_spec.lua') diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index 9ec1469c03..359203f945 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 @@ -162,3 +164,21 @@ it('autocmd TermEnter, TermLeave', function() }, 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('') | 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) -- cgit From 673ee213e9d0900b1fa2638dc5373ee8167ed4fa Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Sat, 4 Sep 2021 15:28:08 -0600 Subject: test: update tests for auto-closing :term buffers The terminal buffer closes automatically when using `:terminal` and the command exits without an error. This messes up some tests that expect the terminal buffer to still be open. We can force the buffer not to close by passing an argument to `:terminal`. This can be anything, since the shell-test stub simply prints whatever argument it's given. --- test/functional/autocmd/termxx_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/functional/autocmd/termxx_spec.lua') diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index 359203f945..802020494b 100644 --- a/test/functional/autocmd/termxx_spec.lua +++ b/test/functional/autocmd/termxx_spec.lua @@ -103,12 +103,13 @@ describe('autocmd TermClose', function() it('reports the correct ', function() command('set hidden') + command('set shellcmdflag=EXE') command('autocmd TermClose * let g:abuf = expand("")') 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') -- cgit From bbc74d51ad791edad1948178736589cb181236e8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 18 Oct 2023 07:19:29 +0800 Subject: test(autocmd/termxx_spec): fix flakiness (#25694) --- test/functional/autocmd/termxx_spec.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'test/functional/autocmd/termxx_spec.lua') diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index 802020494b..2522a28a9d 100644 --- a/test/functional/autocmd/termxx_spec.lua +++ b/test/functional/autocmd/termxx_spec.lua @@ -149,21 +149,21 @@ it('autocmd TermEnter, TermLeave', function() -- TermLeave is also triggered by :quit. command('split foo') + feed('') -- 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('') -- 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() -- cgit From 684e93054b82c6b5b215db7d3ecbad803eb81f0e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 25 Oct 2023 09:59:02 +0800 Subject: fix(terminal): assign channel to terminal earlier (#25771) --- test/functional/autocmd/termxx_spec.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'test/functional/autocmd/termxx_spec.lua') diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua index 2522a28a9d..332a936e3f 100644 --- a/test/functional/autocmd/termxx_spec.lua +++ b/test/functional/autocmd/termxx_spec.lua @@ -22,7 +22,6 @@ describe('autocmd TermClose', function() 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')), {}) -- cgit