aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-01-02 15:34:14 +0100
committerJustin M. Keyes <justinkz@gmail.com>2023-01-05 17:10:02 +0100
commitadef308a5925a3b967af3bd7c598074e5b6cae18 (patch)
tree10bb0dc4b3801eb53b56023542283c20aff7e967 /test/functional
parent45549f031ee52a01601c33acc411f3111cfc4e95 (diff)
downloadrneovim-adef308a5925a3b967af3bd7c598074e5b6cae18.tar.gz
rneovim-adef308a5925a3b967af3bd7c598074e5b6cae18.tar.bz2
rneovim-adef308a5925a3b967af3bd7c598074e5b6cae18.zip
feat(lua): exit 1 on Lua "-l" script error
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/core/startup_spec.lua21
-rw-r--r--test/functional/fixtures/startup-fail.lua7
-rw-r--r--test/functional/vimscript/system_spec.lua2
3 files changed, 24 insertions, 6 deletions
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()
diff --git a/test/functional/fixtures/startup-fail.lua b/test/functional/fixtures/startup-fail.lua
new file mode 100644
index 0000000000..adcfe2a201
--- /dev/null
+++ b/test/functional/fixtures/startup-fail.lua
@@ -0,0 +1,7 @@
+-- Test "nvim -l foo.lua …" with a Lua error.
+
+local function main()
+ error('my pearls!!')
+end
+
+main()
diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua
index dbf734b51a..f099b4a36e 100644
--- a/test/functional/vimscript/system_spec.lua
+++ b/test/functional/vimscript/system_spec.lua
@@ -1,3 +1,5 @@
+-- Tests for system() and :! shell.
+
local helpers = require('test.functional.helpers')(after_each)
local assert_alive = helpers.assert_alive