Skip to content

Commit

Permalink
test: migrate to nvim-test
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Apr 3, 2024
1 parent 955d16e commit 096d083
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 3,440 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ jobs:

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

- name: Download Nvim
run: make nvim

- name: Download Busted
run: make busted
- name: Download nvim-test
run: make nvim-test

- name: Run Test
run: make test
Expand All @@ -69,8 +66,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Download Nvim
run: make nvim
- uses: leafo/gh-actions-lua@v9
with:
luaVersion: "5.1.5"

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

- name: Download nvim-test
run: make nvim-test

- name: Doc Check
run: make doc-check
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ doc/tags

scratch/dummy_ignored.txt

nvim-test-*
nvim-runner-*

.luarocks
nvim-test

stylua
1 change: 1 addition & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"library": [
"lua",
"$VIMRUNTIME",
"nvim-test",
"${3rd}/busted/library",
"${3rd}/luassert/library",
"${3rd}/luv/library"
Expand Down
78 changes: 15 additions & 63 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,90 +3,42 @@ export PJ_ROOT=$(PWD)

FILTER ?= .*

NVIM_RUNNER_VERSION := v0.9.5
NVIM_TEST_VERSION ?= v0.9.5
export NVIM_RUNNER_VERSION := v0.9.5
export NVIM_TEST_VERSION ?= v0.9.5

ifeq ($(shell uname -s),Darwin)
UNAME ?= MACOS
else
UNAME ?= LINUX
endif

NVIM_PLATFORM_MACOS := macos
NVIM_PLATFORM_LINUX := linux64
NVIM_PLATFORM ?= $(NVIM_PLATFORM_$(UNAME))
NVIM_TEST_PLATFORM := $(NVIM_PLATFORM)
NVIM_RUNNER_PLATFORM := $(NVIM_PLATFORM)

ifeq ($(NVIM_PLATFORM),macos)
ifeq ($(NVIM_RUNNER_VERSION),nightly)
NVIM_RUNNER_PLATFORM ?= $(NVIM_PLATFORM)-$(shell uname -m)
endif

ifeq ($(NVIM_TEST_VERSION),nightly)
NVIM_TEST_PLATFORM ?= $(NVIM_PLATFORM)-$(shell uname -m)
endif
endif

NVIM_URL := https://github.com/neovim/neovim/releases/download

NVIM_RUNNER := nvim-runner-$(NVIM_RUNNER_VERSION)
NVIM_RUNNER_URL := $(NVIM_URL)/$(NVIM_RUNNER_VERSION)/nvim-$(NVIM_TEST_PLATFORM).tar.gz

NVIM_TEST := nvim-test-$(NVIM_TEST_VERSION)
NVIM_TEST_URL := $(NVIM_URL)/$(NVIM_TEST_VERSION)/nvim-$(NVIM_TEST_PLATFORM).tar.gz

export NVIM_PRG = $(NVIM_TEST)/bin/nvim

.DEFAULT_GOAL := build

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

$(NVIM_RUNNER):
$(call fetch_nvim,$(NVIM_RUNNER_URL))

$(NVIM_TEST):
$(call fetch_nvim,$(NVIM_TEST_URL))

.PHONY: nvim
nvim: $(NVIM_RUNNER) $(NVIM_TEST)

LUAROCKS := luarocks --lua-version=5.1 --tree .luarocks

.luarocks/bin/busted:
$(LUAROCKS) install busted

.PHONY: busted
busted: .luarocks/bin/busted
nvim-test:
git clone https://github.com/lewis6991/nvim-test
nvim-test/bin/nvim-test --init

.PHONY: test
test: $(NVIM_RUNNER) $(NVIM_TEST) .luarocks/bin/busted
eval $$($(LUAROCKS) path) && $(NVIM_RUNNER)/bin/nvim -ll test/busted/runner.lua -v \
--lazy \
--helper=$(PWD)/test/preload.lua \
--output test.busted.output_handler \
test: nvim-test
NVIM_TEST_VERSION=$(NVIM_TEST_VERSION) \
nvim-test/bin/nvim-test test \
--lpath=$(PWD)/lua/?.lua \
--filter="$(FILTER)" \
$(PWD)/test
--verbose \
--filter="$(FILTER)"

-@stty sane

.PHONY: test-all
test-all:
$(MAKE) test NVIM_TEST_VERSION=v0.8.3
$(MAKE) test NVIM_TEST_VERSION=v0.9.2
$(MAKE) test NVIM_TEST_VERSION=v0.9.5
$(MAKE) test NVIM_TEST_VERSION=nightly

export XDG_DATA_HOME ?= $(HOME)/.data

.PHONY: gen_help
gen_help: $(NVIM_RUNNER)
@$(NVIM_RUNNER)/bin/nvim -l ./gen_help.lua
gen_help: nvim-test
$(XDG_DATA_HOME)/nvim-test/nvim-runner-$(NVIM_RUNNER_VERSION)/bin/nvim -l ./gen_help.lua
@echo Updated help

STYLUA_PLATFORM_MACOS := macos-aarch64
Expand Down
5 changes: 1 addition & 4 deletions gen_help.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/sh
_=[[
exec nvim -l "$0" "$@"
]]
#!/usr/bin/env -S nvim -l
-- Simple script to update the help doc by reading the config schema.

local inspect = vim.inspect
Expand Down
1 change: 1 addition & 0 deletions test/actions_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('actions', function()

describe('staging partial hunks', function()
setup(function()
clear()
setup_test_repo({ test_file_text = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' } })
end)

Expand Down
Loading

0 comments on commit 096d083

Please sign in to comment.