Skip to content

Commit

Permalink
fix: vendor testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jun 13, 2023
1 parent 62e2b01 commit 401f45b
Show file tree
Hide file tree
Showing 20 changed files with 3,483 additions and 143 deletions.
51 changes: 20 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,36 @@ jobs:
# Check commit messages
- uses: webiny/action-conventional-commits@v1.1.0

build:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
neovim_branch: ['v0.8.3', 'v0.9.1', 'nightly']
runs-on: ubuntu-latest
neovim_branch:
- 'v0.8.3'
- 'v0.9.1'
- 'nightly'

env:
NEOVIM_BRANCH: ${{ matrix.neovim_branch }}
NVIM_TEST_VERSION: ${{ matrix.neovim_branch }}
NVIM_PLATFORM: linux64

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get Neovim SHA
id: get-nvim-sha
run: |
echo "sha=$(git ls-remote https://github.com/neovim/neovim ${{env.NEOVIM_BRANCH}} | cut -f1)" >> $GITHUB_OUTPUT
- name: Cache Deps
id: cache-deps
uses: actions/cache@v3
- uses: leafo/gh-actions-lua@v9
with:
path: deps
key: ${{ steps.get-nvim-sha.outputs.sha }}-${{ hashFiles('.github/workflows/ci.yml', 'Makefile') }}

- name: Install Neovim build dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
sudo apt-get update &&
sudo apt-get install -y \
cmake \
g++ \
gettext \
libtool-bin \
lua-bitop \
ninja-build \
unzip
- name: Build Neovim
if: steps.cache-deps.outputs.cache-hit != 'true'
run: make test_deps
luaVersion: "5.1.5"

- uses: leafo/gh-actions-luarocks@v4

- name: install busted
run: luarocks install busted

- name: Download Nvim
run: make nvim

- name: Run Test
run: make test
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
doc/tags

neovim

scratch/dummy_ignored.txt

nvim-test-*
nvim-runner-*
76 changes: 30 additions & 46 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,57 @@ export PJ_ROOT=$(PWD)

FILTER ?= .*

LUA_VERSION := 5.1
NEOVIM_BRANCH ?= master
NVIM_RUNNER_VERSION := v0.9.1
NVIM_TEST_VERSION ?= v0.9.1

DEPS_DIR := $(PWD)/deps/nvim-$(NEOVIM_BRANCH)
NVIM_DIR := $(DEPS_DIR)/neovim
NVIM_PLATFORM ?= macos
# NVIM_PLATFORM := linux64

LUAROCKS := luarocks
LUAROCKS_TREE := $(DEPS_DIR)/luarocks/usr
LUAROCKS_LPATH := $(LUAROCKS_TREE)/share/lua/$(LUA_VERSION)
LUAROCKS_INIT := eval $$($(LUAROCKS) --tree $(LUAROCKS_TREE) path) &&
NVIM_URL := https://github.com/neovim/neovim/releases/download

.DEFAULT_GOAL := build

$(NVIM_DIR):
@mkdir -p $(DEPS_DIR)
git clone --depth 1 https://github.com/neovim/neovim --branch $(NEOVIM_BRANCH) $@
@# disable LTO to reduce compile time
make -C $@ \
DEPS_BUILD_DIR=$(dir $(LUAROCKS_TREE)) \
CMAKE_BUILD_TYPE=RelWithDebInfo \
CMAKE_EXTRA_FLAGS='-DCI_BUILD=OFF -DENABLE_LTO=OFF'
NVIM_RUNNER := nvim-runner-$(NVIM_RUNNER_VERSION)
NVIM_RUNNER_URL := $(NVIM_URL)/$(NVIM_RUNNER_VERSION)/nvim-$(NVIM_PLATFORM).tar.gz

INSPECT := $(LUAROCKS_LPATH)/inspect.lua
NVIM_TEST := nvim-test-$(NVIM_TEST_VERSION)
NVIM_TEST_URL := $(NVIM_URL)/$(NVIM_TEST_VERSION)/nvim-$(NVIM_PLATFORM).tar.gz

$(INSPECT): $(NVIM_DIR)
@mkdir -p $$(dirname $@)
$(LUAROCKS) --tree $(LUAROCKS_TREE) install inspect
touch $@
export NVIM_PRG = $(NVIM_TEST)/bin/nvim

LUV := $(LUAROCKS_TREE)/lib/lua/$(LUA_VERSION)/luv.so

$(LUV): $(NVIM_DIR)
@mkdir -p $$(dirname $@)
$(LUAROCKS) --tree $(LUAROCKS_TREE) install luv
.DEFAULT_GOAL := build

.PHONY: lua_deps
lua_deps: $(INSPECT)
define fetch_nvim
rm -rf $@
rm -rf nvim-$(NVIM_PLATFORM).tar.gz
wget $(1)
tar -xf nvim-$(NVIM_PLATFORM).tar.gz
rm -rf nvim-$(NVIM_PLATFORM).tar.gz
mv nvim-$(NVIM_PLATFORM) $@
endef

.PHONY: test_deps
test_deps: $(NVIM_DIR)
$(NVIM_RUNNER):
$(call fetch_nvim,$(NVIM_RUNNER_URL))

export VIMRUNTIME=$(NVIM_DIR)/runtime
export TEST_COLORS=1
$(NVIM_TEST):
$(call fetch_nvim,$(NVIM_TEST_URL))

BUSTED = $$( [ -f $(NVIM_DIR)/test/busted_runner.lua ] \
&& echo "$(NVIM_DIR)/build/bin/nvim -ll $(NVIM_DIR)/test/busted_runner.lua" \
|| echo "$(LUAROCKS_INIT) busted" )
.PHONY: nvim
nvim: $(NVIM_RUNNER) $(NVIM_TEST)

.PHONY: test
test: $(NVIM_DIR)
$(BUSTED) -v \
test: $(NVIM_RUNNER) $(NVIM_TEST)
$(NVIM_RUNNER)/bin/nvim -ll test/busted/runner.lua -v \
--lazy \
--helper=$(PWD)/test/preload.lua \
--output test.busted.outputHandlers.nvim \
--lpath=$(NVIM_DIR)/?.lua \
--lpath=$(NVIM_DIR)/build/?.lua \
--lpath=$(NVIM_DIR)/runtime/lua/?.lua \
--lpath=$(DEPS_DIR)/?.lua \
--output test.busted.output_handler \
--lpath=$(PWD)/lua/?.lua \
--filter="$(FILTER)" \
$(PWD)/test

-@stty sane

.PHONY: gen_help
gen_help: $(INSPECT)
@$(LUAROCKS_INIT) ./gen_help.lua
gen_help:
@./gen_help.lua
@echo Updated help

.PHONY: build
Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/signs/vimfn.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/actions_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('actions', function()
clear()
-- Make gitisigns available
exec_lua('package.path = ...', package.path)
config = helpers.deepcopy(test_config)
config = vim.deepcopy(test_config)
command('cd '..system{"dirname", os.tmpname()})
setup_gitsigns(config)
end)
Expand Down
Loading

0 comments on commit 401f45b

Please sign in to comment.