diff options
author | erw7 <erw7.github@gmail.com> | 2021-11-12 00:07:03 +0900 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-03-12 19:23:45 +0800 |
commit | 5051510ade5f171c1239906c8638e804356186fe (patch) | |
tree | 43ce21d99a58a7c77baf6f98d0c5234070db93e4 /test/functional | |
parent | ab456bc304965d83585cd248284cb36c96927457 (diff) | |
download | rneovim-5051510ade5f171c1239906c8638e804356186fe.tar.gz rneovim-5051510ade5f171c1239906c8638e804356186fe.tar.bz2 rneovim-5051510ade5f171c1239906c8638e804356186fe.zip |
fix(channel): fix channel consistency
- Fix the problem that chanclose() does not work for channel created by
nvim_open_term().
- Fix the problem that the loopback channel is not released.
- Fix the error message when sending raw data to the loopback channel.
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/core/channels_spec.lua | 21 | ||||
-rw-r--r-- | test/functional/terminal/channel_spec.lua | 10 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua index c28300f0f4..ca52404d3b 100644 --- a/test/functional/core/channels_spec.lua +++ b/test/functional/core/channels_spec.lua @@ -10,6 +10,8 @@ local nvim_prog = helpers.nvim_prog local is_os = helpers.is_os local retry = helpers.retry local expect_twostreams = helpers.expect_twostreams +local assert_alive = helpers.assert_alive +local pcall_err = helpers.pcall_err describe('channels', function() local init = [[ @@ -314,3 +316,22 @@ describe('channels', function() eq({"notification", "exit", {id, 1, {''}}}, next_msg()) end) end) + +describe('loopback', function() + before_each(function() + clear() + command("let chan = sockconnect('pipe', v:servername, {'rpc': v:true})") + end) + + it('does not crash when sending raw data', function() + eq("Vim(call):Can't send raw data to rpc channel", + pcall_err(command, "call chansend(chan, 'test')")) + assert_alive() + end) + + it('are released when closed', function() + local chans = eval('len(nvim_list_chans())') + command('call chanclose(chan)') + eq(chans - 1, eval('len(nvim_list_chans())')) + end) +end) diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua index 7223f5ba61..a0aa8c0708 100644 --- a/test/functional/terminal/channel_spec.lua +++ b/test/functional/terminal/channel_spec.lua @@ -43,3 +43,13 @@ describe('associated channel is closed and later freed for terminal', function() eq("Vim(call):E900: Invalid channel id", pcall_err(command, [[call chansend(id, 'test')]])) end) end) + +describe('channel created by nvim_open_term', function() + before_each(clear) + + it('can close', function() + command('let id = nvim_open_term(0, {})') + eq("Vim(call):Can't send data to closed stream", + pcall_err(command, [[call chanclose(id) | call chansend(id, 'test')]])) + end) +end) |