diff options
author | Gregory Anders <greg@gpanders.com> | 2021-09-04 15:28:08 -0600 |
---|---|---|
committer | Gregory Anders <greg@gpanders.com> | 2023-08-10 09:08:25 -0500 |
commit | 673ee213e9d0900b1fa2638dc5373ee8167ed4fa (patch) | |
tree | 94abb447f78f33d4367f5848444993074f23214f /test/functional/terminal/ex_terminal_spec.lua | |
parent | 0c89854da1893c9d9d5da1994bea69df31fc2a6f (diff) | |
download | rneovim-673ee213e9d0900b1fa2638dc5373ee8167ed4fa.tar.gz rneovim-673ee213e9d0900b1fa2638dc5373ee8167ed4fa.tar.bz2 rneovim-673ee213e9d0900b1fa2638dc5373ee8167ed4fa.zip |
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.
Diffstat (limited to 'test/functional/terminal/ex_terminal_spec.lua')
-rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 5204b61f57..6020a12ddb 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -137,23 +137,29 @@ describe(':terminal (with fake shell)', function() -- shell-test.c is a fake shell that prints its arguments and exits. nvim('set_option_value', 'shell', testprg('shell-test'), {}) nvim('set_option_value', 'shellcmdflag', 'EXE', {}) + nvim('set_option_value', 'shellxquote', '', {}) end) -- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints - -- the {cmd} and exits immediately . + -- the {cmd} and exits immediately. + -- When no argument is given and the exit code is zero, the terminal buffer + -- closes automatically. local function terminal_with_fake_shell(cmd) feed_command("terminal "..(cmd and cmd or "")) end it('with no argument, acts like termopen()', function() skip(is_os('win')) - terminal_with_fake_shell() + -- Use the EXIT subcommand to end the process with a non-zero exit code to + -- prevent the buffer from closing automatically + nvim('set_option_value', 'shellcmdflag', 'EXIT', {}) + terminal_with_fake_shell(1) retry(nil, 4 * screen.timeout, function() screen:expect([[ - ^ready $ | - [Process exited 0] | + ^ | + [Process exited 1] | | - :terminal | + :terminal 1 | ]]) end) end) @@ -245,12 +251,13 @@ describe(':terminal (with fake shell)', function() it('works with :find', function() skip(is_os('win')) - terminal_with_fake_shell() + nvim('set_option_value', 'shellcmdflag', 'EXIT', {}) + terminal_with_fake_shell(1) screen:expect([[ - ^ready $ | - [Process exited 0] | + ^ | + [Process exited 1] | | - :terminal | + :terminal 1 | ]]) eq('term://', string.match(eval('bufname("%")'), "^term://")) feed([[<C-\><C-N>]]) |