-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/go: go test -cover fails when loading plugin built without coverage #67427
Comments
CC @thanm. |
I'll add an observation:
This is where the error occurs. Perhaps, I think it is because package A has a covervars.go file in the test. But when compiling the plugin, it does not. |
Thanks for the report. This problem is no longer reproducible on tip (in Go 1.23); I am not precisely sure which patch is responsible, but it does appear to no longer happening. There are a number of changes to the Go command cover machinery that have gone in since 1.22. In general plugins and coverage are not going to mix well, however, simply because of the way we implement the package consistency check: package build ID is going to be different for a packaeg whose source code has been run through the cover tool as compared with the original sources. You can see this in action for this Go module, which contains 3 packages "a", "b", and "c". Package a test builds plugin "b", which imports "c". Thus when "a" tries to load "b.so" https://go.dev/play/p/_yQzBJyY0r_I
This is effectively equivalent to what you're seeing, and this also happens on tip. Note that "-buildmode=plugin" is not compatible with "-cover", so it is hard to think of ways to work around this. As you can see from the plugin package docs there are a lot of limitations, and I think this is another one that we can add to the list. |
@thanm If it helps, but it seems to me that it happened because the covervars.go file appeared in the source cache of package “c” and the test was built with it, but the plugin was built without it. |
I think I agree, but the cover tool does more than just add "covervars.go", it also modifies all of the functions. So not sure what your point is. |
@thanm alas, we have not fixed the problem with version go 1.23.
|
@dmitshur @thanm @seankhliao the error has not been corrected. |
Based on the above, at most we would document that it is not expected to work. |
@thanm please let me know if you continue to address this issue. |
As mentioned in #67427 (comment), no plans to change how the tools work, a doc update would be suitable instead. |
Ok. Can you tell me when this restriction will appear in the documentation? |
the docs for plugin already state:
I don't think any more documentation is necessary (-cover is a build flag) |
I tried building the plugin with -cover too. That is, all the requirements are met. But the result is the same, erroneous. |
Go version
go version go1.22.3 linux/amd64
Output of
go env
in your module/workspace:What did you do?
https://github.com/pfi79/fabric/tree/up-go-1.22-error
I haven't been able to do a separate test yet.
What did you see happen?
If you remove the cover flag or remove the github.com/hyperledger/fabric/core/handlers/endorsement/api package or put another package without tests or go 1.21 or GOEXPERIMENT=nocoverageredesign everything works fine.
I'll add an observation:
This is where the error occurs. Perhaps, I think it is because package A has a covervars.go file in the test. But when compiling the plugin, it does not.
What did you expect to see?
I want the test to pass and not fail.
The text was updated successfully, but these errors were encountered: