refactor(tests): make tests independent from user nvim config
This commit is contained in:
parent
03cabf675c
commit
00d24d8ad6
4 changed files with 38 additions and 6 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
playground/
|
||||
/playground/
|
||||
/.tests/
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -8,4 +8,4 @@ lint:
|
|||
selene **/*.lua
|
||||
|
||||
test:
|
||||
nvim --headless -u ./spec/minimal_init.vim -c "PlenaryBustedDirectory spec {minimal_init='./spec/minimal_init.vim'}"
|
||||
nvim --headless -u ./spec/minimal_init.lua -c "PlenaryBustedDirectory spec {minimal_init='./spec/minimal_init.lua'}"
|
||||
|
|
|
|||
35
spec/minimal_init.lua
Normal file
35
spec/minimal_init.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
local function root(p)
|
||||
local f = debug.getinfo(1, "S").source:sub(2)
|
||||
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (p or "")
|
||||
end
|
||||
|
||||
local function install_plug(plugin)
|
||||
local name = plugin:match ".*/(.*)"
|
||||
local package_root = 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
|
||||
|
||||
vim.cmd [[set runtimepath=$VIMRUNTIME]]
|
||||
vim.opt.runtimepath:append(root())
|
||||
vim.opt.packpath = { root ".tests/site" }
|
||||
vim.notify = print
|
||||
|
||||
install_plug "nvim-lua/plenary.nvim"
|
||||
install_plug "nvim-treesitter/nvim-treesitter"
|
||||
install_plug "mfussenegger/nvim-dap"
|
||||
|
||||
vim.env.XDG_CONFIG_HOME = root ".tests/config"
|
||||
vim.env.XDG_DATA_HOME = root ".tests/data"
|
||||
vim.env.XDG_STATE_HOME = root ".tests/state"
|
||||
vim.env.XDG_CACHE_HOME = root ".tests/cache"
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
set rtp+=.
|
||||
packadd plenary.nvim
|
||||
packadd nvim-treesitter
|
||||
packadd nvim-dap
|
||||
Loading…
Add table
Add a link
Reference in a new issue