From afa6b4b6195483d73cb6a91bc757652301275ed6 Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Sun, 8 Oct 2023 11:52:40 +0200 Subject: Add test cases --- test/init.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/init.lua (limited to 'test/init.lua') diff --git a/test/init.lua b/test/init.lua new file mode 100644 index 0000000..f05408e --- /dev/null +++ b/test/init.lua @@ -0,0 +1,37 @@ +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(".test/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(".test/site") } + M.load("nvim-lua/plenary.nvim") + vim.env.XDG_CONFIG_HOME = M.root(".test/config") + vim.env.XDG_DATA_HOME = M.root(".test/data") + vim.env.XDG_STATE_HOME = M.root(".test/state") + vim.env.XDG_CACHE_HOME = M.root(".test/cache") + vim.api.nvim_command([[source plugin/promql.lua]]) +end + +M.setup() -- cgit v1.2.3