|
| 1 | +# This file is intended to be called by meta Make file |
| 2 | +export SHELL ?=bash |
| 3 | +export NVIM ?=nvim |
| 4 | + |
| 5 | +# tests: setup plenary.nvim |
| 6 | +#------------------------------------- |
| 7 | +# Find path to a plenary.nvim in differet package manager paths |
| 8 | +# this is used for local testing; in CI it's going to downloaded to a shortest path |
| 9 | +DEP_PLENARY_PATH = $(or $(shell _path=$(HOME)/.local/share/nvim/site/pack/opt/pack/plenary/start/plenary.nvim; test -d $${_path} && echo "$${_path}")) |
| 10 | +DEP_PLENARY_PATH = $(or $(shell _path=$(HOME)/.local/share/nvim/site/pack/packer/start/plenary.nvim; test -d $${_path} && echo "$${_path}")) |
| 11 | +DEP_PLENARY_PATH = $(or $(shell _path=$(HOME)/.local/share/nvim/lazy/plenary.nvim; test -d $${_path} && echo "$${_path}")) |
| 12 | +DEP_PLENARY_PATH := $(or $(DEP_PLENARY_PATH), $(HOME)/.local/share/nvim/lazy/plenary.nvim) |
| 13 | + |
| 14 | +.ONESHELL: |
| 15 | +.PHONY: $(DEP_PLENARY_PATH) |
| 16 | +$(DEP_PLENARY_PATH): |
| 17 | + # ping google public DNS to check if connected to WAN |
| 18 | + nc -4 -w 1 8.8.8.8 53 || { |
| 19 | + echo -e "$(tput setaf 5)info:$(tput op): github.com is unreachable, checkout your connection" |
| 20 | + exit 0 |
| 21 | + } |
| 22 | + if test -d "$(@)" ; |
| 23 | + then |
| 24 | + git -C "$(@)" pull origin master |
| 25 | + else |
| 26 | + mkdir -vp $@ |
| 27 | + git clone --no-tags --depth=1 --single-branch 'https://github.com/nvim-lua/plenary.nvim.git' "$(@)" |
| 28 | + fi |
| 29 | + |
| 30 | +# test: setup neovim versions for testing |
| 31 | +#------------------------------------- |
| 32 | +# Neovim versions to test |
| 33 | +NEOVIM_VERSIONS=v0.7.2 v0.8.3 v0.9.2 nightly |
| 34 | + |
| 35 | +include ../make/neovim-install.mk |
| 36 | + |
| 37 | +# tests for specific neovim versions |
| 38 | +# test-ubuntu-NVIM_VERSION |
| 39 | +# test-ubuntu-nightly etc. |
| 40 | +.PHONY: $(patsubst %,test-ubuntu-%,$(NEOVIM_VERSIONS)) |
| 41 | +.ONESHELL: |
| 42 | +$(patsubst %,test-ubuntu-%,$(NEOVIM_VERSIONS)): test-ubuntu-%: $(HOME)/.neovim/%/bin/nvim | $(DEP_PLENARY_PATH) |
| 43 | + cd .. |
| 44 | + if test -s tests/minimal_init.lua ; |
| 45 | + then |
| 46 | + PLENARY_PATH=$(DEP_PLENARY_PATH) \ |
| 47 | + VIM="$${HOME}/.neovim/$(*)/share/nvim/runtime" \ |
| 48 | + $(HOME)/.neovim/$(*)/bin/nvim \ |
| 49 | + --headless --noplugin -u tests/minimal_init.lua \ |
| 50 | + -c "PlenaryBustedDirectory tests/ { sequential = false }" |
| 51 | + else |
| 52 | + echo -e "$(@): $$(tput setaf 1)error:$$(tput op) tests/minimal_init.lua is not found. Aborting!" > /dev/stderr |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + |
| 56 | +# tests by using system-installed nvim |
| 57 | +.PHONY: test-current |
| 58 | +.ONESHELL: |
| 59 | +test-current: | $(DEP_PLENARY_PATH) |
| 60 | + cd .. |
| 61 | + command -v nvim && { |
| 62 | + PLENARY_PATH=$(DEP_PLENARY_PATH) \ |
| 63 | + $(NVIM) --clean --headless --noplugin -u tests/minimal_init.lua \ |
| 64 | + -c "PlenaryBustedDirectory tests/ { sequential = true }" |
| 65 | + } |
| 66 | + |
| 67 | +# all tests |
| 68 | +.PHONY: test |
| 69 | +.ONESHELL: |
| 70 | +test: $(patsubst %,test-ubuntu-%,$(NEOVIM_VERSIONS)) |
| 71 | + |
| 72 | +.PHONY: clean |
| 73 | +.ONESHELL: |
| 74 | +clean: |
| 75 | + # nightly is often updated |
| 76 | + rm -vrd $(HOME)/.neovim/nightly |
| 77 | + |
| 78 | +all: test |
0 commit comments