aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-07-18 19:37:18 +0000
committerJosh Rahm <rahm@google.com>2022-07-18 19:37:18 +0000
commit308e1940dcd64aa6c344c403d4f9e0dda58d9c5c (patch)
tree35fe43e01755e0f312650667004487a44d6b7941 /test/functional/core
parent96a00c7c588b2f38a2424aeeb4ea3581d370bf2d (diff)
parente8c94697bcbe23a5c7b07c292b90a6b70aadfa87 (diff)
downloadrneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.gz
rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.tar.bz2
rneovim-308e1940dcd64aa6c344c403d4f9e0dda58d9c5c.zip
Merge remote-tracking branch 'upstream/master' into rahm
Diffstat (limited to 'test/functional/core')
-rw-r--r--test/functional/core/channels_spec.lua53
-rw-r--r--test/functional/core/fileio_spec.lua75
-rw-r--r--test/functional/core/job_spec.lua89
-rw-r--r--test/functional/core/log_spec.lua57
-rw-r--r--test/functional/core/main_spec.lua12
-rw-r--r--test/functional/core/remote_spec.lua142
-rw-r--r--test/functional/core/startup_spec.lua51
7 files changed, 438 insertions, 41 deletions
diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua
index 93dec9fb35..ca52404d3b 100644
--- a/test/functional/core/channels_spec.lua
+++ b/test/functional/core/channels_spec.lua
@@ -10,6 +10,8 @@ local nvim_prog = helpers.nvim_prog
local is_os = helpers.is_os
local retry = helpers.retry
local expect_twostreams = helpers.expect_twostreams
+local assert_alive = helpers.assert_alive
+local pcall_err = helpers.pcall_err
describe('channels', function()
local init = [[
@@ -100,6 +102,38 @@ describe('channels', function()
eq({"notification", "exit", {3,0}}, next_msg())
end)
+ it('can use stdio channel and on_print callback', function()
+ source([[
+ let g:job_opts = {
+ \ 'on_stdout': function('OnEvent'),
+ \ 'on_stderr': function('OnEvent'),
+ \ 'on_exit': function('OnEvent'),
+ \ }
+ ]])
+ meths.set_var("nvim_prog", nvim_prog)
+ meths.set_var("code", [[
+ function! OnStdin(id, data, event) dict
+ echo string([a:id, a:data, a:event])
+ if a:data == ['']
+ quit
+ endif
+ endfunction
+ function! OnPrint(text) dict
+ call chansend(g:x, ['OnPrint:' .. a:text])
+ endfunction
+ let g:x = stdioopen({'on_stdin': funcref('OnStdin'), 'on_print':'OnPrint'})
+ call chansend(x, "hello")
+ ]])
+ command("let g:id = jobstart([ g:nvim_prog, '-u', 'NONE', '-i', 'NONE', '--cmd', 'set noswapfile', '--headless', '--cmd', g:code], g:job_opts)")
+ local id = eval("g:id")
+ ok(id > 0)
+
+ eq({ "notification", "stdout", {id, { "hello" } } }, next_msg())
+
+ command("call chansend(id, 'howdy')")
+ eq({"notification", "stdout", {id, {"OnPrint:[1, ['howdy'], 'stdin']"}}}, next_msg())
+ end)
+
local function expect_twoline(id, stream, line1, line2, nobr)
local msg = next_msg()
local joined = nobr and {line1..line2} or {line1, line2}
@@ -282,3 +316,22 @@ describe('channels', function()
eq({"notification", "exit", {id, 1, {''}}}, next_msg())
end)
end)
+
+describe('loopback', function()
+ before_each(function()
+ clear()
+ command("let chan = sockconnect('pipe', v:servername, {'rpc': v:true})")
+ end)
+
+ it('does not crash when sending raw data', function()
+ eq("Vim(call):Can't send raw data to rpc channel",
+ pcall_err(command, "call chansend(chan, 'test')"))
+ assert_alive()
+ end)
+
+ it('are released when closed', function()
+ local chans = eval('len(nvim_list_chans())')
+ command('call chanclose(chan)')
+ eq(chans - 1, eval('len(nvim_list_chans())'))
+ end)
+end)
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua
index c68bc18eed..a4d22685e8 100644
--- a/test/functional/core/fileio_spec.lua
+++ b/test/functional/core/fileio_spec.lua
@@ -1,27 +1,34 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_log = helpers.assert_log
+local assert_nolog = helpers.assert_nolog
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
+local ok = helpers.ok
local feed = helpers.feed
local funcs = helpers.funcs
local nvim_prog = helpers.nvim_prog
local request = helpers.request
local retry = helpers.retry
local rmdir = helpers.rmdir
+local matches = helpers.matches
local mkdir = helpers.mkdir
local sleep = helpers.sleep
local read_file = helpers.read_file
+local tmpname = helpers.tmpname
local trim = helpers.trim
local currentdir = helpers.funcs.getcwd
local iswin = helpers.iswin
local assert_alive = helpers.assert_alive
+local expect_exit = helpers.expect_exit
+local write_file = helpers.write_file
describe('fileio', function()
before_each(function()
end)
after_each(function()
- command(':qall!')
+ expect_exit(command, ':qall!')
os.remove('Xtest_startup_shada')
os.remove('Xtest_startup_file1')
os.remove('Xtest_startup_file1~')
@@ -139,3 +146,69 @@ describe('fileio', function()
end)
end)
+describe('tmpdir', function()
+ local tmproot_pat = [=[.*[/\\]nvim%.[^/\\]+]=]
+ local testlog = 'Xtest_tmpdir_log'
+ local faketmp
+
+ before_each(function()
+ -- Fake /tmp dir so that we can mess it up.
+ faketmp = tmpname()
+ os.remove(faketmp)
+ mkdir(faketmp)
+ end)
+
+ after_each(function()
+ expect_exit(command, ':qall!')
+ os.remove(testlog)
+ end)
+
+ it('failure modes', function()
+ clear({ env={ NVIM_LOG_FILE=testlog, TMPDIR=faketmp, } })
+ assert_nolog('tempdir is not a directory', testlog)
+ assert_nolog('tempdir has invalid permissions', testlog)
+
+ -- Tempfiles typically look like: "…/nvim.<user>/xxx/0".
+ -- - "…/nvim.<user>/xxx/" is the per-process tmpdir, not shared with other Nvims.
+ -- - "…/nvim.<user>/" is the tmpdir root, shared by all Nvims (normally).
+ local tmproot = (funcs.tempname()):match(tmproot_pat)
+ ok(tmproot:len() > 4, 'tmproot like "nvim.foo"', tmproot)
+
+ -- Test how Nvim handles invalid tmpdir root (by hostile users or accidents).
+ --
+ -- "…/nvim.<user>/" is not a directory:
+ expect_exit(command, ':qall!')
+ rmdir(tmproot)
+ write_file(tmproot, '') -- Not a directory, vim_mktempdir() should skip it.
+ clear({ env={ NVIM_LOG_FILE=testlog, TMPDIR=faketmp, } })
+ matches(tmproot_pat, funcs.stdpath('run')) -- Tickle vim_mktempdir().
+ -- Assert that broken tmpdir root was handled.
+ retry(nil, 1000, function()
+ assert_log('tempdir root not a directory', testlog, 100)
+ end)
+
+ -- "…/nvim.<user>/" has wrong permissions:
+ if iswin() then
+ return -- TODO(justinmk): need setfperm/getfperm on Windows. #8244
+ end
+ os.remove(testlog)
+ os.remove(tmproot)
+ mkdir(tmproot)
+ funcs.setfperm(tmproot, 'rwxr--r--') -- Invalid permissions, vim_mktempdir() should skip it.
+ clear({ env={ NVIM_LOG_FILE=testlog, TMPDIR=faketmp, } })
+ matches(tmproot_pat, funcs.stdpath('run')) -- Tickle vim_mktempdir().
+ -- Assert that broken tmpdir root was handled.
+ retry(nil, 1000, function()
+ assert_log('tempdir root has invalid permissions', testlog, 100)
+ end)
+ end)
+
+ it('too long', function()
+ local bigname = ('%s/%s'):format(faketmp, ('x'):rep(666))
+ mkdir(bigname)
+ clear({ env={ NVIM_LOG_FILE=testlog, TMPDIR=bigname, } })
+ matches(tmproot_pat, funcs.stdpath('run')) -- Tickle vim_mktempdir().
+ local len = (funcs.tempname()):len()
+ ok(len > 4 and len < 256, '4 < len < 256', tostring(len))
+ end)
+end)
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 5e127bce26..04fbb807be 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, eval, exc_exec, feed_command, feed, insert, neq, next_msg, nvim,
- nvim_dir, ok, source, write_file, mkdir, rmdir = helpers.clear,
+ testprg, ok, source, write_file, mkdir, rmdir = helpers.clear,
helpers.eq, helpers.eval, helpers.exc_exec, helpers.feed_command, helpers.feed,
helpers.insert, helpers.neq, helpers.next_msg, helpers.nvim,
- helpers.nvim_dir, helpers.ok, helpers.source,
+ helpers.testprg, helpers.ok, helpers.source,
helpers.write_file, helpers.mkdir, helpers.rmdir
local assert_alive = helpers.assert_alive
local command = helpers.command
@@ -16,6 +16,7 @@ local poke_eventloop = helpers.poke_eventloop
local iswin = helpers.iswin
local get_pathsep = helpers.get_pathsep
local pathroot = helpers.pathroot
+local exec_lua = helpers.exec_lua
local nvim_set = helpers.nvim_set
local expect_twostreams = helpers.expect_twostreams
local expect_msg_seq = helpers.expect_msg_seq
@@ -72,12 +73,20 @@ describe('jobs', function()
nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]])
end
- expect_msg_seq({
- {'notification', 'stdout', {0, {'hello world abc', ''}}},
- })
+ expect_msg_seq(
+ {
+ {'notification', 'stdout', {0, {'hello world abc'}}},
+ {'notification', 'stdout', {0, {'', ''}}},
+ },
+ {
+ {'notification', 'stdout', {0, {'hello world abc', ''}}},
+ {'notification', 'stdout', {0, {''}}}
+ }
+ )
end)
it('append environment with pty #env', function()
+ if helpers.pending_win32(pending) then return end
nvim('command', "let $VAR = 'abc'")
nvim('command', "let $TOTO = 'goodbye world'")
nvim('command', "let g:job_opts.pty = v:true")
@@ -87,9 +96,16 @@ describe('jobs', function()
else
nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]])
end
- expect_msg_seq({
- {'notification', 'stdout', {0, {'hello world abc', ''}}},
- })
+ expect_msg_seq(
+ {
+ {'notification', 'stdout', {0, {'hello world abc'}}},
+ {'notification', 'stdout', {0, {'', ''}}},
+ },
+ {
+ {'notification', 'stdout', {0, {'hello world abc', ''}}},
+ {'notification', 'stdout', {0, {''}}}
+ }
+ )
end)
it('replace environment #env', function()
@@ -207,7 +223,7 @@ describe('jobs', function()
ok(string.find(err, "E475: Invalid argument: expected valid directory$") ~= nil)
end)
- it('produces error when using non-executable `cwd`', function()
+ it('error on non-executable `cwd`', function()
if iswin() then return end -- N/A for Windows
local dir = 'Xtest_not_executable_dir'
@@ -248,7 +264,7 @@ describe('jobs', function()
eq({'notification', 'exit', {0, 0}}, next_msg())
end)
- it('allows interactive commands', function()
+ it('interactive commands', function()
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
neq(0, eval('j'))
nvim('command', 'call jobsend(j, "abc\\n")')
@@ -294,13 +310,7 @@ describe('jobs', function()
nvim('command', "call jobstop(j)")
end)
- it("will not buffer data if it doesn't end in newlines", function()
- if helpers.isCI('travis') and os.getenv('CC') == 'gcc-4.9'
- and helpers.is_os('mac') then
- -- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
- pending("[Hangs on Travis macOS. #5002]")
- end
-
+ it("emits partial lines (does NOT buffer data lacking newlines)", function()
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
nvim('command', 'call jobsend(j, "abc\\nxyz")')
eq({'notification', 'stdout', {0, {'abc', 'xyz'}}}, next_msg())
@@ -383,7 +393,7 @@ describe('jobs', function()
eq(NIL, meths.get_proc(pid))
end)
- it("do not survive the exit of nvim", function()
+ it("disposed on Nvim exit", function()
-- use sleep, which doesn't die on stdin close
nvim('command', "let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)")
local pid = eval('jobpid(g:j)')
@@ -651,6 +661,44 @@ describe('jobs', function()
)
end)
+ it('jobstart() environment: $NVIM, $NVIM_LISTEN_ADDRESS #11009', function()
+ local function get_env_in_child_job(envname, env)
+ return exec_lua([[
+ local envname, env = ...
+ local join = function(s) return vim.fn.join(s, '') end
+ local stdout = {}
+ local stderr = {}
+ local opt = {
+ env = env,
+ stdout_buffered = true,
+ stderr_buffered = true,
+ on_stderr = function(chan, data, name) stderr = data end,
+ on_stdout = function(chan, data, name) stdout = data end,
+ }
+ local j1 = vim.fn.jobstart({ vim.v.progpath, '-es', '-V1',( '+echo "%s="..getenv("%s")'):format(envname, envname), '+qa!' }, opt)
+ vim.fn.jobwait({ j1 }, 10000)
+ return join({ join(stdout), join(stderr) })
+ ]],
+ envname,
+ env)
+ end
+
+ local addr = eval('v:servername')
+ ok((addr):len() > 0)
+ -- $NVIM is _not_ defined in the top-level Nvim process.
+ eq('', eval('$NVIM'))
+ -- jobstart() shares its v:servername with the child via $NVIM.
+ eq('NVIM='..addr, get_env_in_child_job('NVIM'))
+ -- $NVIM_LISTEN_ADDRESS is unset by server_init in the child.
+ eq('NVIM_LISTEN_ADDRESS=null', get_env_in_child_job('NVIM_LISTEN_ADDRESS'))
+ eq('NVIM_LISTEN_ADDRESS=null', get_env_in_child_job('NVIM_LISTEN_ADDRESS',
+ { NVIM_LISTEN_ADDRESS='Xtest_jobstart_env' }))
+ -- User can explicitly set $NVIM_LOG_FILE, $VIM, $VIMRUNTIME.
+ eq('NVIM_LOG_FILE=Xtest_jobstart_env',
+ get_env_in_child_job('NVIM_LOG_FILE', { NVIM_LOG_FILE='Xtest_jobstart_env' }))
+ os.remove('Xtest_jobstart_env')
+ end)
+
describe('jobwait', function()
before_each(function()
if iswin() then
@@ -1009,8 +1057,7 @@ describe('jobs', function()
return a:data
endfunction
]])
- local ext = iswin() and '.exe' or ''
- insert(nvim_dir..'/tty-test'..ext) -- Full path to tty-test.
+ insert(testprg('tty-test'))
nvim('command', 'let g:job_opts.pty = 1')
nvim('command', 'let exec = [expand("<cfile>:p")]')
nvim('command', "let j = jobstart(exec, g:job_opts)")
@@ -1043,7 +1090,7 @@ describe('jobs', function()
local other_jobid = eval("jobstart(['cat', '-'], g:job_opts)")
local other_pid = eval('jobpid(' .. other_jobid .. ')')
- -- Other job doesn't block first job from recieving SIGHUP on jobclose()
+ -- Other job doesn't block first job from receiving SIGHUP on jobclose()
command('call jobclose(j)')
-- Have to wait so that the SIGHUP can be processed by tty-test on time.
-- Can't wait for the next message in case this test fails, if it fails
diff --git a/test/functional/core/log_spec.lua b/test/functional/core/log_spec.lua
new file mode 100644
index 0000000000..3b1ccd9559
--- /dev/null
+++ b/test/functional/core/log_spec.lua
@@ -0,0 +1,57 @@
+local helpers = require('test.functional.helpers')(after_each)
+local assert_log = helpers.assert_log
+local clear = helpers.clear
+local command = helpers.command
+local eq = helpers.eq
+local exec_lua = helpers.exec_lua
+local expect_exit = helpers.expect_exit
+local request = helpers.request
+local retry = helpers.retry
+
+describe('log', function()
+ local testlog = 'Xtest_logging'
+
+ after_each(function()
+ expect_exit(command, 'qa!')
+ os.remove(testlog)
+ end)
+
+ it('skipped before log_init', function()
+ -- This test is for _visibility_: adjust as needed, after checking for regression.
+ --
+ -- During startup some components may try to log before logging is setup.
+ -- That should be uncommon (ideally never)--and if there are MANY such
+ -- calls, that needs investigation.
+ clear()
+ eq(0, request('nvim__stats').log_skip)
+ clear{env={CDPATH='~doesnotexist'}}
+ assert(request('nvim__stats').log_skip <= 13)
+ end)
+
+ it('messages are formatted with name or test id', function()
+ -- Examples:
+ -- ERR 2022-05-29T12:30:03.800 T2 log_init:110: test log message
+ -- ERR 2022-05-29T12:30:03.814 T2/child log_init:110: test log message
+
+ clear({env={
+ NVIM_LOG_FILE=testlog,
+ -- TODO: remove this after nvim_log #7062 is merged.
+ __NVIM_TEST_LOG='1'
+ }})
+
+ local tid = _G._nvim_test_id
+ retry(nil, 1000, function()
+ assert_log(tid..'%.%d+%.%d +server_init:%d+: test log message', testlog, 100)
+ end)
+
+ exec_lua([[
+ local j1 = vim.fn.jobstart({ vim.v.progpath, '-es', '-V1', '+foochild', '+qa!' }, vim.empty_dict())
+ vim.fn.jobwait({ j1 }, 10000)
+ ]])
+
+ -- Child Nvim spawned by jobstart() appends "/c" to parent name.
+ retry(nil, 1000, function()
+ assert_log('%.%d+%.%d/c +server_init:%d+: test log message', testlog, 100)
+ end)
+ end)
+end)
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua
index 37a9f0b836..f6fb859ccc 100644
--- a/test/functional/core/main_spec.lua
+++ b/test/functional/core/main_spec.lua
@@ -52,11 +52,15 @@ describe('Command-line option', function()
if helpers.pending_win32(pending) then return end
local screen = Screen.new(40, 8)
screen:attach()
- funcs.termopen({
+ local args = {
nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE',
- '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
- '-s', '-'
- })
+ '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix',
+ '-s', '-'
+ }
+
+ -- Need to explicitly pipe to stdin so that the embedded Nvim instance doesn't try to read
+ -- data from the terminal #18181
+ funcs.termopen(string.format([[echo "" | %s]], table.concat(args, " ")))
screen:expect([[
^ |
{1:~ }|
diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua
new file mode 100644
index 0000000000..d7bd075eb2
--- /dev/null
+++ b/test/functional/core/remote_spec.lua
@@ -0,0 +1,142 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local clear = helpers.clear
+local command = helpers.command
+local eq = helpers.eq
+local expect = helpers.expect
+local funcs = helpers.funcs
+local insert = helpers.insert
+local meths = helpers.meths
+local new_argv = helpers.new_argv
+local neq = helpers.neq
+local set_session = helpers.set_session
+local spawn = helpers.spawn
+local tmpname = helpers.tmpname
+local write_file = helpers.write_file
+
+describe('Remote', function()
+ local fname, other_fname
+ local contents = 'The call is coming from outside the process'
+ local other_contents = "A second file's contents"
+
+ before_each(function()
+ fname = tmpname() .. ' with spaces in the filename'
+ other_fname = tmpname()
+ write_file(fname, contents)
+ write_file(other_fname, other_contents)
+ end)
+
+ describe('connect to server and', function()
+ local server
+ before_each(function()
+ server = spawn(new_argv(), true)
+ set_session(server)
+ end)
+
+ after_each(function()
+ server:close()
+ end)
+
+ local function run_remote(...)
+ set_session(server)
+ local addr = funcs.serverlist()[1]
+ local client_argv = new_argv({args={'--server', addr, ...}})
+
+ -- 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.
+ local client_starter = spawn(new_argv(), false, nil, true)
+ set_session(client_starter)
+ local client_job_id = funcs.jobstart(client_argv)
+ eq({ 0 }, funcs.jobwait({client_job_id}))
+ client_starter:close()
+ set_session(server)
+ end
+
+ it('edit a single file', function()
+ run_remote('--remote', fname)
+ expect(contents)
+ eq(2, #funcs.getbufinfo())
+ end)
+
+ it('tab edit a single file with a non-changed buffer', function()
+ run_remote('--remote-tab', fname)
+ expect(contents)
+ eq(1, #funcs.gettabinfo())
+ end)
+
+ it('tab edit a single file with a changed buffer', function()
+ insert('hello')
+ run_remote('--remote-tab', fname)
+ expect(contents)
+ eq(2, #funcs.gettabinfo())
+ end)
+
+ it('edit multiple files', function()
+ run_remote('--remote', fname, other_fname)
+ expect(contents)
+ command('next')
+ expect(other_contents)
+ eq(3, #funcs.getbufinfo())
+ end)
+
+ it('send keys', function()
+ run_remote('--remote-send', ':edit '..fname..'<CR><C-W>v')
+ expect(contents)
+ eq(2, #funcs.getwininfo())
+ -- Only a single buffer as we're using edit and not drop like --remote does
+ eq(1, #funcs.getbufinfo())
+ end)
+
+ it('evaluate expressions', function()
+ run_remote('--remote-expr', 'setline(1, "Yo")')
+ expect('Yo')
+ end)
+ end)
+
+ it('creates server if not found', function()
+ clear('--remote', fname)
+ expect(contents)
+ eq(1, #funcs.getbufinfo())
+ -- Since we didn't pass silent, we should get a complaint
+ neq(nil, string.find(meths.exec('messages', true), 'E247'))
+ end)
+
+ it('creates server if not found with tabs', function()
+ clear('--remote-tab-silent', fname, other_fname)
+ expect(contents)
+ eq(2, #funcs.gettabinfo())
+ eq(2, #funcs.getbufinfo())
+ -- We passed silent, so no message should be issued about the server not being found
+ eq(nil, string.find(meths.exec('messages', true), 'E247'))
+ end)
+
+ pending('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()
+ local bogus_job_id = funcs.jobstart(bogus_argv)
+ eq({2}, funcs.jobwait({bogus_job_id}))
+ end
+ it('bogus subcommand', function()
+ run_and_check_exit_code('--remote-bogus')
+ end)
+
+ it('send without server', function()
+ run_and_check_exit_code('--remote-send', 'i')
+ end)
+
+ it('expr without server', function()
+ run_and_check_exit_code('--remote-expr', 'setline(1, "Yo")')
+ end)
+ it('wait subcommand', function()
+ run_and_check_exit_code('--remote-wait', fname)
+ end)
+ end)
+end)
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 2fa84e8313..4f9df4010e 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local assert_alive = helpers.assert_alive
+local assert_log = helpers.assert_log
local clear = helpers.clear
local command = helpers.command
local ok = helpers.ok
@@ -23,6 +24,29 @@ local iswin = helpers.iswin
local startswith = helpers.startswith
local write_file = helpers.write_file
local meths = helpers.meths
+local alter_slashes = helpers.alter_slashes
+
+local testfile = 'Xtest_startuptime'
+after_each(function()
+ os.remove(testfile)
+end)
+
+describe('startup', function()
+ it('--clean', function()
+ clear()
+ ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) ~= nil)
+ clear('--clean')
+ ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) == nil)
+ end)
+
+ it('--startuptime', function()
+ clear({ args = {'--startuptime', testfile}})
+ retry(nil, 1000, function()
+ assert_log('sourcing', testfile, 100)
+ assert_log("require%('vim%._editor'%)", testfile, 100)
+ end)
+ end)
+end)
describe('startup', function()
before_each(function()
@@ -255,6 +279,7 @@ describe('startup', function()
it('does not crash when expanding cdpath during early_init', function()
clear{env={CDPATH='~doesnotexist'}}
+ assert_alive()
eq(',~doesnotexist', eval('&cdpath'))
end)
@@ -355,7 +380,7 @@ describe('startup', function()
end)
it("handles :packadd during startup", function()
- -- control group: opt/bonus is not availabe by default
+ -- control group: opt/bonus is not available by default
pack_clear [[
try
let g:x = bonus#secret()
@@ -398,7 +423,8 @@ describe('startup', function()
eq({'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
local rtp = meths.get_option'rtp'
- ok(startswith(rtp, 'test/functional/fixtures/nvim,test/functional/fixtures/pack/*/start/*,test/functional/fixtures/start/*,test/functional/fixtures,test/functional/fixtures/middle,'), 'rtp='..rtp)
+ ok(startswith(rtp, 'test/functional/fixtures/nvim,test/functional/fixtures/pack/*/start/*,test/functional/fixtures/start/*,test/functional/fixtures,test/functional/fixtures/middle,'),
+ 'startswith(…)', 'rtp='..rtp)
end)
it("handles the correct order with opt packages and after/", function()
@@ -492,22 +518,24 @@ describe('sysinit', function()
it('fixed hang issue with -D (#12647)', function()
local screen
- screen = Screen.new(60, 6)
+ screen = Screen.new(60, 7)
screen:attach()
command([[let g:id = termopen('"]]..nvim_prog..
[[" -u NONE -i NONE --cmd "set noruler" -D')]])
screen:expect([[
^ |
Entering Debug mode. Type "cont" to continue. |
- cmd: augroup nvim_terminal |
+ nvim_exec() |
+ cmd: aunmenu * |
> |
- <" -u NONE -i NONE --cmd "set noruler" -D 1,0-1 All|
+ <" -u NONE -i NONE --cmd "set noruler" -D 1,1 All|
|
]])
command([[call chansend(g:id, "cont\n")]])
screen:expect([[
^ |
~ |
+ ~ |
[No Name] |
|
<" -u NONE -i NONE --cmd "set noruler" -D 1,0-1 All|
@@ -516,13 +544,6 @@ describe('sysinit', function()
end)
end)
-describe('clean', function()
- clear()
- ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) ~= nil)
- clear('--clean')
- ok(string.find(meths.get_option('runtimepath'), funcs.stdpath('config'), 1, true) == nil)
-end)
-
describe('user config init', function()
local xhome = 'Xhome'
local pathsep = helpers.get_pathsep()
@@ -577,7 +598,7 @@ describe('user config init', function()
it('loads default lua config, but shows an error', function()
clear{ args_rm={'-u'}, env=xenv }
- feed('<cr>') -- confirm "Conflicting config ..." message
+ feed('<cr><c-c>') -- Dismiss "Conflicting config …" message.
eq(1, eval('g:lua_rc'))
matches('^E5422: Conflicting configs', meths.exec('messages', true))
end)
@@ -629,13 +650,13 @@ describe('runtime:', function()
eq(2, eval('g:lua_plugin'))
-- Check if plugin_file_path is listed in :scriptname
local scripts = meths.exec(':scriptnames', true)
- assert.Truthy(scripts:find(plugin_file_path))
+ assert(scripts:find(plugin_file_path))
-- Check if plugin_file_path is listed in startup profile
local profile_reader = io.open(profiler_file, 'r')
local profile_log = profile_reader:read('*a')
profile_reader:close()
- assert.Truthy(profile_log :find(plugin_file_path))
+ assert(profile_log:find(plugin_file_path))
os.remove(profiler_file)
rmdir(plugin_path)