Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 100

[{Makefile,**/Makefile,*.mk,doc/*.txt}]
indent_style = tab
indent_size = 8
35 changes: 4 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,14 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
# 1. Checkout this plugin repo.
- uses: actions/checkout@v4

# - uses: rhysd/action-setup-vim@v1
# with:
# neovim: true
# version: nightly

# 2. Checkout Neovim source into a subdirectory.
- name: Checkout Neovim
uses: actions/checkout@v4
- uses: rhysd/action-setup-vim@v1
with:
repository: neovim/neovim
path: neovim
fetch-depth: 1

# 3. Install Neovim's test dependencies.
- name: Install deps
run: |
# sudo apt-get update
sudo apt-get install -y ninja-build gettext cmake curl build-essential git

# 4. Build Neovim (and run a dummy test). This avoids build noise in the logs for the next step.
- name: Setup Neovim test environment
env:
GH_TOKEN: ${{ github.token }}
NEOVIM_PATH: ${{ github.workspace }}/neovim
run: |
# make patch-runner
cd neovim
TEST_FILE=test/functional/example_spec.lua CMAKE_FLAGS="-D CI_BUILD=ON" make functionaltest
neovim: true
version: nightly

# 5. Run the plugin tests using Neovim’s framework.
- name: Run plugin tests
- name: Run tests
env:
GH_TOKEN: ${{ github.token }}
NEOVIM_PATH: ${{ github.workspace }}/neovim
run: make test
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
doc/tags
# XXX: can remove this after Nvim test harness is exposed as a runtime feature.
guh.nvim
.deps/
55 changes: 32 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
.PHONY: validate test
NVIM_PRG ?= nvim
TEST_FILE ?= test
TEST_FILTER ?=
# Cached in .deps/ ("rm -rf .deps" to update).
NVIM_TEST_VERSION ?= master
NVIM_TEST_URL ?= https://raw.githubusercontent.com/neovim/neovim/$(NVIM_TEST_VERSION)/test
TEST_DEPS := .deps/neovim/$(NVIM_TEST_VERSION)

TEST_CWD := $(shell pwd)
# Downloads to a temp dir, renamed after all downloads succeed.
$(TEST_DEPS):
rm -rf "$@.tmp"
curl --parallel --fail --location --silent --show-error --create-dirs \
--output "$@.tmp/test/#1" "$(NVIM_TEST_URL)/{\
assert.lua,\
client/rpc_stream.lua,\
client/session.lua,\
client/uv_stream.lua,\
functional/preload.lua,\
functional/testnvim.lua,\
functional/testnvim/exec_lua.lua,\
functional/ui/screen.lua,\
harness.lua,\
reporter.lua,\
runner.lua,\
testutil.lua}"
mv "$@.tmp" "$@"

validate:
ifeq ($(NEOVIM_PATH),)
$(error NEOVIM_PATH is not set. Export it or pass it like: make NEOVIM_PATH=/path/to/neovim test)
endif

# Run tests with "nvim -l" instead of "-ll", so tests can use the full "vim."
# API from the Nvim test harness process itself.
# patch-runner: validate
# @if grep -q -- "-ll " "$(NEOVIM_PATH)/cmake/RunTests.cmake"; then \
# echo "Patching RunTests.cmake (-ll → -l)..."; \
# sed -i.bak 's/-ll /-l /' "$(NEOVIM_PATH)/cmake/RunTests.cmake" && rm -f "$(NEOVIM_PATH)/cmake/RunTests.cmake.bak"; \
# else \
# echo "RunTests.cmake already patched; skipping."; \
# fi


test: validate
ln -sf $(shell pwd) $(NEOVIM_PATH)/test/functional/guh.nvim
@cd $(NEOVIM_PATH) && env GH_TOKEN=$${GH_TOKEN:-$(shell gh auth token 2>/dev/null)} \
TEST_CWD=$(TEST_CWD) \
TEST_FILE=test/functional/guh.nvim/test/gh_spec.lua make functionaltest
# LUA_PATH: `exec_lua` requires test modules in the Nvim under test.
.PHONY: test
test: $(TEST_DEPS)
GH_TOKEN="$${GH_TOKEN:-$$(gh auth token 2>/dev/null)}" NVIM_LOG_FILE="$(abspath .deps/nvim.log)" \
LUA_PATH="$(abspath $(TEST_DEPS))/?.lua;;" \
"$(NVIM_PRG)" --clean -l "$(TEST_DEPS)/test/runner.lua" -X"$(abspath .deps/xdg)" -v \
--helper="$(TEST_DEPS)/test/functional/preload.lua" $(if $(TEST_FILTER),--filter="$(TEST_FILTER)") "$(TEST_FILE)"
8 changes: 6 additions & 2 deletions doc/guh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,15 @@ View the logs: >

Run the tests: >

NEOVIM_PATH='/path/to/neovim/' make test
make test

Run specific tests: >

NEOVIM_PATH='/path/to/neovim/' make test TEST_FILTER=load_comments
make test TEST_FILTER=load_comments

Run the tests on a specific Nvim (default: "nvim" in $PATH): >

make test NVIM_PRG=/path/to/bin/nvim

------------------------------------------------------------------------------
ARCHITECTURE
Expand Down
12 changes: 4 additions & 8 deletions test/gh_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ local n = require('test.functional.testnvim')()
local t = require('test.testutil')
local describe, it, before_each = t.describe, t.it, t.before_each

local test_cwd = assert(os.getenv('TEST_CWD'))
local test_cwd = assert(vim.uv.cwd())

local screen
before_each(function()
n.clear {
args = {
'-c',
("cd '%s'"):format(test_cwd),
},
}
n.clear()
n.exec [[
set laststatus=2
]]
Expand Down Expand Up @@ -63,7 +58,8 @@ describe('guh.gh', function()

local task = async.run(function()
-- `pr_data.ci_jobs` is batched into the `get_pr_data` GraphQL query.
local pr = async.await(4, gh.get_pr_data, 9, 'justinmk/guh.nvim', { force = true })
-- NOTE: GitHub expires CI data after ~1 year, then need update this.
local pr = async.await(4, gh.get_pr_data, 97, 'justinmk/guh.nvim', { force = true })
assert(pr, 'failed to get PR')
local jobs = pr.ci_jobs or {}
assert(#jobs > 0, 'no CI jobs returned')
Expand Down
Loading