diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-05-09 21:44:18 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-05-10 04:01:25 +0200 |
commit | 79a0d827550d7816c9c021fb66926b8a650f8837 (patch) | |
tree | 4d3a2ee0d54db97f500c0ee61ecf834aa7d71f85 | |
parent | 2326a4ac3a9dfdedba6fd4e1c68491b071fdc57b (diff) | |
download | rneovim-79a0d827550d7816c9c021fb66926b8a650f8837.tar.gz rneovim-79a0d827550d7816c9c021fb66926b8a650f8837.tar.bz2 rneovim-79a0d827550d7816c9c021fb66926b8a650f8837.zip |
test: API: fix tests after improved error capture
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 16 | ||||
-rw-r--r-- | test/functional/eval/buf_functions_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/eval/server_spec.lua | 8 |
3 files changed, 15 insertions, 14 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index f00ce6992f..e79a60fb10 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -11,6 +11,7 @@ local ok = helpers.ok local meths = helpers.meths local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv local set_session = helpers.set_session +local expect_err = helpers.expect_err describe('server -> client', function() local cid @@ -221,9 +222,8 @@ describe('server -> client', function() end) it('returns an error if the request failed', function() - local status, err = pcall(eval, "rpcrequest(vim, 'does-not-exist')") - eq(false, status) - ok(nil ~= string.match(err, 'Failed to evaluate expression')) + expect_err('Vim:Invalid method name', + eval, "rpcrequest(vim, 'does-not-exist')") end) end) @@ -261,7 +261,7 @@ describe('server -> client', function() eq({'notification', 'pong', {}}, next_msg()) eq("done!",funcs.rpcrequest(jobid, "write_stderr", "fluff\n")) eq({'notification', 'stderr', {0, {'fluff', ''}}}, next_msg()) - funcs.rpcrequest(jobid, "exit") + pcall(funcs.rpcrequest, jobid, "exit") eq({'notification', 'stderr', {0, {''}}}, next_msg()) eq({'notification', 'exit', {0, 0}}, next_msg()) end) @@ -308,8 +308,8 @@ describe('server -> client', function() it('via ipv4 address', function() local server = spawn(nvim_argv) set_session(server) - local address = funcs.serverstart("127.0.0.1:") - if #address == 0 then + local status, address = pcall(funcs.serverstart, "127.0.0.1:") + if not status then pending('no ipv4 stack', function() end) return end @@ -320,8 +320,8 @@ describe('server -> client', function() it('via ipv6 address', function() local server = spawn(nvim_argv) set_session(server) - local address = funcs.serverstart('::1:') - if #address == 0 then + local status, address = pcall(funcs.serverstart, '::1:') + if not status then pending('no ipv6 stack', function() end) return end diff --git a/test/functional/eval/buf_functions_spec.lua b/test/functional/eval/buf_functions_spec.lua index 7de58766b9..c0e264d4c9 100644 --- a/test/functional/eval/buf_functions_spec.lua +++ b/test/functional/eval/buf_functions_spec.lua @@ -15,6 +15,7 @@ local curwinmeths = helpers.curwinmeths local curtabmeths = helpers.curtabmeths local get_pathsep = helpers.get_pathsep local rmdir = helpers.rmdir +local expect_err = helpers.expect_err local fname = 'Xtest-functional-eval-buf_functions' local fname2 = fname .. '.2' @@ -296,8 +297,8 @@ describe('setbufvar() function', function() eq('Vim(call):E461: Illegal variable name: b:', exc_exec('call setbufvar(1, "", 0)')) eq(true, bufmeths.get_var(buf1, 'number')) - funcs.setbufvar(1, 'changedtick', true) - -- eq(true, bufmeths.get_var(buf1, 'changedtick')) + expect_err('Vim:E46: Cannot change read%-only variable "b:changedtick"', + funcs.setbufvar, 1, 'changedtick', true) eq(2, funcs.getbufvar(1, 'changedtick')) end) end) diff --git a/test/functional/eval/server_spec.lua b/test/functional/eval/server_spec.lua index 187e138b22..563e619b39 100644 --- a/test/functional/eval/server_spec.lua +++ b/test/functional/eval/server_spec.lua @@ -87,15 +87,15 @@ describe('server', function() local expected = {} local v4 = '127.0.0.1:12345' - s = funcs.serverstart(v4) - if #s > 0 then + local status, _ = pcall(funcs.serverstart, v4) + if status then table.insert(expected, v4) pcall(funcs.serverstart, v4) -- exists already; ignore end local v6 = '::1:12345' - s = funcs.serverstart(v6) - if #s > 0 then + status, _ = pcall(funcs.serverstart, v6) + if status then table.insert(expected, v6) pcall(funcs.serverstart, v6) -- exists already; ignore end |