aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/extmark_spec.lua206
-rw-r--r--test/functional/api/vim_spec.lua122
-rw-r--r--test/functional/core/job_spec.lua46
-rw-r--r--test/functional/helpers.lua2
-rw-r--r--test/functional/provider/nodejs_spec.lua4
-rw-r--r--test/functional/provider/perl_spec.lua4
-rw-r--r--test/functional/ui/screen.lua48
-rw-r--r--test/functional/vimscript/server_spec.lua20
8 files changed, 405 insertions, 47 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index e298eb3582..bc8d811c6d 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1606,3 +1606,209 @@ describe('Extmarks buffer api with many marks', function()
eq({}, get_marks(ns2))
end)
end)
+
+describe('API/win_extmark', function()
+ local screen
+ local marks, line1, line2
+ local ns
+
+ before_each(function()
+ -- Initialize some namespaces and insert text into a buffer
+ marks = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
+
+ line1 = "non ui-watched line"
+ line2 = "ui-watched line"
+
+ clear()
+
+ insert(line1)
+ feed("o<esc>")
+ insert(line2)
+ ns = request('nvim_create_namespace', "extmark-ui")
+ end)
+
+ it('sends and only sends ui-watched marks to ui', function()
+ screen = Screen.new(20, 4)
+ screen:attach()
+ -- should send this
+ set_extmark(ns, marks[1], 1, 0, { ui_watched = true })
+ -- should not send this
+ set_extmark(ns, marks[2], 0, 0, { ui_watched = false })
+ screen:expect({
+ grid = [[
+ non ui-watched line |
+ ui-watched lin^e |
+ ~ |
+ |
+ ]],
+ extmarks = {
+ [2] = {
+ -- positioned at the end of the 2nd line
+ { {id = 1000}, 1, 1, 1, 16 },
+ }
+ },
+ })
+ end)
+
+ it('sends multiple ui-watched marks to ui', function()
+ screen = Screen.new(20, 4)
+ screen:attach()
+ -- should send all of these
+ set_extmark(ns, marks[1], 1, 0, { ui_watched = true, virt_text_pos = "overlay" })
+ set_extmark(ns, marks[2], 1, 2, { ui_watched = true, virt_text_pos = "overlay" })
+ set_extmark(ns, marks[3], 1, 4, { ui_watched = true, virt_text_pos = "overlay" })
+ set_extmark(ns, marks[4], 1, 6, { ui_watched = true, virt_text_pos = "overlay" })
+ set_extmark(ns, marks[5], 1, 8, { ui_watched = true })
+ screen:expect({
+ grid = [[
+ non ui-watched line |
+ ui-watched lin^e |
+ ~ |
+ |
+ ]],
+ extmarks = {
+ [2] = {
+ -- earlier notifications
+ { {id = 1000}, 1, 1, 1, 0 },
+ { {id = 1000}, 1, 1, 1, 0 }, { {id = 1000}, 1, 2, 1, 2 },
+ { {id = 1000}, 1, 1, 1, 0 }, { {id = 1000}, 1, 2, 1, 2 }, { {id = 1000}, 1, 3, 1, 4 },
+ { {id = 1000}, 1, 1, 1, 0 }, { {id = 1000}, 1, 2, 1, 2 }, { {id = 1000}, 1, 3, 1, 4 }, { {id = 1000}, 1, 4, 1, 6 },
+ -- final
+ -- overlay
+ { {id = 1000}, 1, 1, 1, 0 },
+ { {id = 1000}, 1, 2, 1, 2 },
+ { {id = 1000}, 1, 3, 1, 4 },
+ { {id = 1000}, 1, 4, 1, 6 },
+ -- eol
+ { {id = 1000}, 1, 5, 1, 16 },
+ }
+ },
+ })
+ end)
+
+ it('updates ui-watched marks', function()
+ screen = Screen.new(20, 4)
+ screen:attach()
+ -- should send this
+ set_extmark(ns, marks[1], 1, 0, { ui_watched = true })
+ -- should not send this
+ set_extmark(ns, marks[2], 0, 0, { ui_watched = false })
+ -- make some changes
+ insert(" update")
+ screen:expect({
+ grid = [[
+ non ui-watched line |
+ ui-watched linupdat^e|
+ e |
+ |
+ ]],
+ extmarks = {
+ [2] = {
+ -- positioned at the end of the 2nd line
+ { {id = 1000}, 1, 1, 1, 16 },
+ -- updated and wrapped to 3rd line
+ { {id = 1000}, 1, 1, 2, 2 },
+ }
+ }
+ })
+ feed("<c-e>")
+ screen:expect({
+ grid = [[
+ ui-watched linupdat^e|
+ e |
+ ~ |
+ |
+ ]],
+ extmarks = {
+ [2] = {
+ -- positioned at the end of the 2nd line
+ { {id = 1000}, 1, 1, 1, 16 },
+ -- updated and wrapped to 3rd line
+ { {id = 1000}, 1, 1, 2, 2 },
+ -- scrolled up one line, should be handled by grid scroll
+ }
+ }
+ })
+ end)
+
+ it('sends ui-watched to splits', function()
+ screen = Screen.new(20, 8)
+ screen:attach({ext_multigrid=true})
+ -- should send this
+ set_extmark(ns, marks[1], 1, 0, { ui_watched = true })
+ -- should not send this
+ set_extmark(ns, marks[2], 0, 0, { ui_watched = false })
+ command('split')
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [4:--------------------]|
+ [4:--------------------]|
+ [4:--------------------]|
+ [No Name] [+] |
+ [2:--------------------]|
+ [2:--------------------]|
+ [No Name] [+] |
+ [3:--------------------]|
+ ## grid 2
+ non ui-watched line |
+ ui-watched line |
+ ## grid 3
+ |
+ ## grid 4
+ non ui-watched line |
+ ui-watched lin^e |
+ ~ |
+ ]],
+ extmarks = {
+ [2] = {
+ -- positioned at the end of the 2nd line
+ { {id = 1000}, 1, 1, 1, 16 },
+ -- updated after split
+ { {id = 1000}, 1, 1, 1, 16 },
+ },
+ [4] = {
+ -- only after split
+ { {id = 1001}, 1, 1, 1, 16 },
+ }
+ }
+ })
+ -- make some changes
+ insert(" update")
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [4:--------------------]|
+ [4:--------------------]|
+ [4:--------------------]|
+ [No Name] [+] |
+ [2:--------------------]|
+ [2:--------------------]|
+ [No Name] [+] |
+ [3:--------------------]|
+ ## grid 2
+ non ui-watched line |
+ ui-watched linupd@@@|
+ ## grid 3
+ |
+ ## grid 4
+ non ui-watched line |
+ ui-watched linupdat^e|
+ e |
+ ]],
+ extmarks = {
+ [2] = {
+ -- positioned at the end of the 2nd line
+ { {id = 1000}, 1, 1, 1, 16 },
+ -- updated after split
+ { {id = 1000}, 1, 1, 1, 16 },
+ },
+ [4] = {
+ { {id = 1001}, 1, 1, 1, 16 },
+ -- updated
+ { {id = 1001}, 1, 1, 2, 2 },
+ }
+ }
+ })
+ end)
+end)
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index e138e2cc38..7e54ae0248 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -3104,8 +3104,11 @@ describe('API', function()
cmd = 'echo',
args = { 'foo' },
bang = false,
- line1 = 1,
- line2 = 1,
+ line1 = -1,
+ line2 = -1,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'none',
magic = {
file = false,
@@ -3130,7 +3133,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('echo foo', {}))
end)
@@ -3141,6 +3144,9 @@ describe('API', function()
bang = false,
line1 = 4,
line2 = 6,
+ range = 2,
+ count = -1,
+ reg = '',
addr = 'line',
magic = {
file = false,
@@ -3165,10 +3171,86 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('4,6s/math.random/math.max/', {}))
end)
+ it('works with count', function()
+ eq({
+ cmd = 'buffer',
+ args = {},
+ bang = false,
+ line1 = 1,
+ line2 = 1,
+ range = 1,
+ count = 1,
+ reg = '',
+ addr = 'buf',
+ magic = {
+ file = false,
+ bar = true
+ },
+ nargs = '*',
+ nextcmd = '',
+ mods = {
+ browse = false,
+ confirm = false,
+ emsg_silent = false,
+ hide = false,
+ keepalt = false,
+ keepjumps = false,
+ keepmarks = false,
+ keeppatterns = false,
+ lockmarks = false,
+ noautocmd = false,
+ noswapfile = false,
+ sandbox = false,
+ silent = false,
+ vertical = false,
+ split = "",
+ tab = 0,
+ verbose = -1
+ }
+ }, meths.parse_cmd('buffer 1', {}))
+ end)
+ it('works with register', function()
+ eq({
+ cmd = 'put',
+ args = {},
+ bang = false,
+ line1 = 1,
+ line2 = 1,
+ range = 0,
+ count = -1,
+ reg = '+',
+ addr = 'line',
+ magic = {
+ file = false,
+ bar = true
+ },
+ nargs = '0',
+ nextcmd = '',
+ mods = {
+ browse = false,
+ confirm = false,
+ emsg_silent = false,
+ hide = false,
+ keepalt = false,
+ keepjumps = false,
+ keepmarks = false,
+ keeppatterns = false,
+ lockmarks = false,
+ noautocmd = false,
+ noswapfile = false,
+ sandbox = false,
+ silent = false,
+ vertical = false,
+ split = "",
+ tab = 0,
+ verbose = -1
+ }
+ }, meths.parse_cmd('put +', {}))
+ end)
it('works with bang', function()
eq({
cmd = 'write',
@@ -3176,6 +3258,9 @@ describe('API', function()
bang = true,
line1 = 1,
line2 = 1,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'line',
magic = {
file = true,
@@ -3200,7 +3285,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
},
}, meths.parse_cmd('w!', {}))
end)
@@ -3211,6 +3296,9 @@ describe('API', function()
bang = false,
line1 = 1,
line2 = 1,
+ range = 0,
+ count = -1,
+ reg = '',
addr = '?',
magic = {
file = true,
@@ -3247,6 +3335,9 @@ describe('API', function()
bang = true,
line1 = 4,
line2 = 6,
+ range = 2,
+ count = -1,
+ reg = '',
addr = 'line',
magic = {
file = false,
@@ -3271,7 +3362,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('4,6MyCommand! test it', {}))
end)
@@ -3282,6 +3373,9 @@ describe('API', function()
bang = false,
line1 = 0,
line2 = 0,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'arg',
magic = {
file = true,
@@ -3306,7 +3400,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('argadd a.txt | argadd b.txt', {}))
end)
@@ -3316,8 +3410,11 @@ describe('API', function()
cmd = 'MyCommand',
args = { 'test it' },
bang = false,
- line1 = 1,
- line2 = 1,
+ line1 = -1,
+ line2 = -1,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'none',
magic = {
file = false,
@@ -3342,7 +3439,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('MyCommand test it', {}))
end)
@@ -3355,6 +3452,9 @@ describe('API', function()
bang = false,
line1 = 1,
line2 = 2,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'buf',
magic = {
file = false,
@@ -3379,7 +3479,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('MyCommand', {}))
end)
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 94a50b9a41..cf24e570cb 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -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
@@ -208,7 +209,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'
@@ -249,7 +250,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")')
@@ -295,7 +296,7 @@ describe('jobs', function()
nvim('command', "call jobstop(j)")
end)
- it("will not buffer data if it doesn't end in newlines", function()
+ 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())
@@ -378,7 +379,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)')
@@ -646,6 +647,43 @@ 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' }))
+ end)
+
describe('jobwait', function()
before_each(function()
if iswin() then
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index b0b2dac9fd..e9c3d4bd92 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -782,7 +782,7 @@ function module.pathroot()
return iswin() and (module.nvim_dir:sub(1,2)..pathsep) or '/'
end
--- Returns a valid, platform-independent $NVIM_LISTEN_ADDRESS.
+-- Returns a valid, platform-independent Nvim listen address.
-- Useful for communicating with child instances.
function module.new_pipename()
-- HACK: Start a server temporarily, get the name, then stop it.
diff --git a/test/functional/provider/nodejs_spec.lua b/test/functional/provider/nodejs_spec.lua
index 661a6f4f94..187f1c0412 100644
--- a/test/functional/provider/nodejs_spec.lua
+++ b/test/functional/provider/nodejs_spec.lua
@@ -29,7 +29,7 @@ describe('nodejs host', function()
local fname = 'Xtest-nodejs-hello.js'
write_file(fname, [[
const neovim = require('neovim');
- const nvim = neovim.attach({socket: process.env.NVIM_LISTEN_ADDRESS});
+ const nvim = neovim.attach({socket: process.env.NVIM});
nvim.command('let g:job_out = "hello"');
]])
command('let g:job_id = jobstart(["node", "'..fname..'"])')
@@ -39,7 +39,7 @@ describe('nodejs host', function()
local fname = 'Xtest-nodejs-hello-plugin.js'
write_file(fname, [[
const neovim = require('neovim');
- const nvim = neovim.attach({socket: process.env.NVIM_LISTEN_ADDRESS});
+ const nvim = neovim.attach({socket: process.env.NVIM});
class TestPlugin {
hello() {
diff --git a/test/functional/provider/perl_spec.lua b/test/functional/provider/perl_spec.lua
index 125674660b..aff5e36e24 100644
--- a/test/functional/provider/perl_spec.lua
+++ b/test/functional/provider/perl_spec.lua
@@ -83,7 +83,7 @@ describe('perl provider', function()
use Neovim::Ext;
use Neovim::Ext::MsgPack::RPC;
- my $session = Neovim::Ext::MsgPack::RPC::socket_session($ENV{NVIM_LISTEN_ADDRESS});
+ my $session = Neovim::Ext::MsgPack::RPC::socket_session($ENV{NVIM});
my $nvim = Neovim::Ext::from_session($session);
$nvim->command('let g:job_out = "hello"');
1;
@@ -116,7 +116,7 @@ describe('perl provider', function()
use Neovim::Ext;
use Neovim::Ext::MsgPack::RPC;
- my $session = Neovim::Ext::MsgPack::RPC::socket_session($ENV{NVIM_LISTEN_ADDRESS});
+ my $session = Neovim::Ext::MsgPack::RPC::socket_session($ENV{NVIM});
my $nvim = Neovim::Ext::from_session($session);
my $plugin = TestPlugin->new($nvim);
$plugin->test_command();
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index e8a39ab6f8..06daabad1a 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -75,7 +75,7 @@ local busted = require('busted')
local deepcopy = helpers.deepcopy
local shallowcopy = helpers.shallowcopy
local concat_tables = helpers.concat_tables
-local request, run_session = helpers.request, helpers.run_session
+local run_session = helpers.run_session
local eq = helpers.eq
local dedent = helpers.dedent
local get_session = helpers.get_session
@@ -90,8 +90,6 @@ end
local Screen = {}
Screen.__index = Screen
-local debug_screen
-
local default_timeout_factor = 1
if os.getenv('VALGRIND') then
default_timeout_factor = default_timeout_factor * 3
@@ -123,18 +121,6 @@ do
Screen.colornames = colornames
end
-function Screen.debug(command)
- if not command then
- command = 'pynvim -n -c '
- end
- command = command .. request('vim_eval', '$NVIM_LISTEN_ADDRESS')
- if debug_screen then
- debug_screen:close()
- end
- debug_screen = io.popen(command, 'r')
- debug_screen:read()
-end
-
function Screen.new(width, height)
if not width then
width = 53
@@ -179,6 +165,7 @@ function Screen.new(width, height)
_width = width,
_height = height,
_grids = {},
+ _grid_win_extmarks = {},
_cursor = {
grid = 1, row = 1, col = 1
},
@@ -278,6 +265,8 @@ local ext_keys = {
-- attributes in the final state are an error.
-- Use screen:set_default_attr_ids() to define attributes for many
-- expect() calls.
+-- extmarks: Expected win_extmarks accumulated for the grids. For each grid,
+-- the win_extmark messages are accumulated into an array.
-- condition: Function asserting some arbitrary condition. Return value is
-- ignored, throw an error (use eq() or similar) to signal failure.
-- any: Lua pattern string expected to match a screen line. NB: the
@@ -320,7 +309,7 @@ function Screen:expect(expected, attr_ids, ...)
assert(not (attr_ids ~= nil))
local is_key = {grid=true, attr_ids=true, condition=true, mouse_enabled=true,
any=true, mode=true, unchanged=true, intermediate=true,
- reset=true, timeout=true, request_cb=true, hl_groups=true}
+ reset=true, timeout=true, request_cb=true, hl_groups=true, extmarks=true}
for _, v in ipairs(ext_keys) do
is_key[v] = true
end
@@ -459,6 +448,25 @@ screen:redraw_debug() to show all intermediate screen states. ]])
end
end
end
+
+ if expected.extmarks ~= nil then
+ for gridid, expected_marks in pairs(expected.extmarks) do
+ local stored_marks = self._grid_win_extmarks[gridid]
+ if stored_marks == nil then
+ return 'no win_extmark for grid '..tostring(gridid)
+ end
+ local status, res = pcall(eq, expected_marks, stored_marks, "extmarks for grid "..tostring(gridid))
+ if not status then
+ return tostring(res)
+ end
+ end
+ for gridid, _ in pairs(self._grid_win_extmarks) do
+ local expected_marks = expected.extmarks[gridid]
+ if expected_marks == nil then
+ return 'unexpected win_extmark for grid '..tostring(gridid)
+ end
+ end
+ end
end, expected)
end
@@ -703,6 +711,7 @@ function Screen:_reset()
self.cmdline_block = {}
self.wildmenu_items = nil
self.wildmenu_pos = nil
+ self._grid_win_extmarks = {}
end
function Screen:_handle_mode_info_set(cursor_style_enabled, mode_info)
@@ -803,6 +812,13 @@ function Screen:_handle_win_close(grid)
self.float_pos[grid] = nil
end
+function Screen:_handle_win_extmark(grid, ...)
+ if self._grid_win_extmarks[grid] == nil then
+ self._grid_win_extmarks[grid] = {}
+ end
+ table.insert(self._grid_win_extmarks[grid], {...})
+end
+
function Screen:_handle_busy_start()
self._busy = true
end
diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua
index 238d1aeb0f..de64a77b4d 100644
--- a/test/functional/vimscript/server_spec.lua
+++ b/test/functional/vimscript/server_spec.lua
@@ -1,6 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval
-local command = helpers.command
local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths
local iswin = helpers.iswin
local ok = helpers.ok
@@ -16,27 +15,25 @@ end
describe('server', function()
before_each(clear)
- it('serverstart() sets $NVIM_LISTEN_ADDRESS on first invocation', function()
- -- Unset $NVIM_LISTEN_ADDRESS
- command('let $NVIM_LISTEN_ADDRESS = ""')
-
+ it('serverstart(), serverstop() does not set $NVIM', function()
local s = eval('serverstart()')
assert(s ~= nil and s:len() > 0, "serverstart() returned empty")
- eq(s, eval('$NVIM_LISTEN_ADDRESS'))
+ eq('', eval('$NVIM'))
+ eq('', eval('$NVIM_LISTEN_ADDRESS'))
eq(1, eval("serverstop('"..s.."')"))
eq('', eval('$NVIM_LISTEN_ADDRESS'))
end)
it('sets new v:servername if $NVIM_LISTEN_ADDRESS is invalid', function()
clear({env={NVIM_LISTEN_ADDRESS='.'}})
- eq('.', eval('$NVIM_LISTEN_ADDRESS'))
+ -- Cleared on startup.
+ eq('', eval('$NVIM_LISTEN_ADDRESS'))
local servers = funcs.serverlist()
eq(1, #servers)
ok(string.len(servers[1]) > 4) -- Like /tmp/nvim…/… or \\.\pipe\…
end)
- it('sets v:servername at startup or if all servers were stopped',
- function()
+ it('sets v:servername at startup or if all servers were stopped', function()
local initial_server = meths.get_vvar('servername')
assert(initial_server ~= nil and initial_server:len() > 0,
'v:servername was not initialized')
@@ -55,11 +52,13 @@ describe('server', function()
eq(1, funcs.serverstop(funcs.serverlist()[1]))
eq('', meths.get_vvar('servername'))
- -- v:servername will take the next available server.
+ -- v:servername and $NVIM take the next available server.
local servername = (iswin() and [[\\.\pipe\Xtest-functional-server-pipe]]
or 'Xtest-functional-server-socket')
funcs.serverstart(servername)
eq(servername, meths.get_vvar('servername'))
+ -- Not set in the current process, only in children.
+ eq('', eval('$NVIM'))
end)
it('serverstop() returns false for invalid input', function()
@@ -136,7 +135,6 @@ end)
describe('startup --listen', function()
it('validates', function()
clear()
-
local cmd = { unpack(helpers.nvim_argv) }
table.insert(cmd, '--listen')
matches('nvim.*: Argument missing after: "%-%-listen"', funcs.system(cmd))