mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-08-03 17:45:05 +02:00
test: use busted for tests
This commit is contained in:
parent
46e5bdd6f1
commit
5e1c474192
4 changed files with 47 additions and 63 deletions
37
tests/busted.lua
Normal file
37
tests/busted.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env -S nvim -l
|
||||
|
||||
-- set stdpaths to use .tests
|
||||
local root = vim.fn.fnamemodify("./.tests", ":p")
|
||||
for _, name in ipairs({ "config", "data", "state", "cache" }) do
|
||||
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||
end
|
||||
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
vim.o.loadplugins = true -- enable since nvim -l disables plugins
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
{ "LazyVim/LazyVim", dir = vim.fn.expand(".") },
|
||||
"lunarmodules/busted", -- add busted
|
||||
"LazyVim/starter",
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "folke/lazy.nvim" },
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"williamboman/mason.nvim",
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
},
|
||||
rocks = { hererocks = true },
|
||||
})
|
||||
|
||||
-- run busted
|
||||
return pcall(require("busted.runner"), {
|
||||
standalone = false,
|
||||
}) or os.exit(1)
|
|
@ -38,13 +38,10 @@ describe("Extra", function()
|
|||
for _, extra in ipairs(extras) do
|
||||
local name = extra.modname:sub(#"lazyvim.plugins.extras" + 2)
|
||||
describe(name, function()
|
||||
---@type any, LazySpecLoader
|
||||
local mod, spec
|
||||
|
||||
it("spec is valid", function()
|
||||
mod = require(extra.modname)
|
||||
local mod = require(extra.modname)
|
||||
assert.is_not_nil(mod)
|
||||
spec = Plugin.Spec.new({
|
||||
local spec = Plugin.Spec.new({
|
||||
{ "williamboman/mason.nvim", opts = { ensure_installed = {} } },
|
||||
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },
|
||||
mod,
|
||||
|
@ -54,10 +51,17 @@ describe("Extra", function()
|
|||
|
||||
if extra.modname:find("%.lang%.") then
|
||||
it("has recommended set", function()
|
||||
local mod = require(extra.modname)
|
||||
assert(mod.recommended, "`recommended` not set for " .. extra.modname)
|
||||
end)
|
||||
end
|
||||
|
||||
local mod = require(extra.modname)
|
||||
local spec = Plugin.Spec.new({
|
||||
{ "williamboman/mason.nvim", opts = { ensure_installed = {} } },
|
||||
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },
|
||||
mod,
|
||||
}, { optional = true })
|
||||
local lspconfig = spec.plugins["nvim-lspconfig"]
|
||||
if lspconfig then
|
||||
it("does not install LSP servers with mason.nvim", function()
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
-- 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" },
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"williamboman/mason.nvim",
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
}
|
||||
|
||||
local function main()
|
||||
print("Installing plugins")
|
||||
require("lazy").setup(plugins, {
|
||||
root = root .. "/plugins",
|
||||
pkg = { enabled = false },
|
||||
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,
|
||||
})
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests {init = 'tests//init.lua', sequential = true}"
|
||||
nvim -l tests/busted.lua tests -o utfTerminal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue