lawrence-laz / neotest-zig

Test runner for Zig in Neovim using Neotest backend.
MIT License
27 stars 7 forks source link

0.13.0 zig support #35

Closed natpuncher closed 1 week ago

natpuncher commented 2 weeks ago

Hi there. It would be great to use this test-runner with master version 0.13.0 of zig. I've tried, but got this error and all my tests marked as failed.

neotest_build.zig:13:101: error: no field named 'fn' in union 'builtin.Type'
    const can_build_function_return_error = @typeInfo(@typeInfo(@TypeOf(original_build_file.build)).@"fn".return_type.?) == .error_union;
                                                                                                    ^~~~~
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/builtin.zig:256:18: note: union declared here
pub const Type = union(enum) {
                 ^~~~~
referenced by:
    build: neotest_build.zig:5:5
    runBuild__anon_8413: /opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2116:27
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
neotest_build.zig:13:101: error: no field named 'fn' in union 'builtin.Type'
    const can_build_function_return_error = @typeInfo(@typeInfo(@TypeOf(original_build_file.build)).@"fn".return_type:18: note: union declared here
pub const Type = union(nion;
                                                                                                    ^~~~~
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/builtin.zig:256enum) {
                 ^~~~~
referenced by:
    build: neotest_build.zig:5:5
    runBuild__anon_8413: /opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2116:27
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
.?) == .error_u

Thanks in advance.

lawrence-laz commented 1 week ago

Hi,

If you use zig zig/master then use neotest-zig/main If you use zig/0.13.0 then use neotest-zig/1.3.0

Let me know if this doesn't work with the respective tagged version

natpuncher commented 1 week ago

I changed commit in lazy-lock.json file to the last release db005bb... hash and when I start tests or open tests window I got this errors.

   Error  10:56:16 msg_show.lua_error Error executing vim.schedule lua callback: .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:100: Async task failed without callback: The coroutine failed with this message: 
...0.10.2_1/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 2:3. Invalid node type "TestDecl":
    (TestDecl
  ^

stack traceback:
    [C]: in function '_ts_parse_query'
    ...0.10.2_1/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
    ...im/0.10.2_1/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'parse_query'
    ...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:104: in function 'normalise_query'
    ...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:161: in function 'parse_positions_from_string'
    ...cal/share/nvim/lazy/neotest-zig/lua/neotest-zig/init.lua:136: in function '_does_file_contain_tests'
    ...cal/share/nvim/lazy/neotest-zig/lua/neotest-zig/init.lua:108: in function 'is_test_file'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:346: in function 'get_adapter'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:356: in function '_set_focused_file'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:508: in function '_start'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:186: in function '_ensure_started'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:198: in function <...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:197>
    ...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:39: in function 'get_tree_from_args'
    ...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:80: in function 'func'
    .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:173: in function <.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:172>
stack traceback:
    [C]: in function 'error'
    .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:100: in function 'close_task'
    .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:122: in function 'cb'
    .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:188: in function <.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:187>
   Error  10:56:16 msg_show.lua_error Error executing vim.schedule lua callback: .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:100: Async task failed without callback: The coroutine failed with this message: 
...0.10.2_1/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 2:3. Invalid node type "TestDecl":
    (TestDecl
  ^

stack traceback:
    [C]: in function '_ts_parse_query'
    ...0.10.2_1/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
    ...im/0.10.2_1/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'parse_query'
    ...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:104: in function 'normalise_query'
    ...re/nvim/lazy/neotest/lua/neotest/lib/treesitter/init.lua:161: in function 'parse_positions_from_string'
    ...cal/share/nvim/lazy/neotest-zig/lua/neotest-zig/init.lua:136: in function '_does_file_contain_tests'
    ...cal/share/nvim/lazy/neotest-zig/lua/neotest-zig/init.lua:108: in function 'is_test_file'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:346: in function '_get_adapter'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:203: in function 'get_position'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:150: in function 'get_nearest'
    ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:496: in function <...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:495>
stack traceback:
    [C]: in function 'error'
    .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:100: in function 'close_task'
    .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:122: in function 'cb'
    .local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:188: in function <.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:187>
lawrence-laz commented 1 week ago

I see, you are using the newer version of tree sitter, this was fixed in main here #32 but was never ported into 1.3.0.

I cherry-picked the fix and released tag 1.3.1, try it out and let know if that solves the issue!


Btw, if you are using Lazy, you can set the tag like this instead of modifying the lazy-lock.json file:

{ "lawrence-laz/neotest-zig", tag = '1.3.1' },
natpuncher commented 1 week ago

It is working! thanks a lot!