Closed akinsho closed 2 years ago
Hey thanks for looking to create an adapter! I've considered a separate org for them and will probably do that, just need to get some time to do so, hopefully this week. Probably should have that before releasing but to be honest, I didn't expect people to be so fast to start developing adapters :sweat_smile:
To answer your questions:
results
should be a table<string, neotest.Result>
(see here https://github.com/rcarriga/neotest/blob/master/lua/neotest/adapters/interface.lua#L32) which maps the test IDs to results. Otherwise the core has no way to know what result corresponds to what test.TestAdd
would contain the errors for TestBothZero
, TestBothPositive
and TestBothNegative
. Of course this is just a suggestion and nothing about the interface requires that. Also not sure how possible that is without integrating with go. I've looked at wrapping go's test module before and it is a bit of a beast)Thanks for the fix and the pointers @rcarriga, regarding point 2 on the return for results, is the correct way to handle this then to iterate the tree somehow and match each result output from the test runner to a node of the tree? how do you account for ways that the tests might have been run? do you need to?
Well for plenary and python when collecting the results, it is possible to derive the test ID from the result. I'm not sure what info go test
provides when giving results so I can't be very specific. I should note that the position IDs assigned to each node of the tree is totally arbitrary, you can change them to whatever suits your needs (well in theory, I may have made an assumption somewhere but that would be a bug) as long as they are unique.
how do you account for ways that the tests might have been run? do you need to?
I'm not sure what you mean by this, could you give an example of ways a test might be run?
I ended up using the tree:iter
method and mapping each test name to each node which seemed to work. Not sure if that would work as well for larger test scopes like the whole suite etc.
@rcarriga seems to work well enough now, so if you're ok with it will open a PR to add it to the list of adapters (it's still pretty beta though). One thing I'd still like some help with is I'd like to change the output content. I use the -json
flag, so the test runner gives me easily parsable output, but that means that opening up the test output just shows JSON which isn't that readable. I'm able to collect and parse the test output, so I can re-generate the string that you'd otherwise get from a normal run of go test
but not sure how to feed it into neotest for the output function
e.g.
Other things I'll eventually want to tackle are
Great to hear it's working! Happy to add it to the list.
For showing readable output you could create a tempfile using tempname()
, write the reconstructed data to it and then set the output
field of the result objects. It's set automatically by the core client if not present to the output of the process.
I'd like to add an easy way to test packages not sure exactly how to expose that command
Not too familiar with go beyond the basics, can multiple packages share the same directory (meaning that running a directory wouldn't work)? It may require an additional position type to be added to core to represent it if so
@rcarriga that worked re. saving output to a different file and then using that path ππΏ. One case where I'm not sure if this works is when for whatever reason no test file is found, in this case there is no result to point my output file to, so it just uses the fallback. Tbh the case I'm explaining is an odd one since it should definitely not be saying there is no test, but I'll dig into that, I'm just wondering if there's a way to change the fallback output file to one of my own making even if there are no results
Re. the packages, I believe that is invalid in go and all files from a package must be within that folder, so I guess just using the directory runner would work.
if there's a way to change the fallback output file to one of my own making even if there are no results
You can return a result object for any position including namespaces, files and directories. By default they're just aggregated from child tests. So just iterate through the tree and set the result output for each one to your custom one.
Re. the packages, I believe that is invalid in go and all files from a package must be within that folder, so I guess just using the directory runner would work.
Good to hear :+1:
@rcarriga thanks for your help, now the project is up I'll close this out. If I have any issues with getting other stuff working, I'll tag you in an issue on that repo if that's alright. Hopefully shouldn't be frequent.
Sounds good to me, thanks for contributing!
Hi @rcarriga,
Great work on this plugin π, really excited to see how it evolves.
I've been trying to get it working with
go
and have been having some trouble, having read the explanation in the README and also dug through the code of this repo and the existing adapters.I've got the project over here https://github.com/akinsho/neotest-go (happy to move it under a more general namespace if you intend to create a
neotest
org since I'm sure other people might want to contribute eventually, and I might stop working with go π€·πΏ)I've added a sub folder (neogit_go) within the repo which adds two simple examples of tests and am trying to get things working using those.
Reference: https://pkg.go.dev/testing
Issues
neotest.Result[]
but tests seem to still show as pending when I return this list, so something seems to be missingAny advice or pointers would be much appreciated