Skip to content
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: list reports bad test edges #26354

Closed
alandonovan opened this issue Jul 12, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@alandonovan
Copy link
Contributor

commented Jul 12, 2018

% pwd
/tmp/gopackages-test462362944
% find src
src
src/lib
src/lib/lib_test.go
src/lib/lib_x_test.go
src/lib/lib.go
src/testutil
src/testutil/testutil.go
src/testutil/testutil_test.go
% head $(find src -type f)
==> src/lib/lib_test.go <==
package lib
==> src/lib/lib_x_test.go <==
package lib_test; import _ "testutil"
==> src/lib/lib.go <==
package lib
==> src/testutil/testutil.go <==
package testutil; import _ "lib"
==> src/testutil/testutil_test.go <==
package testutil
% GOPATH=$(pwd) go list -json -test -deps lib testutil
{
	"Dir": "/tmp/gopackages-test462362944/src/testutil",
	"ImportPath": "testutil",
	"Name": "testutil",
	"GoFiles": [
		"testutil.go"
	],
	"Imports": [
		"lib [lib.test]"
	],
	"ImportMap": {
		"lib": "lib [lib.test]"
	},
	"Deps": [
		"lib"
	],
}
{
	"Dir": "/tmp/gopackages-test462362944/src/testutil",
	"ImportPath": "testutil [lib.test]",
	"Name": "testutil",
	"ForTest": "lib",
	"GoFiles": [
		"testutil.go"
	],
	"Imports": [
		"lib [lib.test]"
	],
	"ImportMap": {
		"lib": "lib [lib.test]"
	},
	"Deps": [
		"lib [lib.test]"
	],
}
...

go list reports that the regular testutil package imports "lib [lib.test]", which is surprising: "lib [lib.test]" is a necessary package in this -test query result because lib was a goal, but the regular testutil should depend on the regular lib package.

Also observe that the Deps of testutil includes the regular lib and not "lib [lib.test]", which contradicts its Imports section. Perhaps the Deps are expressed as keys in the ImportMap, or perhaps Deps is just wrong. Either way, confusing.

@bcmills bcmills added this to the Go1.11 milestone Jul 20, 2018

@bcmills

This comment has been minimized.

Copy link
Member

commented Jul 20, 2018

Alan, what's the impact of this bug? (Does it need to be a release-blocker for 1.11?)

@rsc

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2018

Dup of #26880, fixed by @suzmue. Thanks!

@rsc rsc closed this Aug 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.