mirror of
https://github.com/neovim/neovim
synced 2025-07-18 10:11:50 +00:00
fix(ui): Windows :detach is opt-in
Problem: On Windows, spawning the `nvim --embed` server with `detach=true` breaks various `tt.setup_child_nvim` tests. Solution: Make this behavior opt-in with an env var, temporarily.
This commit is contained in:
@ -438,9 +438,9 @@ static void on_proc_exit(Proc *proc)
|
|||||||
ILOG("child exited: pid=%d status=%d" PRIu64, proc->pid, proc->status);
|
ILOG("child exited: pid=%d status=%d" PRIu64, proc->pid, proc->status);
|
||||||
|
|
||||||
// XXX: This assumes the TUI never spawns any other processes...?
|
// XXX: This assumes the TUI never spawns any other processes...?
|
||||||
// if (ui_client_channel_id) {
|
if (ui_client_channel_id) {
|
||||||
// exit_on_closed_chan(proc->status);
|
exit_on_closed_chan(proc->status);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Process has terminated, but there could still be data to be read from the
|
// Process has terminated, but there could still be data to be read from the
|
||||||
// OS. We are still in the libuv loop, so we cannot call code that polls for
|
// OS. We are still in the libuv loop, so we cannot call code that polls for
|
||||||
|
@ -62,7 +62,8 @@ uint64_t ui_client_start_server(int argc, char **argv)
|
|||||||
on_err.fwd_err = true;
|
on_err.fwd_err = true;
|
||||||
|
|
||||||
#ifdef MSWIN
|
#ifdef MSWIN
|
||||||
bool detach = false; // TODO(justinmk): detach=true breaks `tt.setup_child_nvim` tests on Windows.
|
// TODO(justinmk): detach breaks `tt.setup_child_nvim` tests on Windows?
|
||||||
|
bool detach = os_env_exists("__NVIM_DETACH");
|
||||||
#else
|
#else
|
||||||
bool detach = true;
|
bool detach = true;
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,6 +42,47 @@ describe('TUI :detach', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not stop server', function()
|
it('does not stop server', function()
|
||||||
|
local job_opts = {
|
||||||
|
env = {
|
||||||
|
NVIM_LOG_FILE = testlog,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_os('win') then
|
||||||
|
-- TODO(justinmk): on Windows,
|
||||||
|
-- - tt.setup_child_nvim() is broken.
|
||||||
|
-- - session.lua is broken after the pipe closes.
|
||||||
|
-- So this test currently just exercises __NVIM_DETACH + :detach, without asserting anything.
|
||||||
|
|
||||||
|
-- TODO(justinmk): temporary hack for Windows.
|
||||||
|
job_opts.env['__NVIM_DETACH'] = '1'
|
||||||
|
n.clear(job_opts)
|
||||||
|
|
||||||
|
local screen = Screen.new(50, 10)
|
||||||
|
n.feed('iHello, World')
|
||||||
|
screen:expect([[
|
||||||
|
Hello, World^ |
|
||||||
|
{1:~ }|*8
|
||||||
|
{5:-- INSERT --} |
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- local addr = api.nvim_get_vvar('servername')
|
||||||
|
eq(1, #n.api.nvim_list_uis())
|
||||||
|
|
||||||
|
-- TODO(justinmk): test util should not freak out when the pipe closes.
|
||||||
|
n.expect_exit(n.command, 'detach')
|
||||||
|
|
||||||
|
-- n.get_session():close() -- XXX: hangs
|
||||||
|
-- n.set_session(n.connect(addr)) -- XXX: hangs
|
||||||
|
-- eq(0, #n.api.nvim_list_uis()) -- XXX: hangs
|
||||||
|
|
||||||
|
-- Avoid a dangling process.
|
||||||
|
n.get_session():close('kill')
|
||||||
|
-- n.expect_exit(n.command, 'qall!')
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local server_super = n.clear()
|
local server_super = n.clear()
|
||||||
local client_super = n.new_session(true)
|
local client_super = n.new_session(true)
|
||||||
finally(function()
|
finally(function()
|
||||||
@ -53,16 +94,15 @@ describe('TUI :detach', function()
|
|||||||
local screen = tt.setup_child_nvim({
|
local screen = tt.setup_child_nvim({
|
||||||
'--listen',
|
'--listen',
|
||||||
child_server,
|
child_server,
|
||||||
'--clean',
|
'-u',
|
||||||
|
'NONE',
|
||||||
|
'-i',
|
||||||
|
'NONE',
|
||||||
'--cmd',
|
'--cmd',
|
||||||
'colorscheme vim',
|
'colorscheme vim',
|
||||||
'--cmd',
|
'--cmd',
|
||||||
nvim_set .. ' notermguicolors laststatus=2 background=dark',
|
nvim_set .. ' notermguicolors laststatus=2 background=dark',
|
||||||
}, {
|
}, job_opts)
|
||||||
env = {
|
|
||||||
NVIM_LOG_FILE = testlog,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
tt.feed_data('iHello, World')
|
tt.feed_data('iHello, World')
|
||||||
screen:expect {
|
screen:expect {
|
||||||
@ -106,7 +146,8 @@ describe('TUI :detach', function()
|
|||||||
'--remote-ui',
|
'--remote-ui',
|
||||||
'--server',
|
'--server',
|
||||||
child_server,
|
child_server,
|
||||||
})
|
}, job_opts)
|
||||||
|
|
||||||
screen_reattached:expect {
|
screen_reattached:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
We did it, pooky^. |
|
We did it, pooky^. |
|
||||||
|
Reference in New Issue
Block a user