|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | # |
3 | 3 | # Setup and run tests for lua part of gitlab.nvim. |
4 | | -# |
| 4 | +# |
5 | 5 | # In order to run tests you need to have `luarocks` and `git` installed. This script will check if |
6 | 6 | # environment is already setup, if not it will initialize current directory with `luarocks`, |
7 | 7 | # install `busted` framework and download plugin dependencies. |
8 | | -# |
| 8 | +# |
9 | 9 | # |
10 | 10 | set -e |
11 | 11 |
|
12 | | -LUA_VERSION="5.1" |
| 12 | +LUA_VERSION="5.4" |
13 | 13 | PLUGINS_FOLDER="tests/plugins" |
14 | 14 | PLUGINS=( |
15 | | - "https://github.com/MunifTanjim/nui.nvim" |
16 | | - "https://github.com/nvim-lua/plenary.nvim" |
17 | | - "https://github.com/sindrets/diffview.nvim" |
| 15 | + "https://github.com/MunifTanjim/nui.nvim" |
| 16 | + "https://github.com/nvim-lua/plenary.nvim" |
| 17 | + "https://github.com/sindrets/diffview.nvim" |
18 | 18 | ) |
19 | 19 |
|
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 |
| 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 | 23 | fi |
24 | 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 |
| 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 |
28 | 28 | fi |
29 | 29 |
|
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 |
| 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 |
35 | 35 | fi |
36 | 36 |
|
37 | 37 | for arg in "$@"; do |
38 | | -if [[ $arg =~ "--coverage" ]] && ! luarocks --lua-version=$LUA_VERSION which luacov > /dev/null 2>&1; then |
| 38 | + if [[ $arg =~ "--coverage" ]] && ! luarocks --lua-version=$LUA_VERSION which luacov >/dev/null 2>&1; then |
39 | 39 | luarocks install --lua-version="$LUA_VERSION" luacov |
40 | 40 | # lcov reporter for luacov - lcov format is supported by `nvim-coverage` |
41 | 41 | luarocks install --lua-version="$LUA_VERSION" luacov-reporter-lcov |
42 | | -fi |
| 42 | + fi |
43 | 43 | done |
44 | 44 |
|
45 | 45 | for plugin in "${PLUGINS[@]}"; do |
46 | | - plugin_name=${plugin##*/} |
47 | | - plugin_folder="$PLUGINS_FOLDER/$plugin_name" |
| 46 | + plugin_name=${plugin##*/} |
| 47 | + plugin_folder="$PLUGINS_FOLDER/$plugin_name" |
48 | 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 |
| 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 | 54 |
|
55 | | - git clone --depth 1 "$plugin" "$plugin_folder" |
| 55 | + git clone --depth 1 "$plugin" "$plugin_folder" |
56 | 56 |
|
57 | 57 | done |
58 | 58 |
|
59 | | -nvim -u NONE -U NONE -N -i NONE -l tests/init.lua "$@" |
| 59 | +nvim -u NONE -U NONE -N -i NONE -l tests/init.lua "$@" |
0 commit comments