mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 03:26:52 -04:00
fix tests
disable Windows tests for now (hang on parser compile)
This commit is contained in:
parent
7681249bbd
commit
008cc677d2
12 changed files with 73 additions and 65 deletions
48
.github/workflows/test-queries.yml
vendored
48
.github/workflows/test-queries.yml
vendored
|
|
@ -1,12 +1,12 @@
|
|||
name: Test queries
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
# push:
|
||||
# branches:
|
||||
# - "main"
|
||||
pull_request:
|
||||
branches:
|
||||
- "master"
|
||||
- "main"
|
||||
|
||||
# Cancel any in-progress CI runs for a PR if it is updated
|
||||
concurrency:
|
||||
|
|
@ -24,29 +24,33 @@ jobs:
|
|||
matrix:
|
||||
os: [ubuntu-latest, windows-2022, macos-latest]
|
||||
cc: [gcc, clang]
|
||||
nvim_tag: [stable]
|
||||
nvim_tag: [nightly]
|
||||
exclude:
|
||||
- os: ubuntu-latest
|
||||
cc: clang
|
||||
nvim_tag: stable
|
||||
nvim_tag: nightly
|
||||
|
||||
- os: macos-latest
|
||||
cc: gcc
|
||||
nvim_tag: stable
|
||||
nvim_tag: nightly
|
||||
|
||||
- os: windows-2022
|
||||
cc: gcc
|
||||
nvim_tag: nightly
|
||||
|
||||
- os: windows-2022
|
||||
cc: clang
|
||||
nvim_tag: stable
|
||||
|
||||
include:
|
||||
- os: windows-2022
|
||||
cc: cl
|
||||
nvim_tag: stable
|
||||
|
||||
- os: ubuntu-latest
|
||||
cc: gcc
|
||||
nvim_tag: nightly
|
||||
|
||||
# include:
|
||||
# - os: windows-2022
|
||||
# cc: cl
|
||||
# nvim_tag: nightly
|
||||
|
||||
# - os: ubuntu-latest
|
||||
# cc: gcc
|
||||
# nvim_tag: nightly
|
||||
|
||||
name: Parser compilation
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
|
|
@ -72,16 +76,12 @@ jobs:
|
|||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
./parser/
|
||||
~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/
|
||||
key: ${{ matrix.os }}-${{ matrix.cc }}-${{ matrix.nvim_tag }}-parsers-v1-${{ hashFiles('./lockfile.json', './lua/nvim-treesitter/parsers.lua', './lua/nvim-treesitter/install.lua', './lua/nvim-treesitter/shell_command_selectors.lua') }}
|
||||
~/.local/share/nvim/site/parser/
|
||||
~/AppData/Local/nvim-data/site/parser/
|
||||
key: ${{ matrix.os }}-${{ matrix.cc }}-${{ matrix.nvim_tag }}-parsers-v1-${{ hashFiles('./lockfile.json', './lua/nvim-treesitter/parsers.lua', './lua/nvim-treesitter/install.lua', './lua/nvim-treesitter/util.lua') }}
|
||||
|
||||
- name: Compile parsers
|
||||
run: $NVIM --headless -c "lua require'nvim-treesitter.install'.prefer_git=false" -c "TSInstallSync all" -c "q"
|
||||
|
||||
- name: Post compile Windows
|
||||
if: matrix.os == 'windows-2022'
|
||||
run: cp -r ~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/* parser
|
||||
run: $NVIM -l ./scripts/install-parsers.lua
|
||||
|
||||
- name: Check query files
|
||||
run: ./scripts/check-queries.lua
|
||||
|
|
|
|||
13
.github/workflows/tests.yml
vendored
13
.github/workflows/tests.yml
vendored
|
|
@ -1,12 +1,12 @@
|
|||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
# push:
|
||||
# branches:
|
||||
# - "main"
|
||||
pull_request:
|
||||
branches:
|
||||
- "master"
|
||||
- "main"
|
||||
|
||||
# Cancel any in-progress CI runs for a PR if it is updated
|
||||
concurrency:
|
||||
|
|
@ -42,7 +42,7 @@ jobs:
|
|||
|
||||
- name: Install and prepare Neovim
|
||||
env:
|
||||
NVIM_TAG: stable
|
||||
NVIM_TAG: nightly
|
||||
TREE_SITTER_CLI_TAG: v0.20.8
|
||||
run: |
|
||||
bash ./scripts/ci-install-${{ matrix.os }}.sh
|
||||
|
|
@ -58,8 +58,7 @@ jobs:
|
|||
|
||||
- name: Compile parsers Unix like
|
||||
if: ${{ matrix.os != 'windows-latest' && steps.parsers-cache.outputs.cache-hit != 'true' }}
|
||||
run: |
|
||||
nvim --headless -c "TSInstallSync all" -c "q"
|
||||
run: nvim -l ./scripts/install-parsers.lua
|
||||
|
||||
- name: Tests
|
||||
run: PATH=/usr/local/bin:$PATH ./scripts/run_tests.sh
|
||||
|
|
|
|||
2
.github/workflows/update-lockfile.yml
vendored
2
.github/workflows/update-lockfile.yml
vendored
|
|
@ -12,7 +12,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
ref: main
|
||||
|
||||
- name: Prepare
|
||||
env:
|
||||
|
|
|
|||
2
.github/workflows/update-readme.yml
vendored
2
.github/workflows/update-readme.yml
vendored
|
|
@ -3,7 +3,7 @@ name: Update README
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
|
|
|||
3
TODO.md
3
TODO.md
|
|
@ -5,8 +5,9 @@ This document lists the planned and finished changes in this rewrite towards [Nv
|
|||
## TODO
|
||||
|
||||
- [ ] **`query_predicates.lua`:** upstream/remove
|
||||
- [ ] **`parsers.lua`:** modularize?
|
||||
- [ ] **`parsers.lua`:** add dependencies (and "query-only" langs like ecma, jsx, html_tags, ...)
|
||||
- [ ] **`parsers.lua`:** assign tiers
|
||||
- [ ] **`parsers.lua`:** modularize?
|
||||
- [ ] **`install.lua`:** simplify compilation:
|
||||
- hardcode one compiler + args per platform
|
||||
- provide `install.compile_command` for overriding (function that takes files, ...?)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local query = vim.treesitter.query
|
||||
|
||||
-- register custom predicates
|
||||
-- register custom predicates (overwrite existing; needed for CI)
|
||||
|
||||
---@param match (TSNode|nil)[]
|
||||
---@param pred string[]
|
||||
|
|
@ -13,7 +13,7 @@ query.add_predicate('has-type?', function(match, _, _, pred)
|
|||
|
||||
local types = { unpack(pred, 3) }
|
||||
return vim.list_contains(types, node:type())
|
||||
end)
|
||||
end, true)
|
||||
|
||||
-- register custom directives
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ query.add_directive('set-lang-from-mimetype!', function(match, _, bufnr, pred, m
|
|||
local parts = vim.split(type_attr_value, '/', {})
|
||||
metadata['injection.language'] = parts[#parts]
|
||||
end
|
||||
end)
|
||||
end, true)
|
||||
|
||||
local injection_aliases = {
|
||||
ex = 'elixir',
|
||||
|
|
@ -68,7 +68,7 @@ query.add_directive('set-lang-from-info-string!', function(match, _, bufnr, pred
|
|||
local injection_alias = vim.treesitter.get_node_text(node, bufnr)
|
||||
local filetype = vim.filetype.match({ filename = 'a.' .. injection_alias })
|
||||
metadata['injection.language'] = filetype or injection_aliases[injection_alias] or injection_alias
|
||||
end)
|
||||
end, true)
|
||||
|
||||
query.add_directive('downcase!', function(match, _, bufnr, pred, metadata)
|
||||
local text, key, value ---@type string|string[], string, string|integer
|
||||
|
|
@ -95,7 +95,7 @@ query.add_directive('downcase!', function(match, _, bufnr, pred, metadata)
|
|||
else
|
||||
metadata[key] = string.lower(text)
|
||||
end
|
||||
end)
|
||||
end, true)
|
||||
|
||||
-- Trim blank lines from end of the region
|
||||
-- Arguments are the captures to trim.
|
||||
|
|
@ -138,4 +138,4 @@ query.add_directive('trim!', function(match, _, bufnr, pred, metadata)
|
|||
metadata[id].range = { start_row, start_col, end_row, end_col }
|
||||
end
|
||||
end
|
||||
end)
|
||||
end, true)
|
||||
|
|
|
|||
|
|
@ -104,17 +104,20 @@ local ok, result = pcall(do_check)
|
|||
local allowed_to_fail = vim.split(vim.env.ALLOWED_INSTALLATION_FAILURES or '', ',', true)
|
||||
|
||||
for k, v in pairs(require('nvim-treesitter.parsers').configs) do
|
||||
if #vim.api.nvim_get_runtime_file('parser/' .. k .. '.*', false) == 0 then
|
||||
-- On CI all parsers that can be installed from C files should be installed
|
||||
if
|
||||
vim.env.CI
|
||||
and not v.install_info.requires_generate_from_grammar
|
||||
and not vim.list_contains(allowed_to_fail, k)
|
||||
then
|
||||
io_print('Error: parser for ' .. k .. ' is not installed')
|
||||
vim.cmd('cq')
|
||||
else
|
||||
io_print('Warning: parser for ' .. k .. ' is not installed')
|
||||
if v.install_info then
|
||||
-- skip "query only" languages
|
||||
if #vim.api.nvim_get_runtime_file('parser/' .. k .. '.*', false) == 0 then
|
||||
-- On CI all parsers that can be installed from C files should be installed
|
||||
if
|
||||
vim.env.CI
|
||||
and not v.install_info.requires_generate_from_grammar
|
||||
and not vim.list_contains(allowed_to_fail, k)
|
||||
then
|
||||
io_print('Error: parser for ' .. k .. ' is not installed')
|
||||
vim.cmd('cq')
|
||||
else
|
||||
io_print('Warning: parser for ' .. k .. ' is not installed')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
15
scripts/install-parsers.lua
Executable file
15
scripts/install-parsers.lua
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env -S nvim -l
|
||||
|
||||
vim.opt.runtimepath:append('.')
|
||||
|
||||
-- needed on CI
|
||||
vim.fn.mkdir(vim.fn.stdpath('cache'), 'p')
|
||||
|
||||
local done = false
|
||||
require('nvim-treesitter.install').install('all', {}, function()
|
||||
done = true
|
||||
end)
|
||||
|
||||
vim.wait(6000000, function()
|
||||
return done
|
||||
end)
|
||||
|
|
@ -2,11 +2,11 @@ vim.opt.runtimepath:append('.')
|
|||
vim.cmd.runtime({ 'plugin/plenary.vim', bang = true })
|
||||
vim.cmd.runtime({ 'plugin/nvim-treesitter.lua', bang = true })
|
||||
vim.cmd.runtime({ 'plugin/query_predicates.lua', bang = true })
|
||||
vim.cmd.runtime({ 'plugin/filetypes.lua', bang = true })
|
||||
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
conf = 'hocon',
|
||||
cmm = 't32',
|
||||
hurl = 'hurl',
|
||||
ncl = 'nickel',
|
||||
tig = 'tiger',
|
||||
|
|
@ -24,6 +24,6 @@ require('nvim-treesitter').setup()
|
|||
vim.api.nvim_create_autocmd('FileType', {
|
||||
callback = function(args)
|
||||
pcall(vim.treesitter.start)
|
||||
vim.bo[args.buffer].indentexpr = 'v:lua.require"nvim-treesitter".indentexpr()'
|
||||
vim.bo[args.buf].indentexpr = 'v:lua.require"nvim-treesitter".indentexpr()'
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Can be used as a pre-push hook
|
||||
# Just symlink this file to .git/hooks/pre-push
|
||||
|
||||
echo "Running linter..."
|
||||
luacheck .
|
||||
|
||||
echo "Checking formatting..."
|
||||
stylua --check .
|
||||
|
|
@ -4,7 +4,7 @@ HERE="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
|||
cd $HERE/..
|
||||
|
||||
run() {
|
||||
nvim --headless --noplugin -u scripts/minimal_init.lua \
|
||||
nvim --headless --noplugin -u scripts/minimal_init.lua \
|
||||
-c "PlenaryBustedDirectory $1 { minimal_init = './scripts/minimal_init.lua' }"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ assert:register(
|
|||
local function compare_indent(before, after, xfail)
|
||||
assert:add_formatter(format_indent)
|
||||
if xfail then
|
||||
io.stdout:write('Warning! Known failure of this test! Please help to fix it! ')
|
||||
-- io.stdout:write('Warning! Known failure of this test! Please help to fix it! ')
|
||||
assert.is_not.same_indent(before, after)
|
||||
else
|
||||
assert.is.same_indent(before, after)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue