aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/ex_terminal_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-10-12 08:45:30 +0200
committerGitHub <noreply@github.com>2016-10-12 08:45:30 +0200
commit0190b9fb92bf81e99db0a4b5d6888b4f7eaadeb0 (patch)
tree7f5cf775fed6d67a9e263d71e8e7dbd190305216 /test/functional/terminal/ex_terminal_spec.lua
parent1dde512498d2fa9f3427861b5d4f894c778f992b (diff)
parentb182f247ecf5d49558aae165ba248e2240d3a5d7 (diff)
downloadrneovim-0190b9fb92bf81e99db0a4b5d6888b4f7eaadeb0.tar.gz
rneovim-0190b9fb92bf81e99db0a4b5d6888b4f7eaadeb0.tar.bz2
rneovim-0190b9fb92bf81e99db0a4b5d6888b4f7eaadeb0.zip
Merge #5463 from justinmk/te-skip-writes
term_write(): Skip writes if stream was closed.
Diffstat (limited to 'test/functional/terminal/ex_terminal_spec.lua')
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 6f929f17e4..09b4eaa8d5 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -13,13 +13,19 @@ describe(':terminal', function()
clear()
screen = Screen.new(50, 4)
screen:attach({rgb=false})
+ -- shell-test.c is a fake shell that prints its arguments and exits.
nvim('set_option', 'shell', nvim_dir..'/shell-test')
nvim('set_option', 'shellcmdflag', 'EXE')
-
end)
+ -- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints
+ -- the {cmd} and exits immediately .
+ local function terminal_run_fake_shell_cmd(cmd)
+ execute("terminal "..(cmd and cmd or ""))
+ end
+
it('with no argument, acts like termopen()', function()
- execute('terminal')
+ terminal_run_fake_shell_cmd()
wait()
screen:expect([[
ready $ |
@@ -30,7 +36,7 @@ describe(':terminal', function()
end)
it('executes a given command through the shell', function()
- execute('terminal echo hi')
+ terminal_run_fake_shell_cmd('echo hi')
wait()
screen:expect([[
ready $ echo hi |
@@ -41,7 +47,7 @@ describe(':terminal', function()
end)
it('allows quotes and slashes', function()
- execute([[terminal echo 'hello' \ "world"]])
+ terminal_run_fake_shell_cmd([[echo 'hello' \ "world"]])
wait()
screen:expect([[
ready $ echo 'hello' \ "world" |
@@ -58,4 +64,16 @@ describe(':terminal', function()
-- Verify that BufNew actually fired (else the test is invalid).
eq('foo', eval('&shell'))
end)
+
+ it('ignores writes if the backing stream closes', function()
+ terminal_run_fake_shell_cmd()
+ helpers.feed('iiXXXXXXX')
+ wait()
+ -- Race: Though the shell exited (and streams were closed by SIGCHLD
+ -- handler), :terminal cleanup is pending on the main-loop.
+ -- This write should be ignored (not crash, #5445).
+ helpers.feed('iiYYYYYYY')
+ wait()
+ end)
+
end)