test(remote_spec): reduce flakiness in waiting for client exit (#20230)

It is less likely for client to exit between jobstart() and jobwait() if
they are invoked in the same RPC request instead of two separate ones.
This commit is contained in:
zeertzjq 2022-09-17 16:17:51 +08:00 committed by GitHub
parent 18139a69bc
commit 3c3f3e7353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear local clear = helpers.clear
local command = helpers.command local command = helpers.command
local eq = helpers.eq local eq = helpers.eq
local exec_lua = helpers.exec_lua
local expect = helpers.expect local expect = helpers.expect
local funcs = helpers.funcs local funcs = helpers.funcs
local insert = helpers.insert local insert = helpers.insert
@ -48,8 +49,8 @@ describe('Remote', function()
-- our incoming --remote calls. -- our incoming --remote calls.
local client_starter = spawn(new_argv(), false, nil, true) local client_starter = spawn(new_argv(), false, nil, true)
set_session(client_starter) set_session(client_starter)
local client_job_id = funcs.jobstart(client_argv) -- Call jobstart() and jobwait() in the same RPC request to reduce flakiness.
eq({ 0 }, funcs.jobwait({client_job_id})) eq({ 0 }, exec_lua([[return vim.fn.jobwait({ vim.fn.jobstart(...) })]], client_argv))
client_starter:close() client_starter:close()
set_session(server) set_session(server)
end end
@ -121,8 +122,8 @@ describe('Remote', function()
-- the event loop. If the server event loop is blocked, it can't process -- the event loop. If the server event loop is blocked, it can't process
-- our incoming --remote calls. -- our incoming --remote calls.
clear() clear()
local bogus_job_id = funcs.jobstart(bogus_argv) -- Call jobstart() and jobwait() in the same RPC request to reduce flakiness.
eq({2}, funcs.jobwait({bogus_job_id})) eq({ 2 }, exec_lua([[return vim.fn.jobwait({ vim.fn.jobstart(...) })]], bogus_argv))
end end
it('bogus subcommand', function() it('bogus subcommand', function()
run_and_check_exit_code('--remote-bogus') run_and_check_exit_code('--remote-bogus')