Open mrcjkb opened 1 year ago
Note to self:
This query properly links the stage1Tests
function with testGroup "Stage 1" stage1Tests
, but there does not seem to be a way to capture both as a @namespace.definition
. It looks like only the second @namespace.definition
capture is applied.
I don't think scheme is powerful enough to define a capture that encompasses both the testGroup
exp_apply
and the function
.
;; testGroups that call functions with testCases
(
(_
(_
(_
(exp_apply
(exp_name) @ns_func_name
(#lua-match? @ns_func_name "^.*testGroup")
(exp_literal (string) @namespace.name)
(_ (variable) @ref_name)
) @namespace.definition
)
)
)
(function
name: (variable) @ref_name
(_
(exp_apply
(exp_name) @test_func_name
(#lua-match? @test_func_name "^.*testCase")
(exp_literal) @test.name
) @test.definition
)
) @namespace.definition
)
Originally posted by @Kleidukos in https://github.com/mrcjkb/neotest-haskell/issues/102#issuecomment-1596276072
Example:
should be detected as
namespace
:"Parser Tests:
namespace
:"Stage 1
[test]
-> test casesCurrently, the test groups and test cases are not associated with each other, because there are no tree-sitter queries that link tests with test groups in other trees.
I'm not sure if this is possible with scheme queries, but it is worth looking into.