Skip to content

Commit 55a8fae

Browse files
committed
ci: run tests against new nvim-treesitter API
1 parent 8bb8697 commit 55a8fae

File tree

4 files changed

+23
-46
lines changed

4 files changed

+23
-46
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- master
7+
- stevearc-ci
78
pull_request:
89
branches:
910
- master
@@ -61,15 +62,14 @@ jobs:
6162
NVIM_TAG: ${{ matrix.nvim_tag }}
6263
steps:
6364
- uses: actions/checkout@v4
65+
- uses: tree-sitter/setup-action@v2
66+
with:
67+
install-lib: false
6468

6569
- name: Install Neovim and dependencies
6670
run: |
6771
bash ./.github/workflows/install_nvim.sh
6872
69-
- name: Install tree-sitter CLI
70-
run: |
71-
npm install -g tree-sitter-cli
72-
7373
- name: Run tests
7474
run: |
7575
bash ./run_tests.sh

run_tests.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#!/bin/bash
22
set -e
33

4-
NVIM_TREESITTER_BRANCH='master'
4+
NVIM_TREESITTER_BRANCH='main'
55

66
for arg in "$@"; do
77
shift
88
case "$arg" in
9-
'--update')
10-
export UPDATE_SYMBOLS=1
11-
if ! command -v jq >/dev/null; then
12-
echo "jq is required for --update. Please install jq"
13-
exit 1
14-
fi
15-
;;
16-
'--test-main')
17-
NVIM_TREESITTER_BRANCH='main'
18-
;;
19-
*)
20-
set -- "$@" "$arg"
21-
;;
9+
'--update')
10+
export UPDATE_SYMBOLS=1
11+
if ! command -v jq >/dev/null; then
12+
echo "jq is required for --update. Please install jq"
13+
exit 1
14+
fi
15+
;;
16+
'--test-master')
17+
NVIM_TREESITTER_BRANCH='master'
18+
;;
19+
*)
20+
set -- "$@" "$arg"
21+
;;
2222
esac
2323
done
2424

tests/minimal_init.lua

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,10 @@ if master_nvim_ts then
4141
)
4242
end, { nargs = "?" })
4343
else
44-
-- Use compiler that includes c++14 features by default
45-
-- If `cc` doesn't implement those, override it for tests run with
46-
-- `CC=gcc-13 ./run_tests.sh`
47-
local parser_config = require("nvim-treesitter.parsers").configs
48-
parser_config.norg = {
49-
install_info = {
50-
url = "https://github.com/nvim-neorg/tree-sitter-norg",
51-
files = { "src/parser.c", "src/scanner.cc" },
52-
branch = "main",
53-
},
54-
tier = 3,
55-
}
44+
require("nvim-treesitter").install(langs):wait(60000)
5645

5746
vim.api.nvim_create_user_command("RunTests", function(opts)
5847
local path = opts.fargs[1] or "tests"
59-
require("nvim-treesitter.install").install(langs, { skip = { installed = true } }, function()
60-
vim.schedule(function()
61-
require("plenary.test_harness").test_directory(
62-
path,
63-
-- nvim-treesitter `main` sets up some useful filetype mappings
64-
-- as a plugin, which doesn't get executed by plenary buster
65-
-- when running with `minimal_init`
66-
--
67-
-- While this can be circumvented by setting all the associations
68-
-- in the init, for some reason they don't get picked up by the
69-
-- time a spec gets executed, leading to false negatives
70-
{ init = "./tests/minimal_init.lua" }
71-
)
72-
end)
73-
end)
48+
require("plenary.test_harness").test_directory(path, { init = "./tests/minimal_init.lua" })
7449
end, { nargs = "?" })
7550
end

tests/treesitter_spec.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ local function list_files(dir)
2323
end
2424

2525
describe("treesitter", function()
26-
local skip_tests = {}
26+
-- norg is a pain to install because it requires specific gcc version.
27+
-- I'm disabling this for now. Will re-enable once it's easy to install.
28+
local skip_tests = { "norg_test.norg" }
2729
if vim.fn.has("nvim-0.11") == 0 then
2830
-- ABI version mismatch
2931
table.insert(skip_tests, "enforce_test.c")

0 commit comments

Comments
 (0)