From ac2c12d68163b7599002603af62b230f60a53a81 Mon Sep 17 00:00:00 2001 From: MisanthropicBit Date: Fri, 10 Jan 2025 22:17:53 +0100 Subject: [PATCH] Add test run script --- .gitignore | 3 +++ run-tests.lua | 26 ++++++++++++++++++++++++++ tests/minimal_init.lua | 4 ---- winmove.nvim-scm-1.rockspec | 4 ++-- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 run-tests.lua delete mode 100644 tests/minimal_init.lua diff --git a/.gitignore b/.gitignore index 9f5a86a..7f2b59d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ doc/tags .test_output.tmp +lua_modules/ +luarocks +.luarocks/ diff --git a/run-tests.lua b/run-tests.lua new file mode 100644 index 0000000..236933e --- /dev/null +++ b/run-tests.lua @@ -0,0 +1,26 @@ +---@param command string +---@param args string[] +---@return string +local function run_command(command, args) + local result = vim.fn.system(vim.list_extend({ command }, args)) + + if vim.v.shell_error ~= 0 then + error("Failed to run command") + end + + return result +end + +-- Path for the plugin being tested +vim.opt.rtp:append(".") + +local lua_path = run_command("luarocks", { "path", "--lr-path" }) +local lua_cpath = run_command("luarocks", { "path", "--lr-cpath" }) + +-- Paths for the project-local luarocks packages +package.path = package.path .. ";" .. lua_path + +-- Paths for the project-local shared libraries +package.cpath = package.cpath .. ";" .. lua_cpath + +require("busted.runner")({ standalone = false }) diff --git a/tests/minimal_init.lua b/tests/minimal_init.lua deleted file mode 100644 index 8db925e..0000000 --- a/tests/minimal_init.lua +++ /dev/null @@ -1,4 +0,0 @@ -vim.opt.rtp:append(".") -vim.opt.rtp:append("./lua_modules/lua/plenary.nvim") - -vim.cmd.runtime({ "plugin/plenary.vim", bang = true }) diff --git a/winmove.nvim-scm-1.rockspec b/winmove.nvim-scm-1.rockspec index 53f9ac9..8b787ce 100644 --- a/winmove.nvim-scm-1.rockspec +++ b/winmove.nvim-scm-1.rockspec @@ -36,9 +36,9 @@ build = { test_dependencies = { "busted >= 2.2.0", - "neotest-busted >= 0.3.0", } test = { - type = "busted", + type = "command", + command = "nvim -l ./run-tests.lua", }