aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/main_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/core/main_spec.lua')
-rw-r--r--test/functional/core/main_spec.lua117
1 files changed, 52 insertions, 65 deletions
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua
index a445423efc..65a7c556b8 100644
--- a/test/functional/core/main_spec.lua
+++ b/test/functional/core/main_spec.lua
@@ -9,7 +9,6 @@ local feed = n.feed
local eval = n.eval
local clear = n.clear
local fn = n.fn
-local nvim_prog_abs = n.nvim_prog_abs
local write_file = t.write_file
local is_os = t.is_os
local skip = t.skip
@@ -35,7 +34,7 @@ describe('command-line option', function()
it('treats - as stdin', function()
eq(nil, uv.fs_stat(fname))
fn.system({
- nvim_prog_abs(),
+ n.nvim_prog,
'-u',
'NONE',
'-i',
@@ -56,41 +55,39 @@ describe('command-line option', function()
eq(nil, uv.fs_stat(fname))
eq(true, not not dollar_fname:find('%$%w+'))
write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n')
- fn.system({
- nvim_prog_abs(),
- '-u',
- 'NONE',
- '-i',
- 'NONE',
- '--headless',
+ local p = n.spawn_wait(
'--cmd',
'set noswapfile shortmess+=IFW fileformats=unix',
'-s',
dollar_fname,
- fname,
- })
- eq(0, eval('v:shell_error'))
+ fname
+ )
+ eq(0, p.status)
local attrs = uv.fs_stat(fname)
eq(#'100500\n', attrs.size)
end)
- it('does not crash when run completion in ex mode', function()
- fn.system({
- nvim_prog_abs(),
- '--clean',
- '-e',
- '-s',
- '--cmd',
- 'exe "norm! i\\<C-X>\\<C-V>"',
- })
- eq(0, eval('v:shell_error'))
+ it('does not crash when running completion in Ex mode', function()
+ local p =
+ n.spawn_wait('--clean', '-e', '-s', '--cmd', 'exe "norm! i\\<C-X>\\<C-V>"', '--cmd', 'qa!')
+ eq(0, p.status)
+ end)
+
+ it('does not crash when running completion from -l script', function()
+ local lua_fname = 'Xinscompl.lua'
+ write_file(lua_fname, [=[vim.cmd([[exe "norm! i\<C-X>\<C-V>"]])]=])
+ finally(function()
+ os.remove(lua_fname)
+ end)
+ local p = n.spawn_wait('--clean', '-l', lua_fname)
+ eq(0, p.status)
end)
it('does not crash after reading from stdin in non-headless mode', function()
skip(is_os('win'))
local screen = Screen.new(40, 8)
local args = {
- nvim_prog_abs(),
+ n.nvim_prog,
'-u',
'NONE',
'-i',
@@ -103,7 +100,8 @@ describe('command-line option', function()
-- Need to explicitly pipe to stdin so that the embedded Nvim instance doesn't try to read
-- data from the terminal #18181
- fn.termopen(string.format([[echo "" | %s]], table.concat(args, ' ')), {
+ fn.jobstart(string.format([[echo "" | %s]], table.concat(args, ' ')), {
+ term = true,
env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
})
screen:expect(
@@ -120,7 +118,7 @@ describe('command-line option', function()
feed('i:cq<CR>')
screen:expect([[
|
- [Process exited 1]{2: } |
+ [Process exited 1]^ |
|*5
{5:-- TERMINAL --} |
]])
@@ -137,60 +135,49 @@ describe('command-line option', function()
]=]
end)
- it('errors out when trying to use nonexistent file with -s', function()
+ it('fails when trying to use nonexistent file with -s', function()
+ local p = n.spawn_wait(
+ '--cmd',
+ 'set noswapfile shortmess+=IFW fileformats=unix',
+ '--cmd',
+ 'language C',
+ '-s',
+ nonexistent_fname
+ )
eq(
'Cannot open for reading: "' .. nonexistent_fname .. '": no such file or directory\n',
- fn.system({
- nvim_prog_abs(),
- '-u',
- 'NONE',
- '-i',
- 'NONE',
- '--headless',
- '--cmd',
- 'set noswapfile shortmess+=IFW fileformats=unix',
- '--cmd',
- 'language C',
- '-s',
- nonexistent_fname,
- })
+ --- TODO(justinmk): using `p.output` because Nvim emits CRLF even on non-Win. Emit LF instead?
+ p:output()
)
- eq(2, eval('v:shell_error'))
+ eq(2, p.status)
end)
it('errors out when trying to use -s twice', function()
write_file(fname, ':call setline(1, "1")\n:wqall!\n')
write_file(dollar_fname, ':call setline(1, "2")\n:wqall!\n')
- eq(
- 'Attempt to open script file again: "-s ' .. dollar_fname .. '"\n',
- fn.system({
- nvim_prog_abs(),
- '-u',
- 'NONE',
- '-i',
- 'NONE',
- '--headless',
- '--cmd',
- 'set noswapfile shortmess+=IFW fileformats=unix',
- '--cmd',
- 'language C',
- '-s',
- fname,
- '-s',
- dollar_fname,
- fname_2,
- })
+ local p = n.spawn_wait(
+ '--cmd',
+ 'set noswapfile shortmess+=IFW fileformats=unix',
+ '--cmd',
+ 'language C',
+ '-s',
+ fname,
+ '-s',
+ dollar_fname,
+ fname_2
)
- eq(2, eval('v:shell_error'))
+ --- TODO(justinmk): using `p.output` because Nvim emits CRLF even on non-Win. Emit LF instead?
+ eq('Attempt to open script file again: "-s ' .. dollar_fname .. '"\n', p:output())
+ eq(2, p.status)
eq(nil, uv.fs_stat(fname_2))
end)
end)
it('nvim -v, :version', function()
matches('Run ":verbose version"', fn.execute(':version'))
- matches('Compilation: .*Run :checkhealth', fn.execute(':verbose version'))
- matches('Run "nvim %-V1 %-v"', fn.system({ nvim_prog_abs(), '-v' }))
- matches('Compilation: .*Run :checkhealth', fn.system({ nvim_prog_abs(), '-V1', '-v' }))
+ matches('fall%-back for %$VIM: .*Run :checkhealth', fn.execute(':verbose version'))
+ matches('Run "nvim %-V1 %-v"', n.spawn_wait('-v').stdout)
+ matches('fall%-back for %$VIM: .*Run :checkhealth', n.spawn_wait('-V1', '-v').stdout)
end)
if is_os('win') then
@@ -204,7 +191,7 @@ describe('command-line option', function()
eq(
'some text',
fn.system({
- nvim_prog_abs(),
+ n.nvim_prog,
'-es',
'+%print',
'+q',