aboutsummaryrefslogtreecommitdiff
path: root/test/functional/helpers.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2022-05-23 21:44:15 -0700
committerJustin M. Keyes <justinkz@gmail.com>2022-06-15 19:23:10 -0700
commit8f065205946844d87f00d6c55517521e3809f821 (patch)
tree7201a15d3b8f8992fc67a3769ffb6ad06657b9d4 /test/functional/helpers.lua
parentfa4b0c3ba5c4aa6dce90cf9d5fb63ea65fd0daee (diff)
downloadrneovim-8f065205946844d87f00d6c55517521e3809f821.tar.gz
rneovim-8f065205946844d87f00d6c55517521e3809f821.tar.bz2
rneovim-8f065205946844d87f00d6c55517521e3809f821.zip
feat(logging): include test-id in log messages
Problem: 1. Log messages (especially in CI) are hard to correlate with tests. 2. Since b353a5c05f02 #11886, dumplog() prints the logs next to test failures. This is noisy and gets in the way of the test results. Solution: 1. Associate an incrementing id with each test and include it in log messages. - FUTURE: add v:name so Nvim instances can be formally "named"? 2. Mention "child" in log messages if the current Nvim is a child (based on the presence of $NVIM). BEFORE: DBG … 12345 UI: event DBG … 12345 log_server_msg:722: RPC ->ch 1: … DBG … 12345 UI: flush DBG … 12345 inbuf_poll:444: blocking... events_enabled=1 events_pending=0 DBG … 23454 UI: stop INF … 23454 os_exit:594: Nvim exit: 0 AFTER: DBG … T57 UI: event DBG … T57 log_server_msg:722: RPC ->ch 1: … DBG … T57 UI: flush DBG … T57 inbuf_poll:444: blocking... events_enabled=1 events_pending=0 DBG … T57/child UI: stop INF … T57/child os_exit:594: Nvim exit: 0
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r--test/functional/helpers.lua25
1 files changed, 15 insertions, 10 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index ffb5694c15..0122229e77 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -433,16 +433,19 @@ function module.new_argv(...)
table.insert(args, '--headless')
local new_args
local io_extra
- local env = nil
+ local env = {}
local opts = select(1, ...)
- if type(opts) == 'table' then
+ if type(opts) ~= 'table' then
+ new_args = {...}
+ else
args = remove_args(args, opts.args_rm)
if opts.env then
- local env_tbl = {}
+ opts.env['NVIM_TEST'] = nil
+ local env_opt = {}
for k, v in pairs(opts.env) do
assert(type(k) == 'string')
assert(type(v) == 'string')
- env_tbl[k] = v
+ env_opt[k] = v
end
for _, k in ipairs({
'HOME',
@@ -458,23 +461,25 @@ function module.new_argv(...)
'TMPDIR',
'VIMRUNTIME',
}) do
- if not env_tbl[k] then
- env_tbl[k] = os.getenv(k)
+ -- Set these from the environment only if not in opts.env.
+ if not env_opt[k] then
+ env_opt[k] = os.getenv(k)
end
end
- env = {}
- for k, v in pairs(env_tbl) do
+ for k, v in pairs(env_opt) do
env[#env + 1] = k .. '=' .. v
end
end
new_args = opts.args or {}
io_extra = opts.io_extra
- else
- new_args = {...}
end
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