Skip to content

Commit

Permalink
chore: use mini.test plugin, and convert all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oysandvik94 committed Nov 23, 2024
1 parent e3e70d8 commit 2eab1b9
Show file tree
Hide file tree
Showing 25 changed files with 907 additions and 787 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
nvim --version
[ ! -d tests ] && exit 0
./tests/run
make test
docs:
if: github.ref == 'refs/heads/main'
permissions:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.tests
deps/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ The first and last line is the boundary for the curl command.

Tests can be run like this:

`./test/run`
`make test`
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Run all test files
test: deps/mini.nvim deps/plenary.nvim
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run()"

# Run test from file at `$FILE` environment variable
test_file: deps/mini.nvim deps/plenary.nvim
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run_file('$(FILE)')"

# Download 'mini.nvim' to use its 'mini.test' testing module
deps/mini.nvim:
@mkdir -p deps
git clone --filter=blob:none https://github.com/echasnovski/mini.nvim $@

deps/plenary.nvim:
@mkdir -p deps
git clone --filter=blob:none https://github.com/nvim-lua/plenary.nvim $@
13 changes: 13 additions & 0 deletions scripts/minimal_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Add current directory to 'runtimepath' to be able to use 'lua' files
vim.cmd([[let &rtp.=','.getcwd()]])

-- Set up 'mini.test' only when calling headless Neovim (like with `make test`)
if #vim.api.nvim_list_uis() == 0 then
-- Add 'mini.nvim' to 'runtimepath' to be able to use 'mini.test'
-- Assumed that 'mini.nvim' is stored in 'deps/mini.nvim'
vim.cmd("set rtp+=deps/mini.nvim")
vim.cmd("set rtp+=deps/plenary.nvim")

-- Set up 'mini.test'
require("mini.test").setup()
end
3 changes: 3 additions & 0 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120
67 changes: 0 additions & 67 deletions tests/api_spec.lua

This file was deleted.

127 changes: 0 additions & 127 deletions tests/buffers/buffer_spec.lua

This file was deleted.

15 changes: 0 additions & 15 deletions tests/busted.lua

This file was deleted.

68 changes: 0 additions & 68 deletions tests/cache_spec.lua

This file was deleted.

Loading

0 comments on commit 2eab1b9

Please sign in to comment.