test: support injected query tests#586
Merged
lewis6991 merged 3 commits intonvim-treesitter:masterfrom Apr 17, 2025
Merged
Conversation
0102c43 to
53858c4
Compare
lewis6991
reviewed
Apr 16, 2025
test/contexts_spec.lua
Outdated
| install_langs(lang) | ||
| cmd('edit ' .. test_file) | ||
| local bufnr = api.nvim_get_current_buf() | ||
| exec_lua( |
Member
There was a problem hiding this comment.
Can you add some comments around this. At a glance, I have no idea what this code is trying to do.
Also, you should be able to replace the string in exec_lua with a function.
Contributor
Author
There was a problem hiding this comment.
I replaced with a function, a decent chunk stayed in exec_lua but definitely easier to read
53858c4 to
d146548
Compare
lewis6991
reviewed
Apr 16, 2025
test/contexts_spec.lua
Outdated
| install_langs(current_lang) | ||
|
|
||
| -- Query for injections in the current language, and queue them for installation. | ||
| langs_to_check = exec_lua([[ |
Member
There was a problem hiding this comment.
I meant you should be able to do:
exec_lua(function()
...
end)d146548 to
496e56e
Compare
Before we had snapshots to cover injected query tests, but now we can use the cursor and context markers to test these as well. This will mean that we might be installing more parsers and parsing more than we should be, but the higher test coverage is worth it.
496e56e to
bcec2de
Compare
lewis6991
reviewed
Apr 17, 2025
| end | ||
|
|
||
| setup(function() | ||
| lazy_setup(function() |
Member
There was a problem hiding this comment.
Would running busted with --lazy be an option?
Contributor
Author
There was a problem hiding this comment.
theoretically, but doesn't seem to work for me :/
lewis6991
approved these changes
Apr 17, 2025
jugarpeupv
pushed a commit
to jugarpeupv/nvim-treesitter-context
that referenced
this pull request
Jul 23, 2025
* test: support injected query tests Before we had snapshots to cover injected query tests, but now we can use the cursor and context markers to test these as well. This will mean that we might be installing more parsers and parsing more than we should be, but the higher test coverage is worth it. * test: add injected query tests * chore: support goto for stylua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
context_spec.luatests do not cover test files that have injected queries. To cover these, we recursively parse the file to get the injected languages parsed, which then can be used later for the context tests. This PR also includes updating the html test file to take advantage of this capability. I also wanted to update the markdown one, but it appears to break in 0.9.5 and pass in 0.10.2. I would fix it, but I see that we're dropping 0.9.5 support in favor of 0.11.0, so leaving a TODO for now.Followup to #568