diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/eval/system_spec.lua | 21 | ||||
-rw-r--r-- | test/functional/helpers.lua | 20 |
2 files changed, 31 insertions, 10 deletions
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua index b8f1f87f30..6393477260 100644 --- a/test/functional/eval/system_spec.lua +++ b/test/functional/eval/system_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) -local eq, clear, eval, feed, nvim = - helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim +local eq, clear, eval, execute, feed, nvim = + helpers.eq, helpers.clear, helpers.eval, helpers.execute, helpers.feed, + helpers.nvim local Screen = require('test.functional.ui.screen') @@ -117,8 +118,12 @@ describe('system()', function() eq("echoed", eval('system("echo -n echoed")')) end) it('to backgrounded command does not crash', function() - -- This is indeterminate, just exercise the codepath. - eval('system("echo -n echoed &")') + -- This is indeterminate, just exercise the codepath. May get E5677. + execute('call system("echo -n echoed &")') + local v_errnum = string.match(eval("v:errmsg"), "^E%d*:") + if v_errnum then + eq("E5677:", v_errnum) + end eq(2, eval("1+1")) -- Still alive? end) end) @@ -128,8 +133,12 @@ describe('system()', function() eq("input", eval('system("cat -", "input")')) end) it('to backgrounded command does not crash', function() - -- This is indeterminate, just exercise the codepath. - eval('system("cat - &", "input")') + -- This is indeterminate, just exercise the codepath. May get E5677. + execute('call system("cat - &")') + local v_errnum = string.match(eval("v:errmsg"), "^E%d*:") + if v_errnum then + eq("E5677:", v_errnum) + end eq(2, eval("1+1")) -- Still alive? end) end) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 325f41e506..3598ab5e6e 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -1,11 +1,13 @@ require('coxpcall') local lfs = require('lfs') -local ChildProcessStream = require('nvim.child_process_stream') -local SocketStream = require('nvim.socket_stream') -local TcpStream = require('nvim.tcp_stream') -local Session = require('nvim.session') local global_helpers = require('test.helpers') +-- nvim client: Found in .deps/usr/share/lua/<version>/nvim/ if "bundled". +local Session = require('nvim.session') +local TcpStream = require('nvim.tcp_stream') +local SocketStream = require('nvim.socket_stream') +local ChildProcessStream = require('nvim.child_process_stream') + local check_logs = global_helpers.check_logs local neq = global_helpers.neq local eq = global_helpers.eq @@ -134,10 +136,14 @@ local function stop() session:stop() end +-- Executes an ex-command. VimL errors will manifest as client (lua) errors, and +-- v:errmsg will be updated. local function nvim_command(cmd) request('nvim_command', cmd) end +-- Evaluates a VimL expression. +-- Fails on VimL error, but does not update v:errmsg. local function nvim_eval(expr) return request('nvim_eval', expr) end @@ -158,10 +164,14 @@ local os_name = (function() end) end)() +-- Executes a VimL function. +-- Fails on VimL error, but does not update v:errmsg. local function nvim_call(name, ...) return request('nvim_call_function', name, {...}) end +-- Sends user input to Nvim. +-- Does not fail on VimL error, but v:errmsg will be updated. local function nvim_feed(input) while #input > 0 do local written = request('nvim_input', input) @@ -279,6 +289,8 @@ local function insert(...) nvim_feed('<ESC>') end +-- Executes an ex-command by user input. Because nvim_input() is used, VimL +-- errors will not manifest as client (lua) errors. Use command() for that. local function execute(...) for _, v in ipairs({...}) do if v:sub(1, 1) ~= '/' then |