From e50de0c4db2d0f6db81938c2bd76e9e49628101e Mon Sep 17 00:00:00 2001 From: Julien Vincent Date: Sun, 10 Mar 2024 19:41:15 +0200 Subject: [PATCH] Rework test command to be more flexible This reworks the test command to work better when switching between different nvim channels. Currently the .build/nvim dir needs to be deleted manually when switching to a different channel but now different channels are downloaded to separate directories. Additionally this adds support for specifying an individual file to run the tests for which improves the developer experience of working on tests. --- .github/workflows/test.yml | 7 ++--- Justfile | 57 +++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0af42b2..905134d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,8 +17,5 @@ jobs: - uses: extractions/setup-just@v1 - - name: Prepare ${{ matrix.channel }} - run: just prepare ${{ matrix.channel }} - - - name: Run Tests - run: just test + - name: Run tests [${{ matrix.channel }}] + run: just test ${{ matrix.channel }} diff --git a/Justfile b/Justfile index 982d493..24d5028 100644 --- a/Justfile +++ b/Justfile @@ -1,36 +1,47 @@ -prepare channel="stable": +[macos] +prepare-nvim channel: #!/usr/bin/env bash - test -d .build/nvim || { - mkdir -p ./.build/nvim - - os=$(uname) - if [[ "$os" == "Darwin" ]]; then - curl -L https://github.com/neovim/neovim/releases/download/{{ channel }}/nvim-macos.tar.gz > ./.build/nvim-macos.tar.gz - xattr -c ./.build/nvim-macos.tar.gz - tar xzf ./.build/nvim-macos.tar.gz -C ./.build/nvim --strip-components=1 - rm ./.build/nvim-macos.tar.gz - elif [[ "$os" == "Linux" ]]; then - curl -L https://github.com/neovim/neovim/releases/download/{{ channel }}/nvim-linux64.tar.gz > ./.build/nvim-linux64.tar.gz - tar xzf ./.build/nvim-linux64.tar.gz -C ./.build/nvim --strip-components=1 - rm ./.build/nvim-linux64.tar.gz - else - echo "Unsupported operating system: $os" - exit 1 - fi + NVIM_DIR=".build/nvim/{{ channel }}" + + test -d $NVIM_DIR || { + mkdir -p $NVIM_DIR + + curl -L https://github.com/neovim/neovim/releases/download/{{ channel }}/nvim-macos.tar.gz > ./.build/nvim-macos.tar.gz + xattr -c ./.build/nvim-macos.tar.gz + tar xzf ./.build/nvim-macos.tar.gz -C $NVIM_DIR --strip-components=1 + rm ./.build/nvim-macos.tar.gz + } + +[linux] +prepare-nvim channel: + #!/usr/bin/env bash + NVIM_DIR=".build/nvim/{{ channel }}" + + test -d $NVIM_DIR || { + mkdir -p $NVIM_DIR + + curl -L https://github.com/neovim/neovim/releases/download/{{ channel }}/nvim-linux64.tar.gz > ./.build/nvim-linux64.tar.gz + tar xzf ./.build/nvim-linux64.tar.gz -C $NVIM_DIR --strip-components=1 + rm ./.build/nvim-linux64.tar.gz } +prepare-dependencies: + #!/usr/bin/env bash test -d .build/dependencies || { mkdir -p ./.build/dependencies git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ./.build/dependencies/plenary.nvim git clone --depth 1 https://github.com/nvim-treesitter/nvim-treesitter ./.build/dependencies/nvim-treesitter } -tests_dir := "tests/nvim-paredit/" +prepare channel: (prepare-nvim channel) prepare-dependencies + +test channel="stable" file="": (prepare channel) + #!/usr/bin/env bash + NVIM_DIR=".build/nvim/{{ channel }}" -test: prepare - ./.build/nvim/bin/nvim --version - ./.build/nvim/bin/nvim \ + ./$NVIM_DIR/bin/nvim --version + ./$NVIM_DIR/bin/nvim \ --headless \ --noplugin \ -u tests/init.lua \ - -c "PlenaryBustedDirectory tests/nvim-paredit { minimal_init='tests/init.lua', sequential=true }" + -c "PlenaryBustedDirectory tests/nvim-paredit/{{ file }} { minimal_init='tests/init.lua', sequential=true }"