From 81e5a3b8fb417aca427d83e1e9db47065c157e98 Mon Sep 17 00:00:00 2001 From: Marco Kellershoff Date: Sat, 7 Sep 2024 16:50:35 +0200 Subject: [PATCH 1/2] Change testing framework to busted Reason: folke and echasnovski both use this. --- .github/workflows/tests.yml | 5 +---- .gitignore | 2 +- scripts/tests.sh | 41 ++----------------------------------- tests/init.vim | 2 -- tests/minimal_init.lua | 9 -------- tests/minit.lua | 11 ++++++++++ 6 files changed, 15 insertions(+), 55 deletions(-) delete mode 100644 tests/init.vim delete mode 100644 tests/minimal_init.lua create mode 100644 tests/minit.lua diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c03bbf4..70a4dc3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.gitignore b/.gitignore index 4b465d2..a9432b7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ http-client.env.json *.http *graphql-schema.json /http-examples -/_neovim +.tests diff --git a/scripts/tests.sh b/scripts/tests.sh index f8b4f02..b265a91 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -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() { @@ -51,9 +17,6 @@ main() { "run") run "$args" ;; - "prepare") - prepare "$args" - ;; *) echo "Invalid action" exit 1 diff --git a/tests/init.vim b/tests/init.vim deleted file mode 100644 index 5b10d82..0000000 --- a/tests/init.vim +++ /dev/null @@ -1,2 +0,0 @@ -runtime! plugin/plenary.vim -source tests/minimal_init.lua diff --git a/tests/minimal_init.lua b/tests/minimal_init.lua deleted file mode 100644 index bf1c476..0000000 --- a/tests/minimal_init.lua +++ /dev/null @@ -1,9 +0,0 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy" -vim.notify = print -vim.opt.rtp:append(".") -vim.opt.rtp:append(lazypath .. "/plenary.nvim") -vim.opt.swapfile = false -vim.cmd("runtime! plugin/plenary.vim") -A = function(...) - print(vim.inspect(...)) -end diff --git a/tests/minit.lua b/tests/minit.lua new file mode 100644 index 0000000..6820117 --- /dev/null +++ b/tests/minit.lua @@ -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() }, + }, +}) From 42b4e70b62da3b63f5a67072b0999987d0cc989d Mon Sep 17 00:00:00 2001 From: Marco Kellershoff Date: Sat, 7 Sep 2024 17:11:32 +0200 Subject: [PATCH 2/2] fix(ci): add busted to testrunner container --- tests/_dockerfiles/ubuntu/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/_dockerfiles/ubuntu/Dockerfile b/tests/_dockerfiles/ubuntu/Dockerfile index 57bfbb4..5ec7f7d 100644 --- a/tests/_dockerfiles/ubuntu/Dockerfile +++ b/tests/_dockerfiles/ubuntu/Dockerfile @@ -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