aboutsummaryrefslogtreecommitdiff
path: root/test/runner.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2026-03-25 13:33:17 +0000
committerLewis Russell <lewis6991@gmail.com>2026-04-15 12:09:25 +0100
commit55f9c2136e52d8719495b6021ce7e8d64c5141fe (patch)
tree0f2b934f30af2b232453b3e676fd9cd7f32e7957 /test/runner.lua
parente289f9579c73b4f6da105dfad87bd90e0dc6d973 (diff)
downloadrneovim-55f9c2136e52d8719495b6021ce7e8d64c5141fe.tar.gz
rneovim-55f9c2136e52d8719495b6021ce7e8d64c5141fe.tar.bz2
rneovim-55f9c2136e52d8719495b6021ce7e8d64c5141fe.zip
test: replace busted with local harness
Replace the busted-based Lua test runner with a repo-local harness. The new harness runs spec files directly under `nvim -ll`, ships its own reporter and lightweight `luassert` shim, and keeps the helper/preload flow used by the functional and unit test suites. Keep the file boundary model shallow and busted-like by restoring `_G`, `package.loaded`, `package.preload`, `arg`, and the process environment between files, without carrying extra reset APIs or custom assertion machinery. Update the build and test entrypoints to use the new runner, add black-box coverage for the harness itself, and drop the bundled busted/luacheck dependency path. AI-assisted: Codex
Diffstat (limited to 'test/runner.lua')
-rw-r--r--test/runner.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/runner.lua b/test/runner.lua
new file mode 100644
index 0000000000..a73719893d
--- /dev/null
+++ b/test/runner.lua
@@ -0,0 +1,35 @@
+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
+
+local root = repo_root()
+prepend_package_roots({ root, root .. '/test', '.', './test' })
+
+local exit_code = require('test.harness').main(_G.arg)
+io.stdout:flush()
+io.stderr:flush()
+
+-- Close the standalone Lua state before exit so sanitizers see Lua-owned cleanup.
+os.exit(exit_code, true)