mirror of
https://github.com/neovim/neovim.git
synced 2025-11-17 15:51:32 +00:00
feat: stdpath('run'), /tmp/nvim.user/ #18993
Problem:
- Since c57f6b28d7 #8519, sockets are created in ~/.local/… but XDG
spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).
Solution:
- Store sockets in stdpath('run') ($XDG_RUNTIME_DIR).
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().
closes #3517
closes #17093
This commit is contained in:
@@ -5,6 +5,7 @@ local iswin = helpers.iswin
|
||||
local ok = helpers.ok
|
||||
local matches = helpers.matches
|
||||
local pcall_err = helpers.pcall_err
|
||||
local mkdir = helpers.mkdir
|
||||
|
||||
local function clear_serverlist()
|
||||
for _, server in pairs(funcs.serverlist()) do
|
||||
@@ -13,9 +14,19 @@ local function clear_serverlist()
|
||||
end
|
||||
|
||||
describe('server', function()
|
||||
before_each(clear)
|
||||
it('serverstart() stores sockets in $XDG_RUNTIME_DIR', function()
|
||||
local dir = 'Xtest_xdg_run'
|
||||
mkdir(dir)
|
||||
clear({ env={ XDG_RUNTIME_DIR=dir } })
|
||||
matches(dir, funcs.stdpath('run'))
|
||||
if not iswin() then
|
||||
matches(dir, funcs.serverstart())
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
it('serverstart(), serverstop() does not set $NVIM', function()
|
||||
clear()
|
||||
local s = eval('serverstart()')
|
||||
assert(s ~= nil and s:len() > 0, "serverstart() returned empty")
|
||||
eq('', eval('$NVIM'))
|
||||
@@ -34,6 +45,7 @@ describe('server', function()
|
||||
end)
|
||||
|
||||
it('sets v:servername at startup or if all servers were stopped', function()
|
||||
clear()
|
||||
local initial_server = meths.get_vvar('servername')
|
||||
assert(initial_server ~= nil and initial_server:len() > 0,
|
||||
'v:servername was not initialized')
|
||||
@@ -62,11 +74,13 @@ describe('server', function()
|
||||
end)
|
||||
|
||||
it('serverstop() returns false for invalid input', function()
|
||||
clear()
|
||||
eq(0, eval("serverstop('')"))
|
||||
eq(0, eval("serverstop('bogus-socket-name')"))
|
||||
end)
|
||||
|
||||
it('parses endpoints', function()
|
||||
clear()
|
||||
clear_serverlist()
|
||||
eq({}, funcs.serverlist())
|
||||
|
||||
@@ -111,6 +125,7 @@ describe('server', function()
|
||||
end)
|
||||
|
||||
it('serverlist() returns the list of servers', function()
|
||||
clear()
|
||||
-- There should already be at least one server.
|
||||
local n = eval('len(serverlist())')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user