aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/core/log_spec.lua24
-rw-r--r--test/functional/helpers.lua15
-rw-r--r--test/functional/terminal/api_spec.lua4
-rw-r--r--test/functional/vimscript/server_spec.lua20
4 files changed, 37 insertions, 26 deletions
diff --git a/test/functional/core/log_spec.lua b/test/functional/core/log_spec.lua
index 8553197305..3b1ccd9559 100644
--- a/test/functional/core/log_spec.lua
+++ b/test/functional/core/log_spec.lua
@@ -1,18 +1,19 @@
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
-local expect_exit = helpers.expect_exit
describe('log', function()
- local test_log_file = 'Xtest_logging'
+ local testlog = 'Xtest_logging'
after_each(function()
- expect_exit('qa!')
- os.remove(test_log_file)
+ expect_exit(command, 'qa!')
+ os.remove(testlog)
end)
it('skipped before log_init', function()
@@ -33,13 +34,14 @@ describe('log', function()
-- ERR 2022-05-29T12:30:03.814 T2/child log_init:110: test log message
clear({env={
- NVIM_LOG_FILE=test_log_file,
- -- TODO: Can remove this after nvim_log #7062 is merged.
+ NVIM_LOG_FILE=testlog,
+ -- TODO: remove this after nvim_log #7062 is merged.
__NVIM_TEST_LOG='1'
}})
- retry(nil, nil, function()
- assert_log('T%d+\\.%d+\\.\\d +log_init:%d+: test log message', test_log_file, 100)
+ 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([[
@@ -47,9 +49,9 @@ describe('log', function()
vim.fn.jobwait({ j1 }, 10000)
]])
- -- Child Nvim spawned by jobstart() appends "/child" to parent name.
- retry(nil, nil, function()
- assert_log('T%d+/child +log_init:%d+: test log message', test_log_file, 100)
+ -- 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/helpers.lua b/test/functional/helpers.lua
index 0122229e77..d31d337b63 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -431,16 +431,20 @@ end
function module.new_argv(...)
local args = {unpack(module.nvim_argv)}
table.insert(args, '--headless')
+ if _G._nvim_test_id then
+ -- Set the server name to the test-id for logging. #8519
+ table.insert(args, '--listen')
+ table.insert(args, _G._nvim_test_id)
+ end
local new_args
local io_extra
- local env = {}
+ local env = nil
local opts = select(1, ...)
if type(opts) ~= 'table' then
new_args = {...}
else
args = remove_args(args, opts.args_rm)
if opts.env then
- opts.env['NVIM_TEST'] = nil
local env_opt = {}
for k, v in pairs(opts.env) do
assert(type(k) == 'string')
@@ -461,11 +465,12 @@ function module.new_argv(...)
'TMPDIR',
'VIMRUNTIME',
}) do
- -- Set these from the environment only if not in opts.env.
+ -- Set these from the environment unless the caller defined them.
if not env_opt[k] then
env_opt[k] = os.getenv(k)
end
end
+ env = {}
for k, v in pairs(env_opt) do
env[#env + 1] = k .. '=' .. v
end
@@ -476,10 +481,6 @@ function module.new_argv(...)
for _, arg in ipairs(new_args) do
table.insert(args, arg)
end
-
- -- TODO(justinmk): introduce v:name and use that instead.
- table.insert(env, ('NVIM_TEST=%s'):format(_G._nvim_test_id or '?'))
-
return args, env, io_extra
end
diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua
index e28cc03597..b3a0b8a2c8 100644
--- a/test/functional/terminal/api_spec.lua
+++ b/test/functional/terminal/api_spec.lua
@@ -6,7 +6,7 @@ if helpers.pending_win32(pending) then return end
describe('api', function()
local screen
- local socket_name = "Xtest_functional_api.sock"
+ local socket_name = "./Xtest_functional_api.sock"
before_each(function()
helpers.clear()
@@ -29,7 +29,7 @@ describe('api', function()
{4:~ }|
{4:~ }|
{4:~ }|
- ]]..socket_name..[[ |
+ ]]..socket_name..[[ |
{3:-- TERMINAL --} |
]])
diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua
index de64a77b4d..ea07be231d 100644
--- a/test/functional/vimscript/server_spec.lua
+++ b/test/functional/vimscript/server_spec.lua
@@ -30,7 +30,7 @@ describe('server', function()
eq('', eval('$NVIM_LISTEN_ADDRESS'))
local servers = funcs.serverlist()
eq(1, #servers)
- ok(string.len(servers[1]) > 4) -- Like /tmp/nvim…/… or \\.\pipe\…
+ ok(string.len(servers[1]) > 4) -- "~/.local/state/nvim…/…" or "\\.\pipe\…"
end)
it('sets v:servername at startup or if all servers were stopped', function()
@@ -54,7 +54,7 @@ describe('server', function()
-- v:servername and $NVIM take the next available server.
local servername = (iswin() and [[\\.\pipe\Xtest-functional-server-pipe]]
- or 'Xtest-functional-server-socket')
+ or './Xtest-functional-server-socket')
funcs.serverstart(servername)
eq(servername, meths.get_vvar('servername'))
-- Not set in the current process, only in children.
@@ -66,7 +66,7 @@ describe('server', function()
eq(0, eval("serverstop('bogus-socket-name')"))
end)
- it('parses endpoints correctly', function()
+ it('parses endpoints', function()
clear_serverlist()
eq({}, funcs.serverlist())
@@ -101,6 +101,10 @@ describe('server', function()
eq(expected, funcs.serverlist())
clear_serverlist()
+ -- Address without slashes is a "name" which is appended to a generated path. #8519
+ matches([[.*[/\\]xtest1%.2%.3%.4[^/\\]*]], funcs.serverstart('xtest1.2.3.4'))
+ clear_serverlist()
+
eq('Vim:Failed to start server: invalid argument',
pcall_err(funcs.serverstart, '127.0.0.1:65536')) -- invalid port
eq({}, funcs.serverlist())
@@ -113,7 +117,7 @@ describe('server', function()
-- Add some servers.
local servs = (iswin()
and { [[\\.\pipe\Xtest-pipe0934]], [[\\.\pipe\Xtest-pipe4324]] }
- or { [[Xtest-pipe0934]], [[Xtest-pipe4324]] })
+ or { [[./Xtest-pipe0934]], [[./Xtest-pipe4324]] })
for _, s in ipairs(servs) do
eq(s, eval("serverstart('"..s.."')"))
end
@@ -146,9 +150,13 @@ describe('startup --listen', function()
it('sets v:servername, overrides $NVIM_LISTEN_ADDRESS', function()
local addr = (iswin() and [[\\.\pipe\Xtest-listen-pipe]]
- or 'Xtest-listen-pipe')
- clear({ env={ NVIM_LISTEN_ADDRESS='Xtest-env-pipe' },
+ or './Xtest-listen-pipe')
+ clear({ env={ NVIM_LISTEN_ADDRESS='./Xtest-env-pipe' },
args={ '--listen', addr } })
eq(addr, meths.get_vvar('servername'))
+
+ -- Address without slashes is a "name" which is appended to a generated path. #8519
+ clear({ args={ '--listen', 'test-name' } })
+ matches([[.*[/\\]test%-name[^/\\]*]], meths.get_vvar('servername'))
end)
end)