|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | # |
3 | 3 | # Setup and run tests for lua part of gitlab.nvim. |
4 | | -# |
5 | | -# In order to run tests you need to have `luarocks` and `git` installed. This script will check if |
6 | | -# environment is already setup, if not it will initialize current directory with `luarocks`, |
7 | | -# install `busted` framework and download plugin dependencies. |
8 | | -# |
| 4 | +# Requires `luarocks`, `git`, and `nvim` installed. |
9 | 5 | # |
10 | | -set -e |
11 | 6 |
|
12 | | -LUA_VERSION="5.1" |
| 7 | +set -euo pipefail |
| 8 | + |
13 | 9 | PLUGINS_FOLDER="tests/plugins" |
14 | 10 | PLUGINS=( |
15 | | - "https://github.com/MunifTanjim/nui.nvim" |
16 | | - "https://github.com/nvim-lua/plenary.nvim" |
17 | | - "https://github.com/sindrets/diffview.nvim" |
| 11 | + "https://github.com/MunifTanjim/nui.nvim" |
| 12 | + "https://github.com/nvim-lua/plenary.nvim" |
| 13 | + "https://github.com/sindrets/diffview.nvim" |
18 | 14 | ) |
19 | 15 |
|
20 | | -if ! command -v luarocks > /dev/null 2>&1; then |
21 | | - echo "You need to have luarocks installed in order to run tests." |
22 | | - exit 1 |
23 | | -fi |
24 | | - |
25 | | -if ! command -v git > /dev/null 2>&1; then |
26 | | - echo "You need to have git installed in order to run tests." |
27 | | - exit 1 |
| 16 | +if ! command -v luarocks >/dev/null 2>&1; then |
| 17 | + echo "Error: luarocks not found. Please install LuaRocks." >&2 |
| 18 | + exit 1 |
28 | 19 | fi |
29 | 20 |
|
30 | | -if ! luarocks --lua-version=$LUA_VERSION which busted > /dev/null 2>&1; then |
31 | | - echo "Installing busted." |
32 | | - luarocks init |
33 | | - luarocks config --scope project lua_version "$LUA_VERSION" |
34 | | - luarocks install --lua-version="$LUA_VERSION" busted |
| 21 | +if ! command -v git >/dev/null 2>&1; then |
| 22 | + echo "Error: git not found. Please install Git." >&2 |
| 23 | + exit 1 |
35 | 24 | fi |
36 | 25 |
|
37 | | -for arg in "$@"; do |
38 | | -if [[ $arg =~ "--coverage" ]] && ! luarocks --lua-version=$LUA_VERSION which luacov > /dev/null 2>&1; then |
39 | | - luarocks install --lua-version="$LUA_VERSION" luacov |
40 | | - # lcov reporter for luacov - lcov format is supported by `nvim-coverage` |
41 | | - luarocks install --lua-version="$LUA_VERSION" luacov-reporter-lcov |
| 26 | +if ! command -v nvim >/dev/null 2>&1; then |
| 27 | + echo "Error: nvim not found. Please install Neovim." >&2 |
| 28 | + exit 1 |
42 | 29 | fi |
43 | | -done |
44 | 30 |
|
| 31 | +# Clone test plugin dependencies |
| 32 | +mkdir -p "$PLUGINS_FOLDER" |
45 | 33 | for plugin in "${PLUGINS[@]}"; do |
46 | | - plugin_name=${plugin##*/} |
47 | | - plugin_folder="$PLUGINS_FOLDER/$plugin_name" |
48 | | - |
49 | | - # Check if plugin was already downloaded |
50 | | - if [[ -d "$plugin_folder/.git" ]]; then |
51 | | - # We could also try to pull here but I am not sure if that wouldn't slow down tests too much. |
52 | | - continue |
53 | | - fi |
54 | | - |
| 34 | + plugin_name="${plugin##*/}" |
| 35 | + plugin_folder="$PLUGINS_FOLDER/$plugin_name" |
| 36 | + if [[ ! -d "$plugin_folder/.git" ]]; then |
| 37 | + echo "Cloning $plugin..." |
55 | 38 | git clone --depth 1 "$plugin" "$plugin_folder" |
56 | | - |
| 39 | + fi |
57 | 40 | done |
58 | 41 |
|
59 | | -nvim -u NONE -U NONE -N -i NONE -l tests/init.lua "$@" |
| 42 | +# Run tests |
| 43 | +echo "Running tests with Neovim..." |
| 44 | +nvim -u NONE -U NONE -N -i NONE -l tests/init.lua "$@" |
0 commit comments