-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
93 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
NVIM_EXEC ?= nvim | ||
|
||
# Run all test files | ||
# assuming `nv` is linked to nightly appimage | ||
# run with `make NVIM_EXEC="nvim nv" test` | ||
# to test on both stable and nightly | ||
# | ||
# Run all tests or specic module tests | ||
# | ||
# Test both stable and nightly (assuming `nv` is linked to nightly): | ||
# `make NVIM_EXEC="nvim nv" test` | ||
# | ||
# Test specific module(s) with `make test glob=file` | ||
# NOTE: glob is resolved using `vim.fn.globpath` so we can also run: | ||
# `make test glob=f | ||
# | ||
.PHONY: test | ||
test: | ||
for nvim_exec in $(NVIM_EXEC); do \ | ||
printf "\n======\n\n" ; \ | ||
$$nvim_exec --version | head -n 1 && echo '' ; \ | ||
$$nvim_exec --headless --noplugin -u ./scripts/minimal_init.lua \ | ||
-c "lua MiniTest.run()" ; \ | ||
-l ./scripts/make_cli.lua ; \ | ||
done | ||
|
||
# Run test from file at `$FILE` environment variable | ||
# run with `make FILE=tests/init_spec.lua test-file` | ||
.PHONY: test-file | ||
test-file: | ||
for nvim_exec in $(NVIM_EXEC); do \ | ||
printf "\n======\n\n" ; \ | ||
$$nvim_exec --version | head -n 1 && echo '' ; \ | ||
$$nvim_exec --headless --noplugin -u ./scripts/minimal_init.lua \ | ||
-c "lua MiniTest.run_file('$(FILE)')" ; \ | ||
done | ||
|
||
# Download 'mini.nvim' to use its 'mini.test' testing module | ||
prepare: | ||
# | ||
# Download 'mini.nvim' and `nvim-web-devicons` into "deps" subfolder | ||
# only used with the CI workflow, `minimal_init` will detect the deps | ||
# in our lazy.nvim local config | ||
# | ||
.PHONY: deps | ||
deps: | ||
make clean | ||
@mkdir -p deps | ||
git clone --depth=1 --single-branch https://github.com/echasnovski/mini.nvim deps/mini.nvim | ||
git clone --depth=1 --single-branch https://github.com/nvim-tree/nvim-web-devicons \ | ||
deps/nvim-web-devicons | ||
|
||
# clean up | ||
.PHONY: clean | ||
clean: | ||
rm -rf deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- NOTE: this script is called with `:help -l` | ||
local MiniTest = require("mini.test") | ||
local glob = vim.env.glob | ||
local find_files | ||
|
||
|
||
if glob then | ||
-- Find both "tests/glob**/*_spec.lua" and "test/glob*_spec.lua" | ||
find_files = function() | ||
local ret = vim.fn.globpath("tests", glob .. "*_spec.lua", true, true) | ||
for _, f in ipairs(vim.fn.globpath("tests", glob .. "**/*_spec.lua", true, true)) do | ||
table.insert(ret, f) | ||
end | ||
return ret | ||
end | ||
else | ||
-- All test files | ||
find_files = function() | ||
return vim.fn.globpath("tests", "**/*_spec.lua", true, true) | ||
end | ||
end | ||
|
||
MiniTest.run({ collect = { find_files = find_files } }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
---@diagnostic disable: unused-local, unused-function | ||
local MiniTest = require("mini.test") | ||
local helpers = dofile("tests/helpers.lua") | ||
local child = helpers.new_child_neovim() | ||
local expect, eq = helpers.expect, helpers.expect.equality | ||
local new_set = MiniTest.new_set | ||
|
||
-- Helpers with child processes | ||
--stylua: ignore start | ||
---@format disable-next | ||
local reload = function(config) child.unload(); child.setup(config) end | ||
local set_cursor = function(...) return child.set_cursor(...) end | ||
local get_cursor = function(...) return child.get_cursor(...) end | ||
local set_lines = function(...) return child.set_lines(...) end | ||
local get_lines = function(...) return child.get_lines(...) end | ||
local type_keys = function(...) return child.type_keys(...) end | ||
local sleep = function(ms) helpers.sleep(ms, child) end | ||
--stylua: ignore end | ||
|
||
local T = new_set({ | ||
hooks = { | ||
pre_case = function() | ||
child.init() | ||
child.setup({}) | ||
|
||
-- Make all showed messages full width | ||
child.o.cmdheight = 10 | ||
end, | ||
post_once = child.stop, | ||
}, | ||
-- n_retry = helpers.get_n_retry(2), | ||
}) | ||
|
||
T["setup()"] = new_set() | ||
|
||
T["setup()"]["setup global vars"] = function() | ||
-- Global vars | ||
eq(child.lua_get([[type(vim.g.fzf_lua_server)]]), "string") | ||
eq(child.lua_get([[type(vim.g.fzf_lua_directory)]]), "string") | ||
end | ||
|
||
return T |