mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 16:23:48 +00:00
This is in preparation of zig 0.17 where b.install_path is no longer known inside `pub fn build()`. Builds which should hardcode a runtime path into the binary has to specify it. We could use a nlua0 helper to encode the install path at build time but I think this is cleaner anyway. (like currently the appimage still encodes a temporary build path which is nonsensical, it is better to just include none) Similarily b.args will not be available anymore (there will just be an opaque pass-through)
48 lines
1.5 KiB
Lua
48 lines
1.5 KiB
Lua
local uv = vim.uv
|
|
|
|
---@return string
|
|
local function repo_root()
|
|
local source = debug.getinfo(1, 'S').source
|
|
assert(type(source) == 'string' and vim.startswith(source, '@'), 'failed to resolve runner path')
|
|
local script_path = assert(uv.fs_realpath(source:sub(2)), 'failed to resolve runner path')
|
|
return vim.fs.dirname(vim.fs.dirname(script_path))
|
|
end
|
|
|
|
---@param roots string[]
|
|
local function prepend_package_roots(roots)
|
|
local entries = {}
|
|
for _, root in ipairs(roots) do
|
|
entries[#entries + 1] = root .. '/?.lua'
|
|
entries[#entries + 1] = root .. '/?/init.lua'
|
|
end
|
|
|
|
package.path = table.concat(entries, ';') .. ';' .. package.path
|
|
end
|
|
|
|
_G.c_include_path = {}
|
|
while _G.arg[1] and vim.startswith(_G.arg[1], '-I') do
|
|
table.insert(_G.c_include_path, string.sub(table.remove(_G.arg, 1), 3))
|
|
end
|
|
if _G.arg[1] and vim.startswith(_G.arg[1], '-P') then
|
|
_G.nvim_build_dir = string.sub(table.remove(_G.arg, 1), 3)
|
|
|
|
vim.env.TMPDIR = _G.nvim_build_dir .. '/Xtest_tmpdir'
|
|
vim.env.NVIM_LOG_FILE = _G.nvim_build_dir .. '/Xtest_nvimlog'
|
|
end
|
|
|
|
local root = repo_root()
|
|
prepend_package_roots({ root, root .. '/test', '.', './test' })
|
|
|
|
-- The harness is not an Nvim instance under test. If its startup server stays
|
|
-- visible, serverlist({ peer = true }) can connect back to the runner and wait
|
|
-- forever for an RPC response.
|
|
if vim.v.servername ~= '' then
|
|
assert(vim.fn.serverstop(vim.v.servername) == 1)
|
|
end
|
|
|
|
local exit_code = require('test.harness').main(_G.arg)
|
|
io.stdout:flush()
|
|
io.stderr:flush()
|
|
|
|
os.exit(exit_code)
|