From adef308a5925a3b967af3bd7c598074e5b6cae18 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Jan 2023 15:34:14 +0100 Subject: feat(lua): exit 1 on Lua "-l" script error --- test/functional/core/startup_spec.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'test/functional/core') diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index dbd517995c..455de08548 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -88,11 +88,11 @@ describe('startup', function() end) describe('-l Lua', function() - local function assert_l_out(expected, args_before, args_after) + local function assert_l_out(expected, nvim_args, lua_args) local args = { nvim_prog, '--clean' } - vim.list_extend(args, args_before or {}) + vim.list_extend(args, nvim_args or {}) vim.list_extend(args, { '-l', 'test/functional/fixtures/startup.lua' }) - vim.list_extend(args, args_after or {}) + vim.list_extend(args, lua_args or {}) local out = funcs.system(args):gsub('\r\n', '\n') return eq(dedent(expected), out) end @@ -115,6 +115,13 @@ describe('startup', function() eq(73, eval('v:shell_error')) end) + it('Lua error sets Nvim exitcode', function() + eq(0, eval('v:shell_error')) + matches('E5113: .* my pearls!!', + funcs.system({ nvim_prog, '-l', 'test/functional/fixtures/startup-fail.lua' })) + eq(1, eval('v:shell_error')) + end) + it('sets _G.arg', function() -- nvim -l foo.lua -arg1 -- a b c assert_l_out([[ @@ -396,11 +403,13 @@ describe('startup', function() { 'put =mode(1)', 'print', '' })) end) - it('fails on --embed with -es/-Es', function() - matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es', + it('fails on --embed with -es/-Es/-l', function() + matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', funcs.system({nvim_prog, '--embed', '-es' })) - matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es', + matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', funcs.system({nvim_prog, '--embed', '-Es' })) + matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', + funcs.system({nvim_prog, '--embed', '-l', 'foo.lua' })) end) it('does not crash if --embed is given twice', function() -- cgit