Merge pull request #28344 from bfredl/wonderland

feat(build): build.zig MVP: build and run functionaltests on linux
This commit is contained in:
bfredl
2025-05-02 10:34:25 +02:00
committed by GitHub
48 changed files with 1530 additions and 64 deletions

View File

@@ -4874,7 +4874,7 @@ describe('API', function()
-- #20681
eq('Invalid command: "win_getid"', pcall_err(api.nvim_cmd, { cmd = 'win_getid' }, {}))
eq('Invalid command: "echo "hi""', pcall_err(api.nvim_cmd, { cmd = 'echo "hi"' }, {}))
eq('Invalid command: "win_getid"', pcall_err(exec_lua, [[return vim.cmd.win_getid{}]]))
matches('Invalid command: "win_getid"$', pcall_err(exec_lua, [[return vim.cmd.win_getid{}]]))
-- Lua call allows empty {} for dict item.
eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, magic = {} }]]))
@@ -4882,16 +4882,16 @@ describe('API', function()
eq('', api.nvim_cmd({ cmd = 'set', args = {}, magic = {} }, {}))
-- Lua call does not allow non-empty list-like {} for dict item.
eq(
"Invalid 'magic': Expected Dict-like Lua table",
matches(
"Invalid 'magic': Expected Dict%-like Lua table$",
pcall_err(exec_lua, [[return vim.cmd{ cmd = "set", args = {}, magic = { 'a' } }]])
)
eq(
"Invalid key: 'bogus'",
matches(
"Invalid key: 'bogus'$",
pcall_err(exec_lua, [[return vim.cmd{ cmd = "set", args = {}, magic = { bogus = true } }]])
)
eq(
"Invalid key: 'bogus'",
matches(
"Invalid key: 'bogus'$",
pcall_err(exec_lua, [[return vim.cmd{ cmd = "set", args = {}, mods = { bogus = true } }]])
)
end)

View File

@@ -169,7 +169,8 @@ pcall(vim.cmd.edit, 'Xtest_swapredraw.lua')
exec(init)
command('edit! ' .. testfile)
command('preserve')
local nvim2 = n.new_session(true, { args = { '--clean', '--embed' }, merge = false })
local args2 = { '--clean', '--embed', '--cmd', n.runtime_set }
local nvim2 = n.new_session(true, { args = args2, merge = false })
set_session(nvim2)
local screen2 = Screen.new(100, 40)
screen2:add_extra_attr_ids({

View File

@@ -47,7 +47,8 @@ local setup_treesitter = function()
end
before_each(function()
clear({ args_rm = { '--cmd' }, args = { '--clean' } })
-- avoid options, but we still need TS parsers
clear({ args_rm = { '--cmd' }, args = { '--clean', '--cmd', n.runtime_set } })
end)
describe('commenting', function()

View File

@@ -245,8 +245,8 @@ describe('vim.fs', function()
describe('find()', function()
it('works', function()
eq(
{ test_build_dir .. '/build' },
vim.fs.find('build', { path = nvim_dir, upward = true, type = 'directory' })
{ test_build_dir .. '/bin' },
vim.fs.find('bin', { path = nvim_dir, upward = true, type = 'directory' })
)
eq({ nvim_prog }, vim.fs.find(nvim_prog_basename, { path = test_build_dir, type = 'file' }))
@@ -255,7 +255,7 @@ describe('vim.fs', function()
end)
it('follows symlinks', function()
local build_dir = test_source_path .. '/build' ---@type string
local build_dir = test_build_dir ---@type string
local symlink = test_source_path .. '/build_link' ---@type string
vim.uv.fs_symlink(build_dir, symlink, { junction = true, dir = true })
@@ -263,8 +263,11 @@ describe('vim.fs', function()
vim.uv.fs_unlink(symlink)
end)
local cases = { nvim_prog, symlink .. '/bin/' .. nvim_prog_basename }
table.sort(cases)
eq(
{ nvim_prog, symlink .. '/bin/' .. nvim_prog_basename },
cases,
vim.fs.find(nvim_prog_basename, {
path = test_source_path,
type = 'file',
@@ -273,6 +276,9 @@ describe('vim.fs', function()
})
)
if t.is_zig_build() then
return pending('broken with build.zig')
end
eq(
{ nvim_prog },
vim.fs.find(nvim_prog_basename, {
@@ -285,6 +291,9 @@ describe('vim.fs', function()
end)
it('follow=true handles symlink loop', function()
if t.is_zig_build() then
return pending('broken/slow with build.zig')
end
local cwd = test_source_path ---@type string
local symlink = test_source_path .. '/loop_link' ---@type string
vim.uv.fs_symlink(cwd, symlink, { junction = true, dir = true })
@@ -304,9 +313,9 @@ describe('vim.fs', function()
it('accepts predicate as names', function()
local opts = { path = nvim_dir, upward = true, type = 'directory' }
eq(
{ test_build_dir .. '/build' },
{ test_build_dir .. '/bin' },
vim.fs.find(function(x)
return x == 'build'
return x == 'bin'
end, opts)
)
eq(

View File

@@ -2100,9 +2100,9 @@ describe('lua stdlib', function()
eq(false, fn.luaeval "vim.v['false']")
eq(NIL, fn.luaeval 'vim.v.null')
matches([[attempt to index .* nil value]], pcall_err(exec_lua, 'return vim.v[0].progpath'))
eq('Key is read-only: count', pcall_err(exec_lua, [[vim.v.count = 42]]))
eq('Dict is locked', pcall_err(exec_lua, [[vim.v.nosuchvar = 42]]))
eq('Key is fixed: errmsg', pcall_err(exec_lua, [[vim.v.errmsg = nil]]))
matches('Key is read%-only: count$', pcall_err(exec_lua, [[vim.v.count = 42]]))
matches('Dict is locked$', pcall_err(exec_lua, [[vim.v.nosuchvar = 42]]))
matches('Key is fixed: errmsg$', pcall_err(exec_lua, [[vim.v.errmsg = nil]]))
exec_lua([[vim.v.errmsg = 'set by Lua']])
eq('set by Lua', eval('v:errmsg'))
exec_lua([[vim.v.errmsg = 42]])
@@ -2111,7 +2111,10 @@ describe('lua stdlib', function()
eq({ 'one', 'two' }, eval('v:oldfiles'))
exec_lua([[vim.v.oldfiles = {}]])
eq({}, eval('v:oldfiles'))
eq('Setting v:oldfiles to value with wrong type', pcall_err(exec_lua, [[vim.v.oldfiles = 'a']]))
matches(
'Setting v:oldfiles to value with wrong type$',
pcall_err(exec_lua, [[vim.v.oldfiles = 'a']])
)
eq({}, eval('v:oldfiles'))
feed('i foo foo foo<Esc>0/foo<CR>')

View File

@@ -491,7 +491,7 @@ describe('LSP', function()
vim._with({ buf = _G.BUFFER }, function()
keymap = vim.fn.maparg('K', 'n', false, false)
end)
return keymap:match('<Lua %d+: .+/runtime/lua/vim/lsp%.lua:%d+>') ~= nil
return keymap:match('<Lua %d+: .*runtime/lua/vim/lsp%.lua:%d+>') ~= nil
end)
)
end,
@@ -499,6 +499,9 @@ describe('LSP', function()
end)
it('should overwrite options set by ftplugins', function()
if t.is_zig_build() then
return pending('TODO: broken with zig build')
end
local client --- @type vim.lsp.Client
local BUFFER_1 --- @type integer
local BUFFER_2 --- @type integer

View File

@@ -17,7 +17,9 @@ local sleep = uv.sleep
--- Functions executing in the current nvim session/process being tested.
local M = {}
local runtime_set = 'set runtimepath^=./build/lib/nvim/'
local lib_path = t.is_zig_build() and './zig-out/lib' or './build/lib/nvim/'
M.runtime_set = 'set runtimepath^=' .. lib_path
M.nvim_prog = (os.getenv('NVIM_PRG') or t.paths.test_build_dir .. '/bin/nvim')
-- Default settings for the test session.
M.nvim_set = (
@@ -34,7 +36,7 @@ M.nvim_argv = {
'NONE',
-- XXX: find treesitter parsers.
'--cmd',
runtime_set,
M.runtime_set,
'--cmd',
M.nvim_set,
-- Remove default user commands and mappings.
@@ -425,7 +427,7 @@ local function remove_args(args, args_rm)
last = ''
elseif vim.tbl_contains(args_rm, arg) then
last = arg
elseif arg == runtime_set and vim.tbl_contains(args_rm, 'runtimepath') then
elseif arg == M.runtime_set and vim.tbl_contains(args_rm, 'runtimepath') then
table.remove(new_args) -- Remove the preceding "--cmd".
last = ''
else

View File

@@ -192,7 +192,7 @@ describe('eval-API', function()
local screen = Screen.new(40, 8)
command('set ft=vim')
command('set rtp^=build/runtime/')
n.add_builddir_to_rtp()
command('syntax on')
insert([[
call bufnr('%')