diff options
Diffstat (limited to 'test/functional/core')
-rw-r--r-- | test/functional/core/channels_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/core/exit_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/core/fileio_spec.lua | 13 | ||||
-rw-r--r-- | test/functional/core/job_spec.lua | 84 | ||||
-rw-r--r-- | test/functional/core/log_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/core/main_spec.lua | 117 | ||||
-rw-r--r-- | test/functional/core/remote_spec.lua | 18 | ||||
-rw-r--r-- | test/functional/core/startup_spec.lua | 129 |
8 files changed, 210 insertions, 166 deletions
diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua index dee13d19ae..7b10eb05ef 100644 --- a/test/functional/core/channels_spec.lua +++ b/test/functional/core/channels_spec.lua @@ -5,7 +5,6 @@ local clear, eq, eval, next_msg, ok, source = n.clear, t.eq, n.eval, n.next_msg, local command, fn, api = n.command, n.fn, n.api local matches = t.matches local sleep = vim.uv.sleep -local spawn, nvim_argv = n.spawn, n.nvim_argv local get_session, set_session = n.get_session, n.set_session local nvim_prog = n.nvim_prog local is_os = t.is_os @@ -33,10 +32,10 @@ describe('channels', function() end) pending('can connect to socket', function() - local server = spawn(nvim_argv, nil, nil, true) + local server = n.new_session(true) set_session(server) local address = fn.serverlist()[1] - local client = spawn(nvim_argv, nil, nil, true) + local client = n.new_session(true) set_session(client) source(init) @@ -63,7 +62,7 @@ describe('channels', function() it('dont crash due to garbage in rpc #23781', function() local client = get_session() - local server = spawn(nvim_argv, nil, nil, true) + local server = n.new_session(true) set_session(server) local address = fn.serverlist()[1] set_session(client) diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua index 34c3eedbd2..65f6bc28a6 100644 --- a/test/functional/core/exit_spec.lua +++ b/test/functional/core/exit_spec.lua @@ -8,8 +8,6 @@ local feed = n.feed local eval = n.eval local eq = t.eq local run = n.run -local fn = n.fn -local nvim_prog = n.nvim_prog local pcall_err = t.pcall_err local exec_capture = n.exec_capture local poke_eventloop = n.poke_eventloop @@ -69,8 +67,8 @@ describe(':cquit', function() poke_eventloop() assert_alive() else - fn.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', '--cmd', cmdline }) - eq(exit_code, eval('v:shell_error')) + local p = n.spawn_wait('--cmd', cmdline) + eq(exit_code, p.status) end end diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index cf9715f848..b1a8e21762 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -31,7 +31,6 @@ local feed_command = n.feed_command local skip = t.skip local is_os = t.is_os local is_ci = t.is_ci -local spawn = n.spawn local set_session = n.set_session describe('fileio', function() @@ -51,12 +50,11 @@ describe('fileio', function() rmdir('Xtest_backupdir with spaces') end) - local args = { nvim_prog, '--clean', '--cmd', 'set nofsync directory=Xtest_startup_swapdir' } + local args = { '--clean', '--cmd', 'set nofsync directory=Xtest_startup_swapdir' } --- Starts a new nvim session and returns an attached screen. - local function startup(extra_args) - extra_args = extra_args or {} - local argv = vim.iter({ args, '--embed', extra_args }):flatten():totable() - local screen_nvim = spawn(argv) + local function startup() + local argv = vim.iter({ args, '--embed' }):flatten():totable() + local screen_nvim = n.new_session(false, { args = argv, merge = false }) set_session(screen_nvim) local screen = Screen.new(70, 10) screen:set_default_attr_ids({ @@ -100,7 +98,8 @@ describe('fileio', function() eq('foozubbaz', trim(read_file('Xtest_startup_file1'))) -- 4. Exit caused by deadly signal (+ 'swapfile'). - local j = fn.jobstart(vim.iter({ args, '--embed' }):flatten():totable(), { rpc = true }) + local j = + fn.jobstart(vim.iter({ nvim_prog, args, '--embed' }):flatten():totable(), { rpc = true }) fn.rpcrequest( j, 'nvim_exec2', diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 618c294566..e833b5127d 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -65,6 +65,39 @@ describe('jobs', function() ]]) end) + it('validation', function() + matches( + "E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set", + pcall_err(command, "call jobstart(['cat', '-'], { 'pty': v:true, 'rpc': v:true })") + ) + matches( + 'E475: Invalid argument: expected valid directory', + pcall_err(command, "call jobstart(['cat', '-'], { 'cwd': 9313843 })") + ) + matches( + 'E475: Invalid argument: expected valid directory', + pcall_err(command, "call jobstart(['cat', '-'], { 'cwd': 'bogusssssss/bogus' })") + ) + matches( + "E475: Invalid argument: 'term' must be Boolean", + pcall_err(command, "call jobstart(['cat', '-'], { 'term': 'bogus' })") + ) + matches( + "E475: Invalid argument: 'term' must be Boolean", + pcall_err(command, "call jobstart(['cat', '-'], { 'term': 1 })") + ) + command('set modified') + matches( + vim.pesc('jobstart(...,{term=true}) requires unmodified buffer'), + pcall_err(command, "call jobstart(['cat', '-'], { 'term': v:true })") + ) + + -- Non-failure cases: + command('set nomodified') + command("call jobstart(['cat', '-'], { 'term': v:true })") + command("call jobstart(['cat', '-'], { 'term': v:false })") + end) + it('must specify env option as a dict', function() command('let g:job_opts.env = v:true') local _, err = pcall(function() @@ -940,6 +973,39 @@ describe('jobs', function() feed('<CR>') fn.jobstop(api.nvim_get_var('id')) end) + + it('does not set UI busy with zero timeout #31712', function() + local screen = Screen.new(50, 6) + command([[let g:id = jobstart(['sleep', '0.3'])]]) + local busy = 0 + screen._handle_busy_start = (function(orig) + return function() + orig(screen) + busy = busy + 1 + end + end)(screen._handle_busy_start) + source([[ + func PrintAndPoll() + echon "aaa\nbbb" + call jobwait([g:id], 0) + echon "\nccc" + endfunc + ]]) + feed_command('call PrintAndPoll()') + screen:expect { + grid = [[ + | + {3: }| + aaa | + bbb | + ccc | + {6:Press ENTER or type command to continue}^ | + ]], + } + feed('<CR>') + fn.jobstop(api.nvim_get_var('id')) + eq(0, busy) + end) end) pending('exit event follows stdout, stderr', function() @@ -969,13 +1035,6 @@ describe('jobs', function() eq({ 'notification', 'exit', { 0, 143 } }, next_msg()) end) - it('cannot have both rpc and pty options', function() - command('let g:job_opts.pty = v:true') - command('let g:job_opts.rpc = v:true') - local _, err = pcall(command, "let j = jobstart(['cat', '-'], g:job_opts)") - matches("E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set", err) - end) - it('does not crash when repeatedly failing to start shell', function() source([[ set shell=nosuchshell @@ -1198,7 +1257,7 @@ describe('jobs', function() }) -- Wait for startup to complete, so that all terminal responses are received. screen:expect([[ - {1: } | + ^ | ~ |*3 {1:[No Name] 0,0-1 All}| | @@ -1208,7 +1267,7 @@ describe('jobs', function() feed(':q<CR>') screen:expect([[ | - [Process exited 0]{1: } | + [Process exited 0]^ | |*4 {3:-- TERMINAL --} | ]]) @@ -1230,7 +1289,7 @@ describe('pty process teardown', function() it('does not prevent/delay exit. #4798 #4900', function() skip(fn.executable('sleep') == 0, 'missing "sleep" command') -- Use a nested nvim (in :term) to test without --headless. - fn.termopen({ + fn.jobstart({ n.nvim_prog, '-u', 'NONE', @@ -1243,7 +1302,10 @@ describe('pty process teardown', function() '+terminal', '+!(sleep 300 &)', '+qa', - }, { env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } }) + }, { + term = true, + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, + }) -- Exiting should terminate all descendants (PTY, its children, ...). screen:expect([[ diff --git a/test/functional/core/log_spec.lua b/test/functional/core/log_spec.lua index 57dfd6364c..571bece833 100644 --- a/test/functional/core/log_spec.lua +++ b/test/functional/core/log_spec.lua @@ -46,7 +46,7 @@ describe('log', function() env = env, }) screen:expect([[ - {1: } | + ^ | ~ |*4 | {3:-- TERMINAL --} | 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', diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua index 6cc28ddeef..1cfa0535f6 100644 --- a/test/functional/core/remote_spec.lua +++ b/test/functional/core/remote_spec.lua @@ -10,10 +10,8 @@ local expect = n.expect local fn = n.fn local insert = n.insert local nvim_prog = n.nvim_prog -local new_argv = n.new_argv local neq = t.neq local set_session = n.set_session -local spawn = n.spawn local tmpname = t.tmpname local write_file = t.write_file @@ -32,8 +30,7 @@ describe('Remote', function() describe('connect to server and', function() local server before_each(function() - server = spawn(new_argv(), true) - set_session(server) + server = n.clear() end) after_each(function() @@ -49,7 +46,7 @@ describe('Remote', function() -- to wait for the remote instance to exit and calling jobwait blocks -- the event loop. If the server event loop is blocked, it can't process -- our incoming --remote calls. - local client_starter = spawn(new_argv(), false, nil, true) + local client_starter = n.new_session(true) set_session(client_starter) -- Call jobstart() and jobwait() in the same RPC request to reduce flakiness. eq( @@ -144,15 +141,8 @@ describe('Remote', function() describe('exits with error on', function() local function run_and_check_exit_code(...) - local bogus_argv = new_argv(...) - - -- Create an nvim instance just to run the remote-invoking nvim. We want - -- to wait for the remote instance to exit and calling jobwait blocks - -- the event loop. If the server event loop is blocked, it can't process - -- our incoming --remote calls. - clear() - -- Call jobstart() and jobwait() in the same RPC request to reduce flakiness. - eq({ 2 }, exec_lua([[return vim.fn.jobwait({ vim.fn.jobstart(...) })]], bogus_argv)) + local p = n.spawn_wait { args = { ... } } + eq(2, p.status) end it('bogus subcommand', function() run_and_check_exit_code('--remote-bogus') diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 7062211187..8ecd3dca97 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -55,7 +55,10 @@ describe('startup', function() clear() local screen screen = Screen.new(84, 3) - fn.termopen({ nvim_prog, '-u', 'NONE', '--server', eval('v:servername'), '--remote-ui' }) + fn.jobstart( + { nvim_prog, '-u', 'NONE', '--server', eval('v:servername'), '--remote-ui' }, + { term = true } + ) screen:expect([[ ^Cannot attach UI of :terminal child to its parent. (Unset $NVIM to skip this check) | |*2 @@ -74,22 +77,9 @@ describe('startup', function() end) it('--startuptime does not crash on error #31125', function() - eq( - "E484: Can't open file .", - fn.system({ - nvim_prog, - '-u', - 'NONE', - '-i', - 'NONE', - '--headless', - '--startuptime', - '.', - '-c', - '42cquit', - }) - ) - eq(42, api.nvim_get_vvar('shell_error')) + local p = n.spawn_wait('--startuptime', '.', '-c', '42cquit') + eq("E484: Can't open file .", p.stderr) + eq(42, p.status) end) it('-D does not hang #12647', function() @@ -98,7 +88,7 @@ describe('startup', function() screen = Screen.new(60, 7) -- not the same colors on windows for some reason screen._default_attr_ids = nil - local id = fn.termopen({ + local id = fn.jobstart({ nvim_prog, '-u', 'NONE', @@ -108,6 +98,7 @@ describe('startup', function() 'set noruler', '-D', }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME'), }, @@ -145,13 +136,18 @@ describe('startup', function() vim.list_extend(args, { '-l', (script or 'test/functional/fixtures/startup.lua') }) vim.list_extend(args, lua_args or {}) local out = fn.system(args, input):gsub('\r\n', '\n') - return eq(dedent(expected), out) + if type(expected) == 'function' then + return expected(out) + else + return eq(dedent(expected), out) + end end it('failure modes', function() -- nvim -l <empty> - matches('nvim%.?e?x?e?: Argument missing after: "%-l"', fn.system({ nvim_prog, '-l' })) - eq(1, eval('v:shell_error')) + local proc = n.spawn_wait('-l') + matches('nvim%.?e?x?e?: Argument missing after: "%-l"', proc.stderr) + eq(1, proc.status) end) it('os.exit() sets Nvim exitcode', function() @@ -178,13 +174,13 @@ describe('startup', function() end) it('Lua-error sets Nvim exitcode', function() + local proc = n.spawn_wait('-l', 'test/functional/fixtures/startup-fail.lua') + matches('E5113: .* my pearls!!', proc:output()) + eq(0, proc.signal) + eq(1, proc.status) + eq(0, eval('v:shell_error')) matches( - 'E5113: .* my pearls!!', - fn.system({ nvim_prog, '-l', 'test/functional/fixtures/startup-fail.lua' }) - ) - eq(1, eval('v:shell_error')) - matches( 'E5113: .* %[string "error%("whoa"%)"%]:1: whoa', fn.system({ nvim_prog, '-l', '-' }, 'error("whoa")') ) @@ -291,14 +287,30 @@ describe('startup', function() eq(0, eval('v:shell_error')) end) - it('disables swapfile/shada/config/plugins', function() + it('disables swapfile/shada/config/plugins unless overridden', function() + local script = [[print(('updatecount=%d shadafile=%s loadplugins=%s scripts=%d'):format( + vim.o.updatecount, vim.o.shadafile, tostring(vim.o.loadplugins), math.max(1, #vim.fn.getscriptinfo())))]] + finally(function() + os.remove('Xtest_shada') + end) + assert_l_out( 'updatecount=0 shadafile=NONE loadplugins=false scripts=1\n', nil, nil, '-', - [[print(('updatecount=%d shadafile=%s loadplugins=%s scripts=%d'):format( - vim.o.updatecount, vim.o.shadafile, tostring(vim.o.loadplugins), math.max(1, #vim.fn.getscriptinfo())))]] + script + ) + + -- User can override. + assert_l_out( + function(out) + return matches('updatecount=99 shadafile=Xtest_shada loadplugins=true scripts=2%d\n', out) + end, + { '+set updatecount=99', '-i', 'Xtest_shada', '+set loadplugins', '-u', 'NORC' }, + nil, + '-', + script ) end) end) @@ -343,7 +355,7 @@ describe('startup', function() local screen = Screen.new(25, 3) -- Remote UI connected by --embed. -- TODO: a lot of tests in this file already use the new default color scheme. - -- once we do the batch update of tests to use it, remove this workarond + -- once we do the batch update of tests to use it, remove this workaround screen._default_attr_ids = nil command([[echo has('ttyin') has('ttyout')]]) screen:expect([[ @@ -360,7 +372,7 @@ describe('startup', function() command([[set shellcmdflag=/s\ /c shellxquote=\"]]) end -- Running in :terminal - fn.termopen({ + fn.jobstart({ nvim_prog, '-u', 'NONE', @@ -371,6 +383,7 @@ describe('startup', function() '-c', 'echo has("ttyin") has("ttyout")', }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME'), }, @@ -393,13 +406,14 @@ describe('startup', function() os.remove('Xtest_startup_ttyout') end) -- Running in :terminal - fn.termopen( + fn.jobstart( ( [["%s" -u NONE -i NONE --cmd "%s"]] .. [[ -c "call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')"]] .. [[ -c q | cat -v]] ):format(nvim_prog, nvim_set), { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME'), }, @@ -424,7 +438,7 @@ describe('startup', function() os.remove('Xtest_startup_ttyout') end) -- Running in :terminal - fn.termopen( + fn.jobstart( ( [[echo foo | ]] -- Input from a pipe. .. [["%s" -u NONE -i NONE --cmd "%s"]] @@ -432,6 +446,7 @@ describe('startup', function() .. [[ -c q -- -]] ):format(nvim_prog, nvim_set), { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME'), }, @@ -454,13 +469,14 @@ describe('startup', function() command([[set shellcmdflag=/s\ /c shellxquote=\"]]) end -- Running in :terminal - fn.termopen( + fn.jobstart( ( [[echo foo | ]] .. [["%s" -u NONE -i NONE --cmd "%s"]] .. [[ -c "echo has('ttyin') has('ttyout')"]] ):format(nvim_prog, nvim_set), { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME'), }, @@ -577,19 +593,21 @@ describe('startup', function() eq(' encoding=utf-8\n', fn.system({ nvim_prog, '-n', '-es' }, { 'set encoding', '' })) end) - it('-es/-Es disables swapfile, user config #8540', function() + it('-es/-Es disables swapfile/shada/config #8540', function() for _, arg in ipairs({ '-es', '-Es' }) do local out = fn.system({ nvim_prog, arg, - '+set swapfile? updatecount? shadafile?', + '+set updatecount? shadafile? loadplugins?', '+put =map(getscriptinfo(), {-> v:val.name})', '+%print', }) local line1 = string.match(out, '^.-\n') -- updatecount=0 means swapfile was disabled. - eq(' swapfile updatecount=0 shadafile=\n', line1) - -- Standard plugins were loaded, but not user config. + eq(' updatecount=0 shadafile=NONE loadplugins\n', line1) + -- Standard plugins were loaded, but not user config. #31878 + local nrlines = #vim.split(out, '\n') + ok(nrlines > 20, '>20', nrlines) ok(string.find(out, 'man.lua') ~= nil) ok(string.find(out, 'init.vim') == nil) end @@ -598,15 +616,15 @@ describe('startup', function() it('fails on --embed with -es/-Es/-l', function() matches( 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', - fn.system({ nvim_prog, '--embed', '-es' }) + n.spawn_wait('--embed', '-es').stderr ) matches( 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', - fn.system({ nvim_prog, '--embed', '-Es' }) + n.spawn_wait('--embed', '-Es').stderr ) matches( 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l', - fn.system({ nvim_prog, '--embed', '-l', 'foo.lua' }) + n.spawn_wait('--embed', '-l', 'foo.lua').stderr ) end) @@ -614,7 +632,7 @@ describe('startup', function() local screen screen = Screen.new(60, 6) screen._default_attr_ids = nil - local id = fn.termopen({ + local id = fn.jobstart({ nvim_prog, '-u', 'NONE', @@ -625,6 +643,7 @@ describe('startup', function() '--cmd', 'let g:foo = g:bar', }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME'), }, @@ -689,20 +708,8 @@ describe('startup', function() end) it('get command line arguments from v:argv', function() - local out = fn.system({ - nvim_prog, - '-u', - 'NONE', - '-i', - 'NONE', - '--headless', - '--cmd', - nvim_set, - '-c', - [[echo v:argv[-1:] len(v:argv) > 1]], - '+q', - }) - eq("['+q'] 1", out) + local p = n.spawn_wait('--cmd', nvim_set, '-c', [[echo v:argv[-1:] len(v:argv) > 1]], '+q') + eq("['+q'] 1", p.stderr) end) end) @@ -1144,7 +1151,8 @@ describe('user config init', function() local screen = Screen.new(50, 8) screen._default_attr_ids = nil - fn.termopen({ nvim_prog }, { + fn.jobstart({ nvim_prog }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME'), }, @@ -1153,7 +1161,7 @@ describe('user config init', function() -- `i` to enter Terminal mode, `a` to allow feed('ia') screen:expect([[ - | + ^ | ~ |*4 [No Name] 0,0-1 All| | @@ -1162,7 +1170,7 @@ describe('user config init', function() feed(':echo g:exrc_file<CR>') screen:expect(string.format( [[ - | + ^ | ~ |*4 [No Name] 0,0-1 All| %s%s| @@ -1418,7 +1426,7 @@ describe('inccommand on ex mode', function() clear() local screen screen = Screen.new(60, 10) - local id = fn.termopen({ + local id = fn.jobstart({ nvim_prog, '-u', 'NONE', @@ -1429,6 +1437,7 @@ describe('inccommand on ex mode', function() '-E', 'test/README.md', }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, }) fn.chansend(id, '%s/N') |