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

x/tools/go/packages: TestLoadImportsGraph failure with custom GOCACHE #29445

Closed
mvdan opened this issue Dec 28, 2018 · 6 comments
Closed

x/tools/go/packages: TestLoadImportsGraph failure with custom GOCACHE #29445

mvdan opened this issue Dec 28, 2018 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Dec 28, 2018

$ git describe --always
d00ac6d2
$ go version
go version devel +6a64efc250 Thu Dec 27 00:07:53 2018 +0000 linux/amd64
$ GOCACHE= go test
PASS
ok      golang.org/x/tools/go/packages  3.788s
$ GOCACHE=$HOME/go/cache go test
--- FAIL: TestLoadImportsGraph (0.38s)
    --- FAIL: TestLoadImportsGraph/GOPATH (0.20s)
        packages_test.go:191: golang.org/fake/subdir/d.test.Srcs = [4302876da86a8aae0c1669924daa223cafca60ef49ccaa060ae37e778d18f218-d], want [0.go]
    --- FAIL: TestLoadImportsGraph/Modules (0.17s)
        packages_test.go:191: golang.org/fake/subdir/d.test.Srcs = [4302876da86a8aae0c1669924daa223cafca60ef49ccaa060ae37e778d18f218-d], want [0.go]
FAIL
exit status 1
FAIL    golang.org/x/tools/go/packages  4.093s

Looks like the test hard-codes that cache paths are under the default go-build directory, which isn't always the case. Will try to send a CL.

@katiehockman
Copy link
Contributor

/cc @matloob

@katiehockman katiehockman added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 2, 2019
@katiehockman katiehockman added this to the Go1.13 milestone Jan 2, 2019
@mvdan
Copy link
Member Author

mvdan commented Jan 2, 2019

I sent https://go-review.googlesource.com/c/tools/+/155897, but forgot to link to the issue - will do on the next patchset. Though the trybots are failing, for some reason.

@dmitshur dmitshur changed the title go/packages: TestLoadImportsGraph failure with custom GOCACHE x/tools/go/packages: TestLoadImportsGraph failure with custom GOCACHE Jan 10, 2019
@gopherbot
Copy link

Change https://golang.org/cl/156977 mentions this issue: go/packages: make tests pass with custom GOCACHE

@andybons
Copy link
Member

This is causing trybots to fail on release-branch-go1.11: https://storage.googleapis.com/go-build-log/8c10ce16/linux-amd64_6f9c601b.log (from golang.org/cl/159740)

@gopherbot please open a backport issue for 1.11

@gopherbot
Copy link

Backport issue(s) opened: #29944 (for 1.11).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@gopherbot
Copy link

Change https://golang.org/cl/163780 mentions this issue: [release-branch.go1.11] go/packages: make tests pass with custom GOCACHE

gopherbot pushed a commit to golang/tools that referenced this issue Feb 25, 2019
This commit was merged earlier with some failing trybots, so it was
reverted. This is a re-submission.

Before this change, a test would fail:

	$ GOCACHE=$HOME/go/cache go test
	--- FAIL: TestLoadImportsGraph (1.05s)
	    packages_test.go:225: subdir/d.test.Srcs = [cf570d60b25cde4f49bbe5f69d3ed407f2d7f1fbc500b8807da726fb19b8f588-d], want [0.go]
	FAIL

This is because it assumed that the user hadn't set their own GOCACHE,
and thus that all source files in the cache would be under the default
"go-build" cache directory.

We could fix this via os.Getenv("GOCACHE"), but a simpler mechanism is
to see if the source file has an extension. Source files don't have an
extension in GOCACHE, so that's much simpler to detect.

After this change:

	$ GOCACHE=$HOME/go/cache go test
	PASS

On release-branch.go1.11, golist_fallback.go did not yet have the code
added that would need to be fixed, so nothing is being backported to it
in this change.

While at it, gofmt.

Updates golang/go#29445
Fixes golang/go#29944

Change-Id: I21fc59f13f00bea1f9a8a80e0438825f1a36ac3e
Reviewed-on: https://go-review.googlesource.com/c/156977
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/163780
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Feb 25, 2020
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

5 participants