aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/vimscript')
-rw-r--r--test/functional/vimscript/api_functions_spec.lua3
-rw-r--r--test/functional/vimscript/ctx_functions_spec.lua12
-rw-r--r--test/functional/vimscript/exepath_spec.lua43
-rw-r--r--test/functional/vimscript/server_spec.lua20
4 files changed, 59 insertions, 19 deletions
diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua
index 8ca245f61a..c032ac3030 100644
--- a/test/functional/vimscript/api_functions_spec.lua
+++ b/test/functional/vimscript/api_functions_spec.lua
@@ -5,6 +5,7 @@ local neq, eq, command = helpers.neq, helpers.eq, helpers.command
local clear, curbufmeths = helpers.clear, helpers.curbufmeths
local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval
local insert, pcall_err = helpers.insert, helpers.pcall_err
+local matches = helpers.matches
local meths = helpers.meths
describe('eval-API', function()
@@ -49,7 +50,7 @@ describe('eval-API', function()
it('cannot change texts if textlocked', function()
command("autocmd TextYankPost <buffer> ++once call nvim_buf_set_lines(0, 0, -1, v:false, [])")
- eq('Vim(call):E5555: API call: E565: Not allowed to change text or change window',
+ matches('Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$',
pcall_err(command, "normal! yy"))
end)
diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua
index d92a81c55b..5ee84a6d13 100644
--- a/test/functional/vimscript/ctx_functions_spec.lua
+++ b/test/functional/vimscript/ctx_functions_spec.lua
@@ -173,9 +173,9 @@ describe('context functions', function()
call('SaveSFuncs')
call('DeleteSFuncs')
- eq('Vim(call):E117: Unknown function: s:greet',
+ eq('function Greet, line 1: Vim(call):E117: Unknown function: s:greet',
pcall_err(command, [[call Greet('World')]]))
- eq('Vim(call):E117: Unknown function: s:greet_all',
+ eq('function GreetAll, line 1: Vim(call):E117: Unknown function: s:greet_all',
pcall_err(command, [[call GreetAll('World', 'One', 'Two', 'Three')]]))
call('RestoreFuncs')
@@ -287,9 +287,11 @@ describe('context functions', function()
local with_jumps = {
['jumps'] = eval(([[
- filter(map(getjumplist()[0], 'filter(
- { "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum },
- { k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)')
+ filter(map(add(
+ getjumplist()[0], { 'bufnr': bufnr('%'), 'lnum': getcurpos()[1] }),
+ 'filter(
+ { "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum },
+ { k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)')
]]):gsub('\n', ''))
}
diff --git a/test/functional/vimscript/exepath_spec.lua b/test/functional/vimscript/exepath_spec.lua
index 056f67e0ad..da3d61cbe0 100644
--- a/test/functional/vimscript/exepath_spec.lua
+++ b/test/functional/vimscript/exepath_spec.lua
@@ -5,21 +5,21 @@ local command = helpers.command
local exc_exec = helpers.exc_exec
local matches = helpers.matches
local is_os = helpers.is_os
+local set_shell_powershell = helpers.set_shell_powershell
+local eval = helpers.eval
+
+local find_dummies = function(ext_pat)
+ local tmp_path = eval('$PATH')
+ command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
+ matches('null' .. ext_pat, call('exepath', 'null'))
+ matches('true' .. ext_pat, call('exepath', 'true'))
+ matches('false' .. ext_pat, call('exepath', 'false'))
+ command("let $PATH = '"..tmp_path.."'")
+end
describe('exepath()', function()
before_each(clear)
- it('returns 1 for commands in $PATH', function()
- local exe = is_os('win') and 'ping' or 'ls'
- local ext_pat = is_os('win') and '%.EXE$' or '$'
- matches(exe .. ext_pat, call('exepath', exe))
- command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
- ext_pat = is_os('win') and '%.CMD$' or '$'
- matches('null' .. ext_pat, call('exepath', 'null'))
- matches('true' .. ext_pat, call('exepath', 'true'))
- matches('false' .. ext_pat, call('exepath', 'false'))
- end)
-
it('fails for invalid values', function()
for _, input in ipairs({'v:null', 'v:true', 'v:false', '{}', '[]'}) do
eq('Vim(call):E1174: String required for argument 1', exc_exec('call exepath('..input..')'))
@@ -32,11 +32,32 @@ describe('exepath()', function()
end)
if is_os('win') then
+ it('returns 1 for commands in $PATH (Windows)', function()
+ local exe = 'ping'
+ matches(exe .. '%.EXE$', call('exepath', exe))
+ end)
+
it('append extension if omitted', function()
local filename = 'cmd'
local pathext = '.exe'
clear({env={PATHEXT=pathext}})
eq(call('exepath', filename..pathext), call('exepath', filename))
end)
+
+ it('returns file WITH extension if files both with and without extension exist in $PATH', function()
+ local ext_pat = '%.CMD$'
+ find_dummies(ext_pat)
+ set_shell_powershell()
+ find_dummies(ext_pat)
+ end)
+ else
+ it('returns 1 for commands in $PATH (not Windows)', function()
+ local exe = 'ls'
+ matches(exe .. '$', call('exepath', exe))
+ end)
+
+ it('returns file WITHOUT extension if files both with and without extension exist in $PATH', function()
+ find_dummies('$')
+ end)
end
end)
diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua
index 14c87d9d93..c89a0c4e93 100644
--- a/test/functional/vimscript/server_spec.lua
+++ b/test/functional/vimscript/server_spec.lua
@@ -1,4 +1,5 @@
local helpers = require('test.functional.helpers')(after_each)
+local assert_log = helpers.assert_log
local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval
local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths
local ok = helpers.ok
@@ -7,6 +8,8 @@ local pcall_err = helpers.pcall_err
local mkdir = helpers.mkdir
local is_os = helpers.is_os
+local testlog = 'Xtest-server-log'
+
local function clear_serverlist()
for _, server in pairs(funcs.serverlist()) do
funcs.serverstop(server)
@@ -14,6 +17,10 @@ local function clear_serverlist()
end
describe('server', function()
+ after_each(function()
+ os.remove(testlog)
+ end)
+
it('serverstart() stores sockets in $XDG_RUNTIME_DIR', function()
local dir = 'Xtest_xdg_run'
mkdir(dir)
@@ -74,13 +81,20 @@ describe('server', function()
end)
it('serverstop() returns false for invalid input', function()
- clear()
+ clear{env={
+ NVIM_LOG_FILE=testlog,
+ NVIM_LISTEN_ADDRESS='.',
+ }}
eq(0, eval("serverstop('')"))
eq(0, eval("serverstop('bogus-socket-name')"))
+ assert_log('Not listening on bogus%-socket%-name', testlog, 10)
end)
it('parses endpoints', function()
- clear()
+ clear{env={
+ NVIM_LOG_FILE=testlog,
+ NVIM_LISTEN_ADDRESS='.',
+ }}
clear_serverlist()
eq({}, funcs.serverlist())
@@ -104,6 +118,7 @@ describe('server', function()
if status then
table.insert(expected, v4)
pcall(funcs.serverstart, v4) -- exists already; ignore
+ assert_log('Failed to start server: address already in use: 127%.0%.0%.1', testlog, 10)
end
local v6 = '::1:12345'
@@ -111,6 +126,7 @@ describe('server', function()
if status then
table.insert(expected, v6)
pcall(funcs.serverstart, v6) -- exists already; ignore
+ assert_log('Failed to start server: address already in use: ::1', testlog, 10)
end
eq(expected, funcs.serverlist())
clear_serverlist()