Open pfi79 opened 2 weeks ago
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
$ go test -coverpkg=./... ./...
? re.pro/b [no test files]
? re.pro/c [no test files]
--- FAIL: TestIt (0.46s)
a_test.go:17: plugin build output:
a_test.go:21: could not load plugin b.so: plugin.Open("b"): plugin was built with a different version of package re.pro/c
FAIL
coverage: 0.0% of statements in ./...
FAIL re.pro/a 0.470s
FAIL
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.
@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.
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.