aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/api/extmark_spec.lua8
-rw-r--r--test/functional/api/highlight_spec.lua6
-rw-r--r--test/functional/core/startup_spec.lua7
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua12
-rw-r--r--test/functional/lua/runtime_spec.lua6
-rw-r--r--test/functional/plugin/lsp/helpers.lua9
-rw-r--r--test/functional/plugin/lsp_spec.lua8
-rw-r--r--test/functional/plugin/man_spec.lua6
-rw-r--r--test/functional/terminal/tui_spec.lua6
-rw-r--r--test/functional/treesitter/language_spec.lua5
-rw-r--r--test/functional/ui/statuscolumn_spec.lua21
-rw-r--r--test/functional/vimscript/exepath_spec.lua43
12 files changed, 102 insertions, 35 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 00f5b25b8a..9902826c72 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1454,6 +1454,14 @@ describe('API/extmarks', function()
}} }, get_extmarks(ns, 0, -1, {details=true}))
end)
+ it('in prompt buffer', function()
+ feed('dd')
+ local id = set_extmark(ns, marks[1], 0, 0, {})
+ curbufmeths.set_option('buftype', 'prompt')
+ feed('i<esc>')
+ eq({{id, 0, 2}}, get_extmarks(ns, 0, -1))
+ end)
+
it('can get details', function()
set_extmark(ns, marks[1], 0, 0, {
end_col = 0,
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index 5941d4c68b..7f044977cb 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -214,7 +214,7 @@ describe("API: set highlight", function()
bold = true,
italic = true,
reverse = true,
- underline = true,
+ underdashed = true,
strikethrough = true,
altfont = true,
cterm = {
@@ -231,7 +231,7 @@ describe("API: set highlight", function()
bold = true,
italic = true,
reverse = true,
- underline = true,
+ underdashed = true,
strikethrough = true,
altfont = true,
}
@@ -297,7 +297,7 @@ describe("API: set highlight", function()
exec_capture('highlight Test_hl'))
meths.set_hl(0, 'Test_hl2', highlight3_config)
- eq('Test_hl2 xxx cterm=italic,reverse,strikethrough,altfont,nocombine ctermfg=8 ctermbg=15 gui=bold,underline,italic,reverse,strikethrough,altfont guifg=#ff0000 guibg=#0032aa',
+ eq('Test_hl2 xxx cterm=italic,reverse,strikethrough,altfont,nocombine ctermfg=8 ctermbg=15 gui=bold,underdashed,italic,reverse,strikethrough,altfont guifg=#ff0000 guibg=#0032aa',
exec_capture('highlight Test_hl2'))
-- Colors are stored with the name they are defined, but
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 1be5de6488..e9b47a0251 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -102,6 +102,13 @@ describe('startup', function()
end)
it('os.exit() sets Nvim exitcode', function()
+ -- tricky: LeakSanitizer triggers on os.exit() and disrupts the return value, disable it
+ exec_lua [[
+ local asan_options = os.getenv 'ASAN_OPTIONS'
+ if asan_options ~= nil and asan_options ~= '' then
+ vim.loop.os_setenv('ASAN_OPTIONS', asan_options..':detect_leaks=0')
+ end
+ ]]
-- nvim -l foo.lua -arg1 -- a b c
assert_l_out([[
bufs:
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index aa47198f7a..db0c8c0c3f 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -927,10 +927,13 @@ function tests.basic_formatting()
}
end
--- Tests will be indexed by TEST_NAME
+-- Tests will be indexed by test_name
+local test_name = arg[1]
+local timeout = arg[2]
+assert(type(test_name) == 'string', 'test_name must be specified as first arg.')
local kill_timer = vim.loop.new_timer()
-kill_timer:start(_G.TIMEOUT or 1e3, 0, function()
+kill_timer:start(timeout or 1e3, 0, function()
kill_timer:stop()
kill_timer:close()
log('ERROR', 'LSP', 'TIMEOUT')
@@ -938,14 +941,11 @@ kill_timer:start(_G.TIMEOUT or 1e3, 0, function()
os.exit(100)
end)
-local test_name = _G.TEST_NAME -- lualint workaround
-assert(type(test_name) == 'string', 'TEST_NAME must be specified.')
local status, err = pcall(assert(tests[test_name], "Test not found"))
kill_timer:stop()
kill_timer:close()
if not status then
log('ERROR', 'LSP', tostring(err))
io.stderr:write(err)
- os.exit(101)
+ vim.cmd [[101cquit]]
end
-os.exit(0)
diff --git a/test/functional/lua/runtime_spec.lua b/test/functional/lua/runtime_spec.lua
index b659f2eacb..884ef3ef8e 100644
--- a/test/functional/lua/runtime_spec.lua
+++ b/test/functional/lua/runtime_spec.lua
@@ -18,6 +18,7 @@ describe('runtime:', function()
io.open(init, 'w'):close() -- touch init file
clear{args = {'-u', init}}
exec('set rtp+=' .. plug_dir)
+ exec('set completeslash=slash')
end)
teardown(function()
@@ -42,6 +43,7 @@ describe('runtime:', function()
write_file(colorscheme_file, [[vim.g.lua_colorscheme = 1]])
eq({'new_colorscheme'}, funcs.getcompletion('new_c', 'color'))
+ eq({'colors/new_colorscheme.lua'}, funcs.getcompletion('colors/new_c', 'runtime'))
exec('colorscheme new_colorscheme')
@@ -71,6 +73,7 @@ describe('runtime:', function()
write_file(compiler_file, [[vim.b.lua_compiler = 1]])
eq({'new_compiler'}, funcs.getcompletion('new_c', 'compiler'))
+ eq({'compiler/new_compiler.lua'}, funcs.getcompletion('compiler/new_c', 'runtime'))
exec('compiler new_compiler')
@@ -100,6 +103,7 @@ describe('runtime:', function()
write_file(ftplugin_file , [[vim.b.lua_ftplugin = 1]])
eq({'new-ft'}, funcs.getcompletion('new-f', 'filetype'))
+ eq({'ftplugin/new-ft.lua'}, funcs.getcompletion('ftplugin/new-f', 'runtime'))
exec [[set filetype=new-ft]]
eq(1, eval('b:lua_ftplugin'))
@@ -116,6 +120,7 @@ describe('runtime:', function()
write_file(indent_file , [[vim.b.lua_indent = 1]])
eq({'new-ft'}, funcs.getcompletion('new-f', 'filetype'))
+ eq({'indent/new-ft.lua'}, funcs.getcompletion('indent/new-f', 'runtime'))
exec [[set filetype=new-ft]]
eq(1, eval('b:lua_indent'))
@@ -152,6 +157,7 @@ describe('runtime:', function()
it('lua syntaxes are included in cmdline completion', function()
eq({'my-lang'}, funcs.getcompletion('my-l', 'filetype'))
eq({'my-lang'}, funcs.getcompletion('my-l', 'syntax'))
+ eq({'syntax/my-lang.lua'}, funcs.getcompletion('syntax/my-l', 'runtime'))
end)
end)
diff --git a/test/functional/plugin/lsp/helpers.lua b/test/functional/plugin/lsp/helpers.lua
index 028ccb9e2c..caab174b4d 100644
--- a/test/functional/plugin/lsp/helpers.lua
+++ b/test/functional/plugin/lsp/helpers.lua
@@ -80,17 +80,14 @@ M.fake_lsp_logfile = 'Xtest-fake-lsp.log'
local function fake_lsp_server_setup(test_name, timeout_ms, options, settings)
exec_lua([=[
lsp = require('vim.lsp')
- local test_name, fixture_filename, logfile, timeout, options, settings = ...
+ local test_name, fake_lsp_code, fake_lsp_logfile, timeout, options, settings = ...
TEST_RPC_CLIENT_ID = lsp.start_client {
cmd_env = {
- NVIM_LOG_FILE = logfile;
+ NVIM_LOG_FILE = fake_lsp_logfile;
NVIM_LUA_NOTRACK = "1";
};
cmd = {
- vim.v.progpath, '-Es', '-u', 'NONE', '--headless',
- "-c", string.format("lua TEST_NAME = %q", test_name),
- "-c", string.format("lua TIMEOUT = %d", timeout),
- "-c", "luafile "..fixture_filename,
+ vim.v.progpath, '-l', fake_lsp_code, test_name, tostring(timeout),
};
handlers = setmetatable({}, {
__index = function(t, method)
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 5229022564..fd162961ff 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -46,16 +46,14 @@ describe('LSP', function()
local test_name = "basic_init"
exec_lua([=[
lsp = require('vim.lsp')
- local test_name, fixture_filename, logfile = ...
+ local test_name, fake_lsp_code, fake_lsp_logfile = ...
function test__start_client()
return lsp.start_client {
cmd_env = {
- NVIM_LOG_FILE = logfile;
+ NVIM_LOG_FILE = fake_lsp_logfile;
};
cmd = {
- vim.v.progpath, '-Es', '-u', 'NONE', '--headless',
- "-c", string.format("lua TEST_NAME = %q", test_name),
- "-c", "luafile "..fixture_filename;
+ vim.v.progpath, '-l', fake_lsp_code, test_name;
};
workspace_folders = {{
uri = 'file://' .. vim.loop.cwd(),
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index c6c7d2b03d..58da059be6 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -59,7 +59,7 @@ describe(':Man', function()
screen:expect([[
^this {b:is} {b:a} test |
- with {u:overstruck} text |
+ with {i:overstruck} text |
{eob:~ }|
{eob:~ }|
|
@@ -98,7 +98,7 @@ describe(':Man', function()
screen:expect([[
^this {b:is} {b:あ} test |
- with {u:överstrũck} te{i:xt¶} |
+ with {i:överstrũck} te{i:xt¶} |
{eob:~ }|
{eob:~ }|
|
@@ -115,7 +115,7 @@ describe(':Man', function()
screen:expect([[
{b:^_begins} |
{b:mid_dle} |
- {u:mid_dle} |
+ {i:mid_dle} |
{eob:~ }|
|
]])
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index b28728057f..1d9e7b8e11 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -14,6 +14,7 @@ local clear = helpers.clear
local command = helpers.command
local dedent = helpers.dedent
local exec = helpers.exec
+local exec_lua = helpers.exec_lua
local testprg = helpers.testprg
local retry = helpers.retry
local nvim_prog = helpers.nvim_prog
@@ -1506,6 +1507,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]]}
end)
+
+ it('no assert failure on deadly signal #21896', function()
+ exec_lua([[vim.loop.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
+ screen:expect({any = '%[Process exited 1%]'})
+ end)
end)
describe('TUI', function()
diff --git a/test/functional/treesitter/language_spec.lua b/test/functional/treesitter/language_spec.lua
index f95b05a1cc..df45c9b384 100644
--- a/test/functional/treesitter/language_spec.lua
+++ b/test/functional/treesitter/language_spec.lua
@@ -31,6 +31,11 @@ describe('treesitter language API', function()
pcall_err(exec_lua, 'vim.treesitter.require_language("c", nil, false, "borklang")'))
end)
+ it('shows error for invalid language name', function()
+ eq(".../language.lua:0: '/foo/' is not a valid language name",
+ pcall_err(exec_lua, 'vim.treesitter.require_language("/foo/", nil, false)'))
+ end)
+
it('inspects language', function()
local keys, fields, symbols = unpack(exec_lua([[
local lang = vim.treesitter.inspect_language('c')
diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua
index ae3b95fb0f..3233e6cd19 100644
--- a/test/functional/ui/statuscolumn_spec.lua
+++ b/test/functional/ui/statuscolumn_spec.lua
@@ -439,7 +439,7 @@ describe('statuscolumn', function()
vim.api.nvim_buf_set_extmark(0, ns, 7, 0, {
virt_lines_leftcol = true, virt_lines = {{{"virt", ""}}} })
]])
- feed('lh') -- force update wcol/row
+ feed('lh') -- force update cursor row
screen:expect([[
4 aaaaa |
5 aaaaa |
@@ -458,5 +458,24 @@ describe('statuscolumn', function()
]])
command('set stc=') -- also for the default sign column
screen:expect_unchanged()
+ -- 'statuscolumn' is not too wide with custom (bogus) fold column
+ command([[set stc=%{foldlevel(v:lnum)>0?repeat('-',foldlevel(v:lnum)):''}%=%l\ ]])
+ feed('Gd10Ggg<C-l>')
+ screen:expect([[
+ 1 ^aaaaa |
+ 2 aaaaa |
+ 3 aaaaa |
+ 4 aaaaa |
+ 5 aaaaa |
+ 6 aaaaa |
+ 7 aaaaa |
+ virt |
+ ---------8 aaaaa |
+ virt |
+ ---------9 aaaaa |
+ ~ |
+ ~ |
+ |
+ ]])
end)
end)
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)