diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/check-parsers.lua | 40 | ||||
| -rwxr-xr-x | scripts/check-queries.lua | 36 | ||||
| -rwxr-xr-x | scripts/ci-install.sh | 7 | ||||
| -rw-r--r-- | scripts/minimal_init.lua | 1 | ||||
| -rwxr-xr-x | scripts/run_tests.sh | 16 |
5 files changed, 41 insertions, 59 deletions
diff --git a/scripts/check-parsers.lua b/scripts/check-parsers.lua new file mode 100755 index 000000000..08e48740d --- /dev/null +++ b/scripts/check-parsers.lua @@ -0,0 +1,40 @@ +#!/usr/bin/env -S nvim -l +vim.opt.runtimepath:append('.') + +local configs = require('nvim-treesitter.parsers') +local parsers = #_G.arg > 0 and { unpack(_G.arg) } + or require('nvim-treesitter.config').installed_parsers() + +local data = {} ---@type table[] +local errors = {} ---@type string[] +for _, lang in pairs(parsers) do + if configs[lang] and configs[lang].install_info then + local ok, info = pcall(vim.treesitter.language.inspect, lang) + if not ok then + errors[#errors + 1] = string.format('%s: %s', lang, info) + else + data[#data + 1] = { lang = lang, abi = info.abi_version, state_count = info.state_count } + end + end +end + +if #errors > 0 then + print('::group::Errors') + for _, err in ipairs(errors) do + print(err) + end + print('::endgroup::') + print('Check failed!\n') + vim.cmd.cq() +else + print('::group::State counts') + table.sort(data, function(a, b) + return a.state_count < b.state_count + end) + + for i, val in ipairs(data) do + print(string.format('%i.\t%d\t%s (ABI %d)', #data - i + 1, val.state_count, val.lang, val.abi)) + end + print('::endgroup::') + print('Check successful!') +end diff --git a/scripts/check-queries.lua b/scripts/check-queries.lua index 66b947914..0a684f5eb 100755 --- a/scripts/check-queries.lua +++ b/scripts/check-queries.lua @@ -6,29 +6,6 @@ local configs = require('nvim-treesitter.parsers') local parsers = #_G.arg > 0 and { unpack(_G.arg) } or require('nvim-treesitter.config').installed_parsers() --- Extract captures from documentation for validation -local captures = {} ---@type table[] -do - local current_query ---@type string - - for line in io.lines('CONTRIBUTING.md') do - if vim.startswith(line, '### ') then - current_query = line:sub(5):lower() ---@type string - elseif vim.startswith(line, '@') and current_query then - if not captures[current_query] then - captures[current_query] = {} - end - - table.insert(captures[current_query], vim.split(line:sub(2), ' ')[1]) - end - end - - -- Complete captures for injections. - for lang, _ in pairs(configs) do - table.insert(captures['injections'], lang) - end -end - -- Check queries for each installed parser in parsers local errors = {} ---@type string[] local timings = {} ---@type { duration: number, lang: string, query_type: string }[] @@ -46,19 +23,6 @@ do print(string.format('Checking %s %s (%.02fms)', lang, query_type, duration * 1e-6)) if not ok then errors[#errors + 1] = string.format('%s (%s): %s', lang, query_type, query) - else - if query then - for _, capture in ipairs(query.captures) do - local is_valid = ( - vim.startswith(capture, '_') -- Helpers. - or vim.list_contains(captures[query_type], capture) - ) - if not is_valid then - errors[#errors + 1] = - string.format('%s (%s): invalid capture "@%s"', lang, query_type, capture) - end - end - end end end end diff --git a/scripts/ci-install.sh b/scripts/ci-install.sh index 43f3c4ade..3d656f842 100755 --- a/scripts/ci-install.sh +++ b/scripts/ci-install.sh @@ -10,19 +10,12 @@ if [[ $os == Linux ]]; then tar -zxf nvim-linux-x86_64.tar.gz sudo ln -s "$PWD"/nvim-linux-x86_64/bin/nvim /usr/local/bin rm -rf "$PWD"/nvim-linu-x86_x64/lib/nvim/parser - mkdir -p ~/.local/share/nvim/site/pack/nvim-treesitter/start - ln -s "$PWD" ~/.local/share/nvim/site/pack/nvim-treesitter/start elif [[ $os == Darwin ]]; then RELEASE_NAME="nvim-macos-$(uname -m)" curl -L "https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/$RELEASE_NAME.tar.gz" | tar -xz sudo ln -s "$PWD/$RELEASE_NAME/bin/nvim" /usr/local/bin rm -rf "$PWD/$RELEASE_NAME/lib/nvim/parser" - mkdir -p ~/.local/share/nvim/site/pack/nvim-treesitter/start - ln -s "$PWD" ~/.local/share/nvim/site/pack/nvim-treesitter/start else curl -L "https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim-win64.zip" -o nvim-win64.zip unzip nvim-win64 - mkdir -p ~/AppData/Local/nvim/pack/nvim-treesitter/start - mkdir -p ~/AppData/Local/nvim-data - cp -r "$PWD" ~/AppData/Local/nvim/pack/nvim-treesitter/start fi diff --git a/scripts/minimal_init.lua b/scripts/minimal_init.lua index 648ffa69f..4a5e14f16 100644 --- a/scripts/minimal_init.lua +++ b/scripts/minimal_init.lua @@ -1,3 +1,4 @@ +vim.opt.runtimepath:append(os.getenv('PLENARY')) vim.opt.runtimepath:append('.') vim.cmd.runtime({ 'plugin/plenary.vim', bang = true }) vim.cmd.runtime({ 'plugin/query_predicates.lua', bang = true }) diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh deleted file mode 100755 index 7ae6b22c5..000000000 --- a/scripts/run_tests.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -HERE="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -cd $HERE/.. - -run() { - nvim --headless --noplugin -u scripts/minimal_init.lua \ - -c "PlenaryBustedDirectory $1 { minimal_init = './scripts/minimal_init.lua' }" -} - -if [[ $2 = '--summary' ]]; then - ## really simple results summary by filtering plenary busted output - run tests/$1 2> /dev/null | grep -E '^\S*(Testing|Success|Failed|Errors)\s*:' -else - run tests/$1 -fi |
