Skip to content

Commit

Permalink
build: added plenary test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 28, 2022
1 parent 08f4804 commit f51eb0d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
tt.lua
.tests
doc/tags
32 changes: 32 additions & 0 deletions tests/init.lua
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 3 additions & 0 deletions tests/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"

0 comments on commit f51eb0d

Please sign in to comment.