diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2022-06-01 11:28:14 -0700 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2022-06-15 19:29:51 -0700 |
commit | 1f2c2a35ad14cfac002d87073471bd84a52860bf (patch) | |
tree | d1830fbb6b8774249da3fbc2f9caae82aa044863 /test/functional/helpers.lua | |
parent | b6467dfc23dab476e256490b8014bbb488684e6b (diff) | |
download | rneovim-1f2c2a35ad14cfac002d87073471bd84a52860bf.tar.gz rneovim-1f2c2a35ad14cfac002d87073471bd84a52860bf.tar.bz2 rneovim-1f2c2a35ad14cfac002d87073471bd84a52860bf.zip |
feat(server): instance "name", store pipes in stdpath(state)
Problem:
- Unix sockets are created in random /tmp dirs.
- /tmp is messy, unclear when OSes actually clear it.
- The generated paths are very ugly. This adds friction to reasoning
about which paths belong to which Nvim instances.
- No way to provide a human-friendly way to identify Nvim instances in
logs or server addresses.
Solution:
- Store unix sockets in stdpath('state')
- Allow --listen "name" and serverstart("name") to given a name (which
is appended to a generated path).
TODO:
- is stdpath(state) the right place?
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r-- | test/functional/helpers.lua | 15 |
1 files changed, 8 insertions, 7 deletions
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 |