multigrid: add multigrid support to test infrastructure

make Screen explicitly tied to its session
This commit is contained in:
Björn Linse
2017-12-09 11:26:06 +01:00
parent f77f09ea6e
commit 1f8afe15a4
6 changed files with 171 additions and 72 deletions

View File

@@ -84,6 +84,10 @@ end
local session, loop_running, last_error
local function get_session()
return session
end
local function set_session(s, keep)
if session and not keep then
session:close()
@@ -164,34 +168,34 @@ local function expect_msg_seq(...)
error(final_error)
end
local function call_and_stop_on_error(...)
local function call_and_stop_on_error(lsession, ...)
local status, result = copcall(...) -- luacheck: ignore
if not status then
session:stop()
lsession:stop()
last_error = result
return ''
end
return result
end
local function run(request_cb, notification_cb, setup_cb, timeout)
local function run_session(lsession, request_cb, notification_cb, setup_cb, timeout)
local on_request, on_notification, on_setup
if request_cb then
function on_request(method, args)
return call_and_stop_on_error(request_cb, method, args)
return call_and_stop_on_error(lsession, request_cb, method, args)
end
end
if notification_cb then
function on_notification(method, args)
call_and_stop_on_error(notification_cb, method, args)
call_and_stop_on_error(lsession, notification_cb, method, args)
end
end
if setup_cb then
function on_setup()
call_and_stop_on_error(setup_cb)
call_and_stop_on_error(lsession, setup_cb)
end
end
@@ -205,6 +209,10 @@ local function run(request_cb, notification_cb, setup_cb, timeout)
end
end
local function run(request_cb, notification_cb, setup_cb, timeout)
run_session(session, request_cb, notification_cb, setup_cb, timeout)
end
local function stop()
session:stop()
end
@@ -677,6 +685,7 @@ local module = {
buffer = buffer,
bufmeths = bufmeths,
call = nvim_call,
create_callindex = create_callindex,
clear = clear,
command = nvim_command,
connect = connect,
@@ -701,6 +710,7 @@ local module = {
filter = filter,
funcs = funcs,
get_pathsep = get_pathsep,
get_session = get_session,
insert = insert,
iswin = iswin,
map = map,
@@ -732,6 +742,7 @@ local module = {
retry = retry,
rmdir = rmdir,
run = run,
run_session = run_session,
set_session = set_session,
set_shell_powershell = set_shell_powershell,
skip_fragile = skip_fragile,