mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-08-18 16:28:37 +02:00
ci: added some tests
This commit is contained in:
parent
373d6b60e1
commit
106130f4cd
4 changed files with 91 additions and 1 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -41,7 +41,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
nvim --version
|
nvim --version
|
||||||
[ ! -d tests ] && exit 0
|
[ ! -d tests ] && exit 0
|
||||||
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
|
./tests/run
|
||||||
docs:
|
docs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: tests
|
needs: tests
|
||||||
|
|
34
tests/extras/lang_spec.lua
Normal file
34
tests/extras/lang_spec.lua
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
---@module 'luassert'
|
||||||
|
|
||||||
|
local Plugin = require("lazy.core.plugin")
|
||||||
|
_G.LazyVim = require("lazyvim.util")
|
||||||
|
|
||||||
|
describe("Extra", function()
|
||||||
|
local Config = require("lazy.core.config")
|
||||||
|
assert(vim.tbl_count(Config.plugins) > 0, "Lazy not properly setup")
|
||||||
|
|
||||||
|
---@type {modname:string, modpath:string}[]
|
||||||
|
local extras = vim.tbl_map(
|
||||||
|
---@param path string
|
||||||
|
function(path)
|
||||||
|
local modname = path:sub(5):gsub("%.lua$", ""):gsub("/", ".")
|
||||||
|
return { modname = modname, modpath = path }
|
||||||
|
end,
|
||||||
|
vim.fs.find(function(name)
|
||||||
|
return name:match("%.lua$")
|
||||||
|
end, { limit = math.huge, type = "file", path = "lua/lazyvim/plugins/extras" })
|
||||||
|
)
|
||||||
|
|
||||||
|
for _, extra in ipairs(extras) do
|
||||||
|
it(extra.modname .. " is valid", function()
|
||||||
|
local mod = require(extra.modname)
|
||||||
|
local spec = Plugin.Spec.new(mod, { optional = true })
|
||||||
|
assert.is_not_nil(mod)
|
||||||
|
assert(#spec.notifs == 0, "Invalid spec: " .. vim.inspect(spec.notifs))
|
||||||
|
|
||||||
|
if extra.modname:find("%.lang%.") then
|
||||||
|
assert(mod.recommended, "`recommended` not set for " .. extra.modname)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
53
tests/init.lua
Normal file
53
tests/init.lua
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
-- DO NOT change the paths and don't remove the colorscheme
|
||||||
|
local root = vim.fn.fnamemodify("./.tests", ":p")
|
||||||
|
|
||||||
|
-- set stdpaths to use .repro
|
||||||
|
for _, name in ipairs({ "config", "data", "state", "cache" }) do
|
||||||
|
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||||
|
end
|
||||||
|
|
||||||
|
-- bootstrap lazy
|
||||||
|
local lazypath = root .. "/plugins/lazy.nvim"
|
||||||
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
|
print("Bootstrapping lazy.nvim")
|
||||||
|
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
|
||||||
|
end
|
||||||
|
vim.opt.runtimepath:prepend(lazypath)
|
||||||
|
|
||||||
|
-- install plugins
|
||||||
|
local plugins = {
|
||||||
|
"LazyVim/starter",
|
||||||
|
{ "nvim-lua/plenary.nvim" },
|
||||||
|
{ "folke/lazy.nvim" },
|
||||||
|
}
|
||||||
|
|
||||||
|
local function main()
|
||||||
|
print("Installing plugins")
|
||||||
|
require("lazy").setup(plugins, {
|
||||||
|
root = root .. "/plugins",
|
||||||
|
performance = {
|
||||||
|
rtp = {
|
||||||
|
reset = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if vim.o.filetype == "lazy" then
|
||||||
|
vim.cmd.close()
|
||||||
|
end
|
||||||
|
|
||||||
|
print("Updating plugins")
|
||||||
|
-- update plugins, wait for it to finish and don't show the output
|
||||||
|
require("lazy").update({ wait = true, show = false })
|
||||||
|
-- require("lazy.core.cache").reset()
|
||||||
|
|
||||||
|
vim.opt.rtp:append(".")
|
||||||
|
end
|
||||||
|
|
||||||
|
local Util = require("lazy.core.util")
|
||||||
|
Util.try(main, {
|
||||||
|
on_error = function(err)
|
||||||
|
print(err)
|
||||||
|
os.exit(1)
|
||||||
|
end,
|
||||||
|
})
|
3
tests/run
Executable file
3
tests/run
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests {init = 'tests//init.lua', sequential = true}"
|
Loading…
Add table
Add a link
Reference in a new issue