Closed cehoffman closed 2 months ago
I, too, had experienced the annoying 'No tests found' :anger:. And on top of that, it took me two days to just build the mental model of how the plugin, treesitter, etc work together to identify tests, and I was able to find the root cause for my issue.
In the end, for me, it was another adapter being used instead of go (neotest-zig), which meant it didn't find the test case name, but as you are showing above you're not registering the neotest-zig adapter.
What I really found useful is inspecting the debug logs that neotest emits. I will share what I did in case it helps you too:
"nvim-neotest/neotest",
-- other key/vals ...
opts = {
level = vim.log.levels.DEBUG,
adapters = {
["neotest-go"] = {
-- Here we can set options for neotest-go, e.g.
-- args = { "-tags=integration" }
recursive_run = true,
},
},
},
:lua vim.print(pcall(vim.fn.stdpath, "log"))
-- my output: /home/asfaltboy/.local/state/nvim/neotest.log
tail -f /home/asfaltboy/.local/state/nvim/neotest.log
If you can't identify the cause outright, please share the logs
I followed the directions to set the log level in the reproduction script and invoked a test run. I didn't get much of any logs except a loading error. Obviously neotest is available to the neovim context since it is the thing invoking the require for itself. I'm not sure where to go from this. This all started after an upgrade of neotest which had the nio update.
I was able to come back and spend some time on this. Digging through the code a bit, it looks like the suggested config for enabling the more detailed logging was wrong.
"nvim-neotest/neotest",
-- other key/vals ...
opts = {
level = vim.log.levels.DEBUG,
adapters = {
["neotest-go"] = {
-- Here we can set options for neotest-go, e.g.
-- args = { "-tags=integration" }
recursive_run = true,
},
},
},
needed to be
"nvim-neotest/neotest",
-- other key/vals ...
opts = {
log_level = vim.log.levels.DEBUG,
adapters = {
["neotest-go"] = {
-- Here we can set options for neotest-go, e.g.
-- args = { "-tags=integration" }
recursive_run = true,
},
},
},
After adjusting this I do see more details, but they really are not anything more enlightening than what the original logs contained. For some reason the spawned nvim subprocess isn't not getting the lua module paths setup correctly and is not able to load neotest in the subprocess neovim editor. I'll be trying to look at this more, but I haven't changed anything about this unless lazy.nvim is somehow broken in subprocess neovim.
Edit:
I've crafted the start command that is used for the subprocess and confirmed it should be able to load neotest.
$ ~/.homebrew/Cellar/neovim/0.9.5/bin/nvim -n --headless +"lua print(require'neotest' and 0)" +q
0
This is missing the --embed
flag which as I understand it is purely there to make neovim work in an RPC mode, however that seems to impact how the library loading is done or the initialization code that sets up the path loading is triggered.
Edit 5/7: Updated to HEAD neovim incase there is something there. No change in behavior. My environment variables are very trimmed down and contain nothing lua related, so I'm currently at a loss why why the subprocess neovim is unable to load modules that the parent obviously can.
After getting dead ended at the rpcrequest
failure to load neotest
module, I decided that it maybe has something to do with the reproduction config and launching neovim with the explicit config file. Sure enough that appears to have been the problem with the reproduction config. One of the things I did trying to get this working did fix the problem in my main configuration. The main configuration has been unchanged since this problem began.
I believe this was caused by Homebrew actually. I encountered a problem trying to install neovim HEAD with homebrew where the compile couldn't find the lpeg library even though Homebrew is managing the library and explicitly setting it for the compile. After a bit of searching for why, I stumbled upon this comment which advice from another thread to try reinstalling lpeg from Homebrew.
Running brew reinstall lpeg
and having it rewrite the bottle and the compile succeeded. This is basically the only tooling change that actually happened. I didn't even remove and reinstall the stable neovim. It seems this all came down to an errant issue with Homebrew and managing the lpeg linkage. I'm a bit puzzled why nothing spit out library load failures, but testing is working again. It seems the upgrade to neotest was just coicidental to probably a closely timed upgrade in Homebrew.
Edit:
Running brew remove lpeg
and trying again still succeeds. I guess I'm now really at a loss. Potentially some other tool upgrade between reporting and now is related since I had been trying to debug this with the reproduction config and finally determined the reproduction config is fails to meet the rpcrequest needs.
I've read the other closed issues #64 and #51 on this. I suspect this is a similar cause with treesitter changes, but I haven't been able to figure out a resolution.
This is the minimal reproduction configuration I have using lazy.nvim.
repro.lua
Loading this test file, I get to tests found for NeotestFile and NeotestSummary.
repro_test.go
The lockfile for lazy.