aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/embed_spec.lua
diff options
context:
space:
mode:
authorGeorge Harker <george@george-graphics.co.uk>2023-10-31 20:04:53 -0700
committerGitHub <noreply@github.com>2023-11-01 11:04:53 +0800
commit4e6096a67fe9860994be38bcd155e7c47313205e (patch)
treea4f7ee6792bc27789bd6c052e3d26f2ae51eba72 /test/functional/ui/embed_spec.lua
parent746a153bc1a1bc1433a1246fcf454eeb058b9de1 (diff)
downloadrneovim-4e6096a67fe9860994be38bcd155e7c47313205e.tar.gz
rneovim-4e6096a67fe9860994be38bcd155e7c47313205e.tar.bz2
rneovim-4e6096a67fe9860994be38bcd155e7c47313205e.zip
feat(server): allow embed with listen (#25709)
connection from any channel or stdio will unblock remote_ui_wait_for_attach. Wait on stdio only if only —embed specified, if both —embed and —listen then wait on any channel.
Diffstat (limited to 'test/functional/ui/embed_spec.lua')
-rw-r--r--test/functional/ui/embed_spec.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua
index db01c55e23..e75de503ee 100644
--- a/test/functional/ui/embed_spec.lua
+++ b/test/functional/ui/embed_spec.lua
@@ -2,10 +2,13 @@ local uv = require'luv'
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
+local thelpers = require('test.functional.terminal.helpers')
local feed = helpers.feed
local eq = helpers.eq
local clear = helpers.clear
+local ok = helpers.ok
+
local function test_embed(ext_linegrid)
local screen
@@ -133,3 +136,60 @@ describe('--embed UI', function()
]]}
end)
end)
+
+describe('--embed --listen UI', function()
+ it('waits for connection on listening address', function()
+ helpers.skip(helpers.is_os('win'))
+ clear()
+ local child_server = assert(helpers.new_pipename())
+
+ local screen = thelpers.screen_setup(0,
+ string.format(
+ [=[["%s", "--embed", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s"]]=],
+ helpers.nvim_prog, child_server, helpers.nvim_set))
+ screen:expect{grid=[[
+ {1: } |
+ |
+ |
+ |
+ |
+ |
+ {3:-- TERMINAL --} |
+ ]]}
+
+ local child_session = helpers.connect(child_server)
+
+ local info_ok, apiinfo = child_session:request('nvim_get_api_info')
+ assert(info_ok)
+ assert(#apiinfo == 2)
+
+ child_session:request('nvim_exec2', [[
+ let g:vim_entered=0
+ autocmd VimEnter * call execute("let g:vim_entered=1")
+ ]], {})
+
+ -- g:vim_entered shouldn't be set to 1 until after attach
+ local var_ok, var = child_session:request('nvim_get_var', 'vim_entered')
+ assert(var_ok)
+ ok(var == 0)
+
+ local child_screen = Screen.new(40, 6)
+ child_screen:attach(nil, child_session)
+ child_screen:expect{grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]], attr_ids={
+ [1] = {foreground = Screen.colors.Blue, bold = true};
+ }}
+
+ -- g:vim_entered should now be set to 1
+ var_ok, var = child_session:request('nvim_get_var', 'vim_entered')
+ assert(var_ok)
+ ok(var == 1)
+
+ end)
+end)