mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(tests): use -l mode for lsp tests
This fixes "fake server" from leaking memory, which makes ASAN very upset, except on current ASAN CI for some reason.
This commit is contained in:
@@ -927,10 +927,13 @@ function tests.basic_formatting()
|
|||||||
}
|
}
|
||||||
end
|
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()
|
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:stop()
|
||||||
kill_timer:close()
|
kill_timer:close()
|
||||||
log('ERROR', 'LSP', 'TIMEOUT')
|
log('ERROR', 'LSP', 'TIMEOUT')
|
||||||
@@ -938,14 +941,11 @@ kill_timer:start(_G.TIMEOUT or 1e3, 0, function()
|
|||||||
os.exit(100)
|
os.exit(100)
|
||||||
end)
|
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"))
|
local status, err = pcall(assert(tests[test_name], "Test not found"))
|
||||||
kill_timer:stop()
|
kill_timer:stop()
|
||||||
kill_timer:close()
|
kill_timer:close()
|
||||||
if not status then
|
if not status then
|
||||||
log('ERROR', 'LSP', tostring(err))
|
log('ERROR', 'LSP', tostring(err))
|
||||||
io.stderr:write(err)
|
io.stderr:write(err)
|
||||||
os.exit(101)
|
vim.cmd [[101cquit]]
|
||||||
end
|
end
|
||||||
os.exit(0)
|
|
||||||
|
@@ -80,17 +80,14 @@ M.fake_lsp_logfile = 'Xtest-fake-lsp.log'
|
|||||||
local function fake_lsp_server_setup(test_name, timeout_ms, options, settings)
|
local function fake_lsp_server_setup(test_name, timeout_ms, options, settings)
|
||||||
exec_lua([=[
|
exec_lua([=[
|
||||||
lsp = require('vim.lsp')
|
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 {
|
TEST_RPC_CLIENT_ID = lsp.start_client {
|
||||||
cmd_env = {
|
cmd_env = {
|
||||||
NVIM_LOG_FILE = logfile;
|
NVIM_LOG_FILE = fake_lsp_logfile;
|
||||||
NVIM_LUA_NOTRACK = "1";
|
NVIM_LUA_NOTRACK = "1";
|
||||||
};
|
};
|
||||||
cmd = {
|
cmd = {
|
||||||
vim.v.progpath, '-Es', '-u', 'NONE', '--headless',
|
vim.v.progpath, '-l', fake_lsp_code, test_name, tostring(timeout),
|
||||||
"-c", string.format("lua TEST_NAME = %q", test_name),
|
|
||||||
"-c", string.format("lua TIMEOUT = %d", timeout),
|
|
||||||
"-c", "luafile "..fixture_filename,
|
|
||||||
};
|
};
|
||||||
handlers = setmetatable({}, {
|
handlers = setmetatable({}, {
|
||||||
__index = function(t, method)
|
__index = function(t, method)
|
||||||
|
@@ -46,16 +46,14 @@ describe('LSP', function()
|
|||||||
local test_name = "basic_init"
|
local test_name = "basic_init"
|
||||||
exec_lua([=[
|
exec_lua([=[
|
||||||
lsp = require('vim.lsp')
|
lsp = require('vim.lsp')
|
||||||
local test_name, fixture_filename, logfile = ...
|
local test_name, fake_lsp_code, fake_lsp_logfile = ...
|
||||||
function test__start_client()
|
function test__start_client()
|
||||||
return lsp.start_client {
|
return lsp.start_client {
|
||||||
cmd_env = {
|
cmd_env = {
|
||||||
NVIM_LOG_FILE = logfile;
|
NVIM_LOG_FILE = fake_lsp_logfile;
|
||||||
};
|
};
|
||||||
cmd = {
|
cmd = {
|
||||||
vim.v.progpath, '-Es', '-u', 'NONE', '--headless',
|
vim.v.progpath, '-l', fake_lsp_code, test_name;
|
||||||
"-c", string.format("lua TEST_NAME = %q", test_name),
|
|
||||||
"-c", "luafile "..fixture_filename;
|
|
||||||
};
|
};
|
||||||
workspace_folders = {{
|
workspace_folders = {{
|
||||||
uri = 'file://' .. vim.loop.cwd(),
|
uri = 'file://' .. vim.loop.cwd(),
|
||||||
|
Reference in New Issue
Block a user