-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: TestMain on other packages are run when executing Run File (neotest)
if the test package has _test
suffix
#222
Comments
I would also add that by restoring the the command to run test on file does not report any outcome. |
Hi @rbroggi and thanks for the report! I can't reproduce this. I've replaced my config with the one you supplied and I can run tests just fine when All the
Judging from the traceback, something unexpected is passed into neotest-golang/lua/neotest-golang/process.lua Line 132 in cdb0eb0
Incidentally, a rather recent addition to the codebase here was colorization of output. You can try disabling the But to really understand what the test command output looks like on your end, would it be possible for you to supply a debug-level log? |
Thank you for the explanation. I will prolly not be able to do that today but will definitely follow up. Cheers |
No stress! By the way, I merged an unrelated change just now, which improves on showing build errors in the output. It's possible you had build errors but that it wasn't obvious that this was the case. You can try it out by making sure you set neotest-golang to use what's on the main branch (e.g. by setting setting |
Ok I've collected some more info:
I've tried in more than one project but most of the projects I use actually have an The issue happens also in tests not having the build tag. I have done the
I've managed to activate the debug log but the logs contain too much data that I think it's not a good idea to post in the open internet (private paths/folders and organization code). The same thing unfortunately applies to the print statement - I couldn't see anything weird about it TBH. I will think a bit longer and try to come out with more evidences. p.s.: I noticed that running the tests from nvim (I use lazyvim) takes WAY longer than running Also maybe another interesting evidence is that the issue happens only when running the |
For me, the absolutely most helpful next step (for figuring out what is wrong) is if I can reproduce this on my end. Would it be possible for you to create a minimal |
I don't think it taking "WAY longer" is expected, no. This depends on your project though. Go does not run tests of individual files. Instead, it runs tests of Go packages. However, Neotest talks files, so when you say you want to run all tests in a file neotest-golang has to figure out which Go packages are actually related to the file(s) and which test functions reside in a certain file. I'm leveraging You can see from the debug logs what the actual Btw, the README explains how you can filter the (very large) debug log so it filters out only logs from neotest-golang. |
Thank you for the advises, I now have a better visibility over what is going on... I have sanitized the debug log for the
It seems that it correctly goes up and find my but instead of launching the process with the specific file package
instead of:
seems to also ignore the The
Notice how here the target path was successfully used:
|
FYI: ❯ go version
go version go1.23.3 linux/amd64 |
It seems like the |
Ok, interesting. Is it correct to say that the test command is only wrong for you in the case of running all tests of a file then? |
Yes, that is right |
I'm having trouble reproducing this on my end. Could you please have a look and see if you can spot something which differs from the setup on your end? This is what I do:
This is the output I get (I am using the
And here's the same sequence (nearest test, file, dir) with the
|
Btw, since you are having this issue when executing all tests in a file, I'm pretty sure that for some reason, this part of the code is failing to figure out what your package name is. neotest-golang/lua/neotest-golang/runspec/file.lua Lines 38 to 53 in a9989f3
As you can see, it's parsing the output from |
in your bug example it works well indeed. Lemme see if I can spot what differences are there. |
I noticed something interesting: I have a package that contains 2 You know, in go there is this It seems that all works well for the |
I'm trying to reproduce your use case, but I still can't see any errors: Unless you can provide a minimal reproducible case, I don't think we will get anywhere here, unfortunately. |
I will try to put a reproducer together. I just need to find the time. Thx for the support so far |
Ok I think I found the error... Here is the reproducer It seems that when running Something quite interesting and suspect is that if we rename the package from So, it seems that when the package has the |
count=1
from test arguments breaks execution of testsRun File (neotest)
if the test package has _test
suffix
maybe some ideas could come from how Goland implements this (here I might be out of my way :D ): go test -c -o <test-executable> <package-path> #gosetup
go tool test2json -t <test-executable> -test.v=test2json -test.paniconexit0 -test.run <regex> |
Allright, I found the bug now and I believe I know how to fix this. Many thanks for being persistent and providing all these details 🙏 |
@rbroggi if you can, please give this a whirl: return {
{
"nvim-neotest/neotest",
dependencies = {
"nvim-neotest/nvim-nio",
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
"nvim-treesitter/nvim-treesitter",
{
"fredrikaverpil/neotest-golang",
- version = "*"
+ branch = "xtestgofiles",
},
},
config = function()
require("neotest").setup({
adapters = {
require("neotest-golang"),
},
})
end,
},
} |
seems to have worked 🎉 |
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.2
Operating system/version
arch
Output from
:checkhealth neotest-golang
Describe the bug
Steps To Reproduce
lazyvim config taken from the very repo and removed the argument
"-count=1"
:Expected Behavior
I would expect to see the test pass normally.
Your Lua setup
The text was updated successfully, but these errors were encountered: