Closed kapral18 closed 5 months ago
The adapter interface describes the root
functions as:
---Find the project root directory given a current directory to work from.
---Should no root be found, the adapter can still be used in a non-project context if a test file matches.
---@async
---@param dir string @Directory to treat as cwd
---@return string | nil @Absolute root dir of test suite
function neotest.Adapter.root(dir) end
A zig "project" is a directory with a build.zig
file, is it not? Wouldnt it be enough to search for this file specifically, instead of any zig file?
It's true that zig doesn't require the build.zig
, but then you'd be running tests on a non project context - you'd just be testing individual files (and that's already expected behavior for both neotest and the zig adapter)
I believe @fnzr is right. I might have been under an impression that if build.zig
is not present and this pattern does not include all zig files, then the tests would not show up in require("neotest").summary.toggle()
window, but they do:
(non build.zig
tests seem to fail to run now though, but that's a separate issue probably.)
I wonder now what do we "get" from having a root directory at all. I'll try to look into this a bit later today.
I played around with it a bit, and looking at neotest code and logs it seems that having just build.zig
instead of **/*.zig
is indeed enough:
INFO | 2024-06-03T22:25:58Z+0300 | /Users/llaz/git/neotest/lua/neotest/adapters/init.lua:18 | Found 0 adapters for directory /Users/llaz/git/playground/zig/test-without-build
DEBUG | 2024-06-03T22:25:58Z+0300 | /Users/llaz/git/neotest/lua/neotest/adapters/init.lua:19 | Adapters: {}
DEBUG | 2024-06-03T22:25:58Z+0300 | /Users/llaz/git/neotest/lua/neotest/lib/file/init.lua:22 | Reading file: /Users/llaz/git/playground/zig/test-without-build/test.zig
INFO | 2024-06-03T22:25:58Z+0300 | /Users/llaz/git/neotest/lua/neotest/adapters/init.lua:50 | Adapter neotest-zig matched buffer /Users/llaz/git/playground/zig/test-without-build/test.zig
See if #15 works ok for you
this is awsm, thanks everybody
Upon start
neotest
registers all the adapters. And if I have my zig adapter set up for neotest, it also gets registered and as part of matching the root pattern during bootstrap it actually scans the root of the project for**/*.zig
pattern.And if I am in a totally unrelated typescript project, let's say
elastic/kibana
that has 70000+ source files and when I simply try to run my jest test file, the neotest hangs on a completely unrelatedneotest-zig
adapter becauseglob()
call is super slow.I think ideally, we need to use "git ls-files '*/.zig'", which is way faster under assumption that if a project is big enough it most likely is git versioned.
Wdyt?