Revert "go/packages: make tests pass with custom GOCACHE"

This reverts commit e7b5a6dfd8.

Reason for revert: merged by mistake

Change-Id: Ibf6ff4aa346b569aaa5e06b58770a93ca3eebdab
Reviewed-on: https://go-review.googlesource.com/c/156900
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
Michael Matloob 2019-01-08 22:25:39 +00:00 committed by Daniel Martí
parent e8d59ebc66
commit 421f03a57a
1 changed files with 7 additions and 8 deletions

View File

@ -1389,19 +1389,19 @@ func testJSON(t *testing.T, exporter packagestest.Exporter) {
ID: "golang.org/fake/b",
Name: "b",
Imports: map[string]*packages.Package{
"golang.org/fake/a": {ID: "golang.org/fake/a"},
"golang.org/fake/a": &packages.Package{ID: "golang.org/fake/a"},
},
}, {
ID: "golang.org/fake/c",
Name: "c",
Imports: map[string]*packages.Package{
"golang.org/fake/b": {ID: "golang.org/fake/b"},
"golang.org/fake/b": &packages.Package{ID: "golang.org/fake/b"},
},
}, {
ID: "golang.org/fake/d",
Name: "d",
Imports: map[string]*packages.Package{
"golang.org/fake/b": {ID: "golang.org/fake/b"},
"golang.org/fake/b": &packages.Package{ID: "golang.org/fake/b"},
},
}} {
got := decoded[i]
@ -1622,13 +1622,12 @@ func srcs(p *packages.Package) []string {
func cleanPaths(paths []string) []string {
result := make([]string, len(paths))
for i, src := range paths {
// If the source file doesn't have an extension like .go or .s,
// it comes from GOCACHE. The names there aren't predictable.
name := filepath.Base(src)
if !strings.Contains(name, ".") {
// The default location for cache data is a subdirectory named go-build
// in the standard user cache directory for the current operating system.
if strings.Contains(filepath.ToSlash(src), "/go-build/") {
result[i] = fmt.Sprintf("%d.go", i) // make cache names predictable
} else {
result[i] = name
result[i] = filepath.Base(src)
}
}
return result