diff --git a/.gitignore b/.gitignore index 20acaa4..42c0336 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ tt.lua +.tests +doc/tags diff --git a/tests/init.lua b/tests/init.lua new file mode 100644 index 0000000..b5a94e8 --- /dev/null +++ b/tests/init.lua @@ -0,0 +1,32 @@ +local M = {} + +function M.root(root) + local f = debug.getinfo(1, "S").source:sub(2) + return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "") +end + +---@param plugin string +function M.load(plugin) + local name = plugin:match(".*/(.*)") + local package_root = M.root(".tests/site/pack/deps/start/") + if not vim.loop.fs_stat(package_root .. name) then + print("Installing " .. plugin) + vim.fn.mkdir(package_root, "p") + vim.fn.system({ + "git", + "clone", + "--depth=1", + "https://github.com/" .. plugin .. ".git", + package_root .. "/" .. name, + }) + end +end + +function M.setup() + vim.cmd([[set runtimepath=$VIMRUNTIME]]) + vim.opt.runtimepath:append(M.root()) + vim.opt.packpath = { M.root(".tests/site") } + M.load("nvim-lua/plenary.nvim") +end + +M.setup() diff --git a/tests/run b/tests/run new file mode 100755 index 0000000..f37e539 --- /dev/null +++ b/tests/run @@ -0,0 +1,3 @@ +#!/bin/sh + +nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"