aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/channel_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2021-11-12 10:27:11 +0800
committerzeertzjq <zeertzjq@outlook.com>2021-11-15 10:34:43 +0800
commitbd15ff7b84bc4eb65ca33f8649cb470e2eaeebcb (patch)
tree65e8f538d315c5d9f89380c5730caace7f6eee56 /test/functional/terminal/channel_spec.lua
parent8f984dc1f29aa6ce41f233b983453bfd795e8238 (diff)
downloadrneovim-bd15ff7b84bc4eb65ca33f8649cb470e2eaeebcb.tar.gz
rneovim-bd15ff7b84bc4eb65ca33f8649cb470e2eaeebcb.tar.bz2
rneovim-bd15ff7b84bc4eb65ca33f8649cb470e2eaeebcb.zip
test: require fewest number of main loop iterations possible
Change exc_exec to pcall_err to reduce one main loop iteration. No need to call poke_eventloop() unless after nvim_input().
Diffstat (limited to 'test/functional/terminal/channel_spec.lua')
-rw-r--r--test/functional/terminal/channel_spec.lua28
1 files changed, 12 insertions, 16 deletions
diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua
index 7d37dcccc8..7223f5ba61 100644
--- a/test/functional/terminal/channel_spec.lua
+++ b/test/functional/terminal/channel_spec.lua
@@ -2,7 +2,7 @@ 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 pcall_err = helpers.pcall_err
local feed = helpers.feed
local sleep = helpers.sleep
local poke_eventloop = helpers.poke_eventloop
@@ -13,24 +13,22 @@ describe('associated channel is closed and later freed for terminal', function()
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')]]))
+ eq("Vim(call):Can't send data to closed stream", pcall_err(command, [[bdelete! | call chansend(id, 'test')]]))
+ -- channel has been freed after one main loop iteration
+ eq("Vim(call):E900: Invalid channel id", pcall_err(command, [[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')]]))
+ eq("Vim(call):Can't send data to closed stream", pcall_err(command, [[call chansend(id, 'test')]]))
-- delete terminal
feed('i<CR>')
- -- process term_delayed_free and free_channel_event
+ -- need to first process input
poke_eventloop()
- -- channel has been freed
- eq("Vim(call):E900: Invalid channel id", exc_exec([[call chansend(id, 'test')]]))
+ -- channel has been freed after another main loop iteration
+ eq("Vim(call):E900: Invalid channel id", pcall_err(command, [[call chansend(id, 'test')]]))
end)
-- This indirectly covers #16264
@@ -38,12 +36,10 @@ describe('associated channel is closed and later freed for terminal', 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')]]))
+ eq("Vim(call):Can't send data to closed stream", pcall_err(command, [[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')]]))
+ eq("Vim(call):Can't send data to closed stream", pcall_err(command, [[bdelete | call chansend(id, 'test')]]))
+ -- channel has been freed after one main loop iteration
+ eq("Vim(call):E900: Invalid channel id", pcall_err(command, [[call chansend(id, 'test')]]))
end)
end)