mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 04:17:01 +00:00
test: fix running functional tests under gdbserver
It was not possible to run the tests under the gdbserver because we were not closing the old session before starting a new one. This caused the server to not to be able to bind to the given address and crashing the tests. This commit closes the session before starting a new one. Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh2702@gmail.com>
This commit is contained in:
@@ -278,8 +278,9 @@ describe('server -> client', function()
|
|||||||
local nvim_argv = merge_args(helpers.nvim_argv, {'--headless'})
|
local nvim_argv = merge_args(helpers.nvim_argv, {'--headless'})
|
||||||
local function connect_test(server, mode, address)
|
local function connect_test(server, mode, address)
|
||||||
local serverpid = funcs.getpid()
|
local serverpid = funcs.getpid()
|
||||||
local client = spawn(nvim_argv)
|
local client = spawn(nvim_argv, false, nil, true)
|
||||||
set_session(client, true)
|
set_session(client)
|
||||||
|
|
||||||
local clientpid = funcs.getpid()
|
local clientpid = funcs.getpid()
|
||||||
neq(serverpid, clientpid)
|
neq(serverpid, clientpid)
|
||||||
local id = funcs.sockconnect(mode, address, {rpc=true})
|
local id = funcs.sockconnect(mode, address, {rpc=true})
|
||||||
@@ -288,7 +289,7 @@ describe('server -> client', function()
|
|||||||
funcs.rpcrequest(id, 'nvim_set_current_line', 'hello')
|
funcs.rpcrequest(id, 'nvim_set_current_line', 'hello')
|
||||||
local client_id = funcs.rpcrequest(id, 'nvim_get_api_info')[1]
|
local client_id = funcs.rpcrequest(id, 'nvim_get_api_info')[1]
|
||||||
|
|
||||||
set_session(server, true)
|
set_session(server)
|
||||||
eq(serverpid, funcs.getpid())
|
eq(serverpid, funcs.getpid())
|
||||||
eq('hello', meths.get_current_line())
|
eq('hello', meths.get_current_line())
|
||||||
|
|
||||||
@@ -296,7 +297,7 @@ describe('server -> client', function()
|
|||||||
funcs.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
|
funcs.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
|
||||||
eq(id, funcs.rpcrequest(client_id, 'nvim_get_api_info')[1])
|
eq(id, funcs.rpcrequest(client_id, 'nvim_get_api_info')[1])
|
||||||
|
|
||||||
set_session(client, true)
|
set_session(client)
|
||||||
eq(clientpid, funcs.getpid())
|
eq(clientpid, funcs.getpid())
|
||||||
eq('howdy!', meths.get_current_line())
|
eq('howdy!', meths.get_current_line())
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ describe('channels', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
pending('can connect to socket', function()
|
pending('can connect to socket', function()
|
||||||
local server = spawn(nvim_argv)
|
local server = spawn(nvim_argv, nil, nil, true)
|
||||||
set_session(server)
|
set_session(server)
|
||||||
local address = funcs.serverlist()[1]
|
local address = funcs.serverlist()[1]
|
||||||
local client = spawn(nvim_argv)
|
local client = spawn(nvim_argv, nil, nil, true)
|
||||||
set_session(client, true)
|
set_session(client)
|
||||||
source(init)
|
source(init)
|
||||||
|
|
||||||
meths.set_var('address', address)
|
meths.set_var('address', address)
|
||||||
@@ -42,11 +42,11 @@ describe('channels', function()
|
|||||||
ok(id > 0)
|
ok(id > 0)
|
||||||
|
|
||||||
command("call chansend(g:id, msgpackdump([[2,'nvim_set_var',['code',23]]]))")
|
command("call chansend(g:id, msgpackdump([[2,'nvim_set_var',['code',23]]]))")
|
||||||
set_session(server, true)
|
set_session(server)
|
||||||
retry(nil, 1000, function()
|
retry(nil, 1000, function()
|
||||||
eq(23, meths.get_var('code'))
|
eq(23, meths.get_var('code'))
|
||||||
end)
|
end)
|
||||||
set_session(client, true)
|
set_session(client)
|
||||||
|
|
||||||
command("call chansend(g:id, msgpackdump([[0,0,'nvim_eval',['2+3']]]))")
|
command("call chansend(g:id, msgpackdump([[0,0,'nvim_eval',['2+3']]]))")
|
||||||
|
|
||||||
|
|||||||
@@ -96,10 +96,7 @@ function module.get_session()
|
|||||||
return session
|
return session
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.set_session(s, keep)
|
function module.set_session(s)
|
||||||
if session and not keep then
|
|
||||||
session:close()
|
|
||||||
end
|
|
||||||
session = s
|
session = s
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -366,7 +363,11 @@ local function remove_args(args, args_rm)
|
|||||||
return new_args
|
return new_args
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.spawn(argv, merge, env)
|
function module.spawn(argv, merge, env, keep)
|
||||||
|
if session and not keep then
|
||||||
|
session:close()
|
||||||
|
end
|
||||||
|
|
||||||
local child_stream = ChildProcessStream.spawn(
|
local child_stream = ChildProcessStream.spawn(
|
||||||
merge and module.merge_args(prepend_argv, argv) or argv,
|
merge and module.merge_args(prepend_argv, argv) or argv,
|
||||||
env)
|
env)
|
||||||
|
|||||||
Reference in New Issue
Block a user