Skip to content

Commit

Permalink
Change testing framework to busted
Browse files Browse the repository at this point in the history
Reason: folke and echasnovski both use this.
  • Loading branch information
gorillamoe committed Sep 7, 2024
1 parent f5abf3c commit 81e5a3b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 55 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ jobs:
uses: actions/cache@v4
with:
path: |
~/.local/share/nvim/site/pack/vendor/start
.tests
key: ${{ runner.os }}-${{ matrix.container-image }}

- name: Prepare dependencies
run: ./scripts/tests.sh prepare

- name: Run tests
run: ./scripts/tests.sh run
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ http-client.env.json
*.http
*graphql-schema.json
/http-examples
/_neovim
.tests
41 changes: 2 additions & 39 deletions scripts/tests.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,12 @@
#!/usr/bin/env bash

# Copy from MIT licensed neotest plugin:
# https://github.com/nvim-neotest/neotest/blob/958a6bff41c7086fe8b46f7f320d0fd073cfc6a0/scripts/test

prepare() {
if [[ ! -d ~/.local/share/nvim/site/pack/vendor/start/nvim-treesitter ]]; then
git clone --depth 1 \
https://github.com/nvim-treesitter/nvim-treesitter \
~/.local/share/nvim/site/pack/vendor/start/nvim-treesitter
fi
if [[ ! -d ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim ]]; then
git clone --depth 1 \
https://github.com/nvim-lua/plenary.nvim \
~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
fi
if [[ ! -d ~/.local/share/nvim/site/pack/vendor/start/kulala.nvim ]]; then
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start
fi
nvim --headless -c 'TSUpdate | TSInstallSync lua | quit'
}

run() {
local tempfile
tempfile=$(mktemp)

nvim --version

if [[ -n $1 ]]; then
nvim --headless --noplugin -u tests/init.vim -c "PlenaryBustedFile $1" | tee "${tempfile}"
nvim -l tests/minit.lua tests --filter "$1"
else
nvim --headless --noplugin -u tests/init.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.vim'}" | tee "${tempfile}"
fi

# Plenary doesn't emit exit code 1 when tests have errors during setup
errors=$(sed 's/\x1b\[[0-9;]*m//g' "${tempfile}" | awk '/(Errors|Failed) :/ {print $3}' | grep -v '0')

if [[ -n $errors ]]; then
echo "Tests failed"
exit 1
nvim -l tests/minit.lua tests
fi

exit 0
}

main() {
Expand All @@ -51,9 +17,6 @@ main() {
"run")
run "$args"
;;
"prepare")
prepare "$args"
;;
*)
echo "Invalid action"
exit 1
Expand Down
2 changes: 0 additions & 2 deletions tests/init.vim

This file was deleted.

9 changes: 0 additions & 9 deletions tests/minimal_init.lua

This file was deleted.

11 changes: 11 additions & 0 deletions tests/minit.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env -S nvim -l

vim.env.LAZY_STDPATH = ".tests"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

-- Setup lazy.nvim
require("lazy.minit").busted({
spec = {
{ dir = vim.uv.cwd() },
},
})

0 comments on commit 81e5a3b

Please sign in to comment.