mirror of
https://github.com/neovim/neovim.git
synced 2025-11-18 16:21:41 +00:00
test: API: fix tests after improved error capture
This commit is contained in:
@@ -11,6 +11,7 @@ local ok = helpers.ok
|
|||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
|
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
|
||||||
local set_session = helpers.set_session
|
local set_session = helpers.set_session
|
||||||
|
local expect_err = helpers.expect_err
|
||||||
|
|
||||||
describe('server -> client', function()
|
describe('server -> client', function()
|
||||||
local cid
|
local cid
|
||||||
@@ -221,9 +222,8 @@ describe('server -> client', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns an error if the request failed', function()
|
it('returns an error if the request failed', function()
|
||||||
local status, err = pcall(eval, "rpcrequest(vim, 'does-not-exist')")
|
expect_err('Vim:Invalid method name',
|
||||||
eq(false, status)
|
eval, "rpcrequest(vim, 'does-not-exist')")
|
||||||
ok(nil ~= string.match(err, 'Failed to evaluate expression'))
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ describe('server -> client', function()
|
|||||||
eq({'notification', 'pong', {}}, next_msg())
|
eq({'notification', 'pong', {}}, next_msg())
|
||||||
eq("done!",funcs.rpcrequest(jobid, "write_stderr", "fluff\n"))
|
eq("done!",funcs.rpcrequest(jobid, "write_stderr", "fluff\n"))
|
||||||
eq({'notification', 'stderr', {0, {'fluff', ''}}}, next_msg())
|
eq({'notification', 'stderr', {0, {'fluff', ''}}}, next_msg())
|
||||||
funcs.rpcrequest(jobid, "exit")
|
pcall(funcs.rpcrequest, jobid, "exit")
|
||||||
eq({'notification', 'stderr', {0, {''}}}, next_msg())
|
eq({'notification', 'stderr', {0, {''}}}, next_msg())
|
||||||
eq({'notification', 'exit', {0, 0}}, next_msg())
|
eq({'notification', 'exit', {0, 0}}, next_msg())
|
||||||
end)
|
end)
|
||||||
@@ -308,8 +308,8 @@ describe('server -> client', function()
|
|||||||
it('via ipv4 address', function()
|
it('via ipv4 address', function()
|
||||||
local server = spawn(nvim_argv)
|
local server = spawn(nvim_argv)
|
||||||
set_session(server)
|
set_session(server)
|
||||||
local address = funcs.serverstart("127.0.0.1:")
|
local status, address = pcall(funcs.serverstart, "127.0.0.1:")
|
||||||
if #address == 0 then
|
if not status then
|
||||||
pending('no ipv4 stack', function() end)
|
pending('no ipv4 stack', function() end)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -320,8 +320,8 @@ describe('server -> client', function()
|
|||||||
it('via ipv6 address', function()
|
it('via ipv6 address', function()
|
||||||
local server = spawn(nvim_argv)
|
local server = spawn(nvim_argv)
|
||||||
set_session(server)
|
set_session(server)
|
||||||
local address = funcs.serverstart('::1:')
|
local status, address = pcall(funcs.serverstart, '::1:')
|
||||||
if #address == 0 then
|
if not status then
|
||||||
pending('no ipv6 stack', function() end)
|
pending('no ipv6 stack', function() end)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ local curwinmeths = helpers.curwinmeths
|
|||||||
local curtabmeths = helpers.curtabmeths
|
local curtabmeths = helpers.curtabmeths
|
||||||
local get_pathsep = helpers.get_pathsep
|
local get_pathsep = helpers.get_pathsep
|
||||||
local rmdir = helpers.rmdir
|
local rmdir = helpers.rmdir
|
||||||
|
local expect_err = helpers.expect_err
|
||||||
|
|
||||||
local fname = 'Xtest-functional-eval-buf_functions'
|
local fname = 'Xtest-functional-eval-buf_functions'
|
||||||
local fname2 = fname .. '.2'
|
local fname2 = fname .. '.2'
|
||||||
@@ -296,8 +297,8 @@ describe('setbufvar() function', function()
|
|||||||
eq('Vim(call):E461: Illegal variable name: b:',
|
eq('Vim(call):E461: Illegal variable name: b:',
|
||||||
exc_exec('call setbufvar(1, "", 0)'))
|
exc_exec('call setbufvar(1, "", 0)'))
|
||||||
eq(true, bufmeths.get_var(buf1, 'number'))
|
eq(true, bufmeths.get_var(buf1, 'number'))
|
||||||
funcs.setbufvar(1, 'changedtick', true)
|
expect_err('Vim:E46: Cannot change read%-only variable "b:changedtick"',
|
||||||
-- eq(true, bufmeths.get_var(buf1, 'changedtick'))
|
funcs.setbufvar, 1, 'changedtick', true)
|
||||||
eq(2, funcs.getbufvar(1, 'changedtick'))
|
eq(2, funcs.getbufvar(1, 'changedtick'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -87,15 +87,15 @@ describe('server', function()
|
|||||||
|
|
||||||
local expected = {}
|
local expected = {}
|
||||||
local v4 = '127.0.0.1:12345'
|
local v4 = '127.0.0.1:12345'
|
||||||
s = funcs.serverstart(v4)
|
local status, _ = pcall(funcs.serverstart, v4)
|
||||||
if #s > 0 then
|
if status then
|
||||||
table.insert(expected, v4)
|
table.insert(expected, v4)
|
||||||
pcall(funcs.serverstart, v4) -- exists already; ignore
|
pcall(funcs.serverstart, v4) -- exists already; ignore
|
||||||
end
|
end
|
||||||
|
|
||||||
local v6 = '::1:12345'
|
local v6 = '::1:12345'
|
||||||
s = funcs.serverstart(v6)
|
status, _ = pcall(funcs.serverstart, v6)
|
||||||
if #s > 0 then
|
if status then
|
||||||
table.insert(expected, v6)
|
table.insert(expected, v6)
|
||||||
pcall(funcs.serverstart, v6) -- exists already; ignore
|
pcall(funcs.serverstart, v6) -- exists already; ignore
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user