From 9c1dd5a09065218a8aa67f251a2116cf74420b8c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 26 Jun 2024 14:30:55 +0200 Subject: [PATCH] test: buse busted for running tasks --- .busted | 11 +++++++++++ .github/workflows/ci.yml | 2 +- tests/busted.lua | 28 ++++++++++++++++++++++++++++ tests/init.lua | 36 ------------------------------------ tests/run | 3 --- 5 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 .busted create mode 100755 tests/busted.lua delete mode 100644 tests/init.lua delete mode 100755 tests/run diff --git a/.busted b/.busted new file mode 100644 index 0000000..98b3032 --- /dev/null +++ b/.busted @@ -0,0 +1,11 @@ +return { + _all = { + coverage = false, + }, + default = { + verbose = true, + }, + tests = { + verbose = true, + }, +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7c3dd2..0d20294 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: run: | nvim --version [ ! -d tests ] && exit 0 - nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}" + nvim -l tests/busted.lua tests community: runs-on: ubuntu-latest steps: diff --git a/tests/busted.lua b/tests/busted.lua new file mode 100755 index 0000000..146ab96 --- /dev/null +++ b/tests/busted.lua @@ -0,0 +1,28 @@ +#!/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.opt.rtp:prepend(".") + +vim.o.loadplugins = true -- enable since nvim -l disables plugins + +-- Setup lazy.nvim +require("lazy").setup({ + "lunarmodules/busted", -- add busted +}) + +-- run busted +return pcall(require("busted.runner"), { + standalone = false, +}) or os.exit(1) diff --git a/tests/init.lua b/tests/init.lua deleted file mode 100644 index 7b243c5..0000000 --- a/tests/init.lua +++ /dev/null @@ -1,36 +0,0 @@ -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.uv.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") - vim.env.XDG_CONFIG_HOME = M.root(".tests/config") - vim.env.XDG_DATA_HOME = M.root(".tests/data") - vim.env.XDG_STATE_HOME = M.root(".tests/state") - vim.env.XDG_CACHE_HOME = M.root(".tests/cache") -end - -M.setup() diff --git a/tests/run b/tests/run deleted file mode 100755 index 412d7b5..0000000 --- a/tests/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests {minimal_init = 'tests//init.lua', sequential = true}"