lawrence-laz / neotest-zig

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

Can't run tests in repos that have Zig submodules #24

Closed ziontee113 closed 5 months ago

ziontee113 commented 5 months ago

Steps To Reproduce

  1. zig init
  2. git init
  3. mkdir submodules
  4. git submodule add https://github.com/ziglibs/treez.git submodules/treez
  5. Try to run test in main.zig

Current behavior

Can't run tests in repos that have Zig submodules.

My temporary fix

In neotest-zig/init.lua -> function M._build_spec_with_buildfile(args, build_file_path), right after declaration of build_file_dir_path variable:

    if string.find(build_file_dir_path, "\n") then
        local lines = {}
        for s in build_file_dir_path:gmatch("[^\r\n]+") do
            table.insert(lines, s)
            break
        end
        build_file_dir_path = lines[1]
        log.info("DEBUGGING new build_file_dir_path", build_file_dir_path)
    end

It seems like the Lua pattern didn't account for submodules shenanigans. In my case, before the fix, build_file_dir_path was very messed up and had multiple \n characters in it, so I tried the fix and everything works as normal.

lawrence-laz commented 5 months ago

Let me know if #25 works ok for you

lawrence-laz commented 5 months ago

Thanks for quality reports!