Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change testing framework to busted #219

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion tests/_dockerfiles/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM ubuntu:latest

RUN apt-get update && apt-get upgrade -y && apt-get install -y curl git gcc
RUN apt-get update && apt-get upgrade -y && apt-get install -y curl git gcc lua5.1 luarocks
RUN mkdir -p _neovim && curl -sL https://github.com/neovim/neovim/releases/download/v0.10.1/nvim-linux64.tar.gz | tar -xz -C _neovim && mv _neovim/nvim-linux64 /usr/local/nvim && rm -rf _neovim
RUN luarocks install busted
RUN ln -s /usr/local/nvim/bin/nvim /usr/bin/nvim
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() },
},
})