aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/server_requests_spec.lua6
-rw-r--r--test/functional/api/vim_spec.lua7
-rw-r--r--test/functional/autocmd/autocmd_spec.lua4
-rw-r--r--test/functional/eval/api_functions_spec.lua8
-rw-r--r--test/functional/helpers.lua14
-rw-r--r--test/functional/provider/python3_spec.lua4
-rw-r--r--test/functional/ui/messages_spec.lua57
-rw-r--r--test/functional/ui/screen.lua14
8 files changed, 90 insertions, 24 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index 7d9a8269d9..07218f11dd 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -10,7 +10,7 @@ local ok = helpers.ok
local meths = helpers.meths
local spawn, merge_args = helpers.spawn, helpers.merge_args
local set_session = helpers.set_session
-local expect_err = helpers.expect_err
+local meth_pcall = helpers.meth_pcall
describe('server -> client', function()
local cid
@@ -221,8 +221,8 @@ describe('server -> client', function()
end)
it('returns an error if the request failed', function()
- expect_err('Vim:Invalid method: does%-not%-exist',
- eval, "rpcrequest(vim, 'does-not-exist')")
+ eq({false, "Vim:Error invoking 'does-not-exist' on channel 3:\nInvalid method: does-not-exist" },
+ meth_pcall(eval, "rpcrequest(vim, 'does-not-exist')"))
end)
end)
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index a7d8dc59ec..69bd584ab4 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -892,7 +892,7 @@ describe('API', function()
eq({info=info}, meths.get_var("opened_event"))
eq({[1]=testinfo,[2]=stderr,[3]=info}, meths.list_chans())
eq(info, meths.get_chan_info(3))
- eval('rpcrequest(3, "nvim_set_client_info", "cat", {}, "remote",'..
+ eval('rpcrequest(3, "nvim_set_client_info", "amazing-cat", {}, "remote",'..
'{"nvim_command":{"n_args":1}},'.. -- and so on
'{"description":"The Amazing Cat"})')
info = {
@@ -900,7 +900,7 @@ describe('API', function()
id=3,
mode='rpc',
client = {
- name='cat',
+ name='amazing-cat',
version={major=0},
type='remote',
methods={nvim_command={n_args=1}},
@@ -909,6 +909,9 @@ describe('API', function()
}
eq({info=info}, meths.get_var("info_event"))
eq({[1]=testinfo,[2]=stderr,[3]=info}, meths.list_chans())
+
+ eq({false, "Vim:Error invoking 'nvim_set_current_buf' on channel 3 (amazing-cat):\nWrong type for argument 1, expecting Buffer"},
+ meth_pcall(eval, 'rpcrequest(3, "nvim_set_current_buf", -1)'))
end)
it('works for :terminal channel', function()
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua
index 1eeaa62864..20538d7141 100644
--- a/test/functional/autocmd/autocmd_spec.lua
+++ b/test/functional/autocmd/autocmd_spec.lua
@@ -219,7 +219,7 @@ describe('autocmd', function()
eq(7, eval('g:test'))
-- API calls are blocked when aucmd_win is not in scope
- eq({false, 'Vim(call):Invalid window id'},
+ eq({false, 'Vim(call):E5555: API call: Invalid window id'},
meth_pcall(command, "call nvim_set_current_win(g:winid)"))
-- second time aucmd_win is needed, a different code path is invoked
@@ -257,7 +257,7 @@ describe('autocmd', function()
eq(0, eval('g:had_value'))
eq(7, eval('g:test'))
- eq({false, 'Vim(call):Invalid window id'},
+ eq({false, 'Vim(call):E5555: API call: Invalid window id'},
meth_pcall(command, "call nvim_set_current_win(g:winid)"))
end)
end)
diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua
index 40d06b599f..0e3a88802d 100644
--- a/test/functional/eval/api_functions_spec.lua
+++ b/test/functional/eval/api_functions_spec.lua
@@ -34,16 +34,16 @@ describe('eval-API', function()
eq('Vim(call):E119: Not enough arguments for function: nvim_set_option', err)
err = exc_exec('call nvim_buf_set_lines(1, 0, -1, [], ["list"])')
- eq('Vim(call):Wrong type for argument 4, expecting Boolean', err)
+ eq('Vim(call):E5555: API call: Wrong type for argument 4, expecting Boolean', err)
err = exc_exec('call nvim_buf_set_lines(0, 0, -1, v:true, "string")')
- eq('Vim(call):Wrong type for argument 5, expecting ArrayOf(String)', err)
+ eq('Vim(call):E5555: API call: Wrong type for argument 5, expecting ArrayOf(String)', err)
err = exc_exec('call nvim_buf_get_number("0")')
- eq('Vim(call):Wrong type for argument 1, expecting Buffer', err)
+ eq('Vim(call):E5555: API call: Wrong type for argument 1, expecting Buffer', err)
err = exc_exec('call nvim_buf_line_count(17)')
- eq('Vim(call):Invalid buffer id', err)
+ eq('Vim(call):E5555: API call: Invalid buffer id', err)
end)
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 35084f6cff..e2639f41e7 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -73,7 +73,7 @@ if prepend_argv then
nvim_argv = new_nvim_argv
end
-local session, loop_running, last_error
+local session, loop_running, last_error, method_error
local function get_session()
return session
@@ -190,12 +190,21 @@ local function call_and_stop_on_error(lsession, ...)
return result
end
+local function set_method_error(err)
+ method_error = err
+end
+
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(lsession, request_cb, method, args)
+ method_error = nil
+ local result = call_and_stop_on_error(lsession, request_cb, method, args)
+ if method_error ~= nil then
+ return method_error, true
+ end
+ return result
end
end
@@ -806,6 +815,7 @@ local module = {
run = run,
run_session = run_session,
set_session = set_session,
+ set_method_error = set_method_error,
set_shell_powershell = set_shell_powershell,
skip_fragile = skip_fragile,
source = source,
diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua
index 3a33109079..68d4d1e2a1 100644
--- a/test/functional/provider/python3_spec.lua
+++ b/test/functional/provider/python3_spec.lua
@@ -40,8 +40,8 @@ describe('python3 provider', function()
-- mostly bogus.
local very_long_symbol = string.rep('a', 1200)
feed_command(':silent! py3 print('..very_long_symbol..' b)')
- -- Truncated error message would not contain this (last) line.
- eq('SyntaxError: invalid syntax', eval('v:errmsg'))
+ -- Error message will contain this (last) line.
+ eq('Error invoking \'python_execute\' on channel 3 (python3-script-host):\n File "<string>", line 1\n print('..very_long_symbol..' b)\n '..string.rep(' ',1200)..' ^\nSyntaxError: invalid syntax', eval('v:errmsg'))
end)
it('python3_execute with nested commands', function()
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index d49d2f0316..976dbe5893 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -4,6 +4,7 @@ local clear, feed = helpers.clear, helpers.feed
local eval = helpers.eval
local eq = helpers.eq
local command = helpers.command
+local set_method_error = helpers.set_method_error
describe('ui/ext_messages', function()
@@ -631,7 +632,7 @@ describe('ui/ext_messages', function()
eq(0, eval('&cmdheight'))
end)
- it('supports multiline messages', function()
+ it('supports multiline messages from lua', function()
feed(':lua error("such\\nmultiline\\nerror")<cr>')
screen:expect{grid=[[
^ |
@@ -641,9 +642,61 @@ describe('ui/ext_messages', function()
{1:~ }|
]], messages={{
content = {{'E5105: Error while calling lua chunk: [string "<VimL compiled string>"]:1: such\nmultiline\nerror', 2}},
- kind = "emsg"
+ kind = "lua_error"
}}}
end)
+
+ it('supports multiline messages from rpc', function()
+ feed(':call rpcrequest(1, "test_method")<cr>')
+
+ screen:expect{grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]], messages={{
+ content = {{"Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2}},
+ kind = "rpc_error"
+ }}, request_cb=function (name)
+ if name == "test_method" then
+ set_method_error("complete\nerror\n\nmessage")
+ end
+ end}
+ end)
+end)
+
+describe('ui/builtin messages', function()
+ local screen
+ before_each(function()
+ clear()
+ screen = Screen.new(60, 7)
+ screen:attach({rgb=true, ext_popupmenu=true})
+ screen:set_default_attr_ids({
+ [1] = {bold = true, foreground = Screen.colors.Blue1},
+ [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
+ [3] = {bold = true, reverse = true},
+ [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
+ })
+ end)
+
+ it('supports multiline messages from rpc', function()
+ feed(':call rpcrequest(1, "test_method")<cr>')
+
+ screen:expect{grid=[[
+ {3: }|
+ {2:Error invoking 'test_method' on channel 1:} |
+ {2:complete} |
+ {2:error} |
+ |
+ {2:message} |
+ {4:Press ENTER or type command to continue}^ |
+ ]], request_cb=function (name)
+ if name == "test_method" then
+ set_method_error("complete\nerror\n\nmessage")
+ end
+ end}
+ end)
end)
describe('ui/ext_messages', function()
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index a81851cbba..044e4cc39c 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -322,7 +322,7 @@ function Screen:expect(expected, attr_ids, attr_ignore)
assert(not (attr_ids ~= nil or attr_ignore ~= nil))
local is_key = {grid=true, attr_ids=true, attr_ignore=true, condition=true,
any=true, mode=true, unchanged=true, intermediate=true,
- reset=true, timeout=true}
+ reset=true, timeout=true, request_cb=true}
for _, v in ipairs(ext_keys) do
is_key[v] = true
end
@@ -497,7 +497,7 @@ function Screen:_wait(check, flags)
return true
end
- run_session(self._session, nil, notification_cb, nil, minimal_timeout)
+ run_session(self._session, flags.request_cb, notification_cb, nil, minimal_timeout)
if not did_flush then
err = "no flush received"
elseif not checked then
@@ -510,7 +510,7 @@ function Screen:_wait(check, flags)
if not success_seen then
did_miminal_timeout = true
- run_session(self._session, nil, notification_cb, nil, timeout-minimal_timeout)
+ run_session(self._session, flags.request_cb, notification_cb, nil, timeout-minimal_timeout)
end
local did_warn = false
@@ -565,12 +565,12 @@ asynchronous (feed(), nvim_input()) and synchronous API calls.
end
end
-function Screen:sleep(ms)
+function Screen:sleep(ms, request_cb)
local function notification_cb(method, args)
assert(method == 'redraw')
self:_redraw(args)
end
- run_session(self._session, nil, notification_cb, nil, ms)
+ run_session(self._session, request_cb, notification_cb, nil, ms)
end
function Screen:_redraw(updates)
@@ -1145,8 +1145,8 @@ end
-- Use snapshot_util({},true) to generate a text-only (no attributes) test.
--
-- @see Screen:redraw_debug()
-function Screen:snapshot_util(attrs, ignore)
- self:sleep(250)
+function Screen:snapshot_util(attrs, ignore, request_cb)
+ self:sleep(250, request_cb)
self:print_snapshot(attrs, ignore)
end