[release-branch.go1.11] go/packages: fix build breakage caused by math/bits to unsafe dep

Our tests compare import graphs from go/packages to expected graphs,
and one of the test cases imports math/bits. But in tip math/bits
picked up a dependency on unsafe, which means the expected graph
is different when run against a Go version >= go1.11. Remove that edge
before comparing against the expected graph to work around the breakage.

Change-Id: Ic586a75ba530741d251df9f87d0817a8e37d92ea
Reviewed-on: https://go-review.googlesource.com/c/151657
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
(cherry picked from commit c5b00d9557)
Reviewed-on: https://go-review.googlesource.com/c/153864
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Michael Matloob 2018-11-28 17:32:05 -05:00 committed by Andrew Bonventre
parent 64f9b8ad70
commit 4d17acb3b1
1 changed files with 6 additions and 0 deletions

View File

@ -1321,6 +1321,12 @@ func importGraph(initial []*packages.Package) (string, map[string]*packages.Pack
continue
}
}
// math/bits took on a dependency on unsafe in 1.12, which breaks some
// tests. As a short term hack, prune that edge.
// TODO(matloob): think of a cleaner solution, or remove math/bits from the test.
if p.ID == "math/bits" && imp.ID == "unsafe" {
continue
}
edges = append(edges, fmt.Sprintf("%s -> %s", p, imp))
visit(imp)
}