aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/terminal')
-rw-r--r--test/functional/terminal/channel_spec.lua49
-rw-r--r--test/functional/terminal/tui_spec.lua14
2 files changed, 59 insertions, 4 deletions
diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua
new file mode 100644
index 0000000000..7d37dcccc8
--- /dev/null
+++ b/test/functional/terminal/channel_spec.lua
@@ -0,0 +1,49 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear = helpers.clear
+local eq = helpers.eq
+local command = helpers.command
+local exc_exec = helpers.exc_exec
+local feed = helpers.feed
+local sleep = helpers.sleep
+local poke_eventloop = helpers.poke_eventloop
+
+describe('associated channel is closed and later freed for terminal', function()
+ before_each(clear)
+
+ it('opened by nvim_open_term() and deleted by :bdelete!', function()
+ command([[let id = nvim_open_term(0, {})]])
+ -- channel hasn't been freed yet
+ eq("Vim(call):Can't send data to closed stream", exc_exec([[bdelete! | call chansend(id, 'test')]]))
+ -- process free_channel_event
+ poke_eventloop()
+ -- channel has been freed
+ eq("Vim(call):E900: Invalid channel id", exc_exec([[call chansend(id, 'test')]]))
+ end)
+
+ it('opened by termopen(), exited, and deleted by pressing a key', function()
+ command([[let id = termopen('echo')]])
+ sleep(500)
+ -- process has exited
+ eq("Vim(call):Can't send data to closed stream", exc_exec([[call chansend(id, 'test')]]))
+ -- delete terminal
+ feed('i<CR>')
+ -- process term_delayed_free and free_channel_event
+ poke_eventloop()
+ -- channel has been freed
+ eq("Vim(call):E900: Invalid channel id", exc_exec([[call chansend(id, 'test')]]))
+ end)
+
+ -- This indirectly covers #16264
+ it('opened by termopen(), exited, and deleted by :bdelete', function()
+ command([[let id = termopen('echo')]])
+ sleep(500)
+ -- process has exited
+ eq("Vim(call):Can't send data to closed stream", exc_exec([[call chansend(id, 'test')]]))
+ -- channel hasn't been freed yet
+ eq("Vim(call):Can't send data to closed stream", exc_exec([[bdelete | call chansend(id, 'test')]]))
+ -- process term_delayed_free and free_channel_event
+ poke_eventloop()
+ -- channel has been freed
+ eq("Vim(call):E900: Invalid channel id", exc_exec([[call chansend(id, 'test')]]))
+ end)
+end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index f7520b14d4..6b9586b4de 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -494,6 +494,8 @@ describe('TUI', function()
it('paste: recovers from vim.paste() failure', function()
child_session:request('nvim_exec_lua', [[
_G.save_paste_fn = vim.paste
+ -- Stack traces for this test are non-deterministic, so disable them
+ _G.debug.traceback = function(msg) return msg end
vim.paste = function(lines, phase) error("fake fail") end
]], {})
-- Prepare something for dot-repeat/redo.
@@ -514,7 +516,7 @@ describe('TUI', function()
foo |
|
{5: }|
- {8:paste: Error executing lua: [string "<nvim>"]:2: f}|
+ {8:paste: Error executing lua: [string "<nvim>"]:4: f}|
{8:ake fail} |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
@@ -579,12 +581,16 @@ describe('TUI', function()
it("paste: 'nomodifiable' buffer", function()
child_session:request('nvim_command', 'set nomodifiable')
+ child_session:request('nvim_exec_lua', [[
+ -- Stack traces for this test are non-deterministic, so disable them
+ _G.debug.traceback = function(msg) return msg end
+ ]], {})
feed_data('\027[200~fail 1\nfail 2\n\027[201~')
screen:expect{grid=[[
|
{4:~ }|
{5: }|
- {MATCH:paste: Error executing lua: vim.lua:%d+: Vim:E21: }|
+ {8:paste: Error executing lua: vim.lua:243: Vim:E21: }|
{8:Cannot make changes, 'modifiable' is off} |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
@@ -671,8 +677,8 @@ describe('TUI', function()
item 2997 |
item 2998 |
item 2999 |
- item 3000 en{1:d}d |
- {5:[No Name] [+] 5999,13 Bot}|
+ item 3000 en{1:d} |
+ {5:[No Name] [+] 3000,13 Bot}|
|
{3:-- TERMINAL --} |
]])