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
Closed

cmd/go: list reports bad test edges #26354

alandonovan opened this issue Jul 12, 2018 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@alandonovan
Copy link
Contributor

% 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 bcmills added NeedsFix The path to resolution is known, but the work has not been done. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsFix The path to resolution is known, but the work has not been done. labels Jul 20, 2018
@bcmills
Copy link
Contributor

bcmills commented Jul 20, 2018

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

@rsc
Copy link
Contributor

rsc commented Aug 10, 2018

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

@rsc rsc closed this as completed Aug 10, 2018
@golang golang locked and limited conversation to collaborators Aug 10, 2019
@rsc rsc removed their assignment Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants