mirror of
https://github.com/golang/go
synced 2024-11-19 03:44:40 -07:00
go/packages: make TestLoadImportsGraph more stable.
Our tests depend on the dependency graphs of the errors which is not guaranteed to have a stable dependency graph across go versions. Especially because we're planning on making changes to the errors package in Go 1.13. Instead, use the container/list package, which is completely useless and won't be changed (unless/until Go gets generics). Fixes golang/go#30448 Change-Id: Ia5f4853d1da336dde2f025b1dd5e1d6223571dd6 Reviewed-on: https://go-review.googlesource.com/c/164298 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
ac7c11b94d
commit
4a0f391d88
@ -72,7 +72,7 @@ func testLoadImportsGraph(t *testing.T, exporter packagestest.Exporter) {
|
||||
Name: "golang.org/fake",
|
||||
Files: map[string]interface{}{
|
||||
"a/a.go": `package a; const A = 1`,
|
||||
"b/b.go": `package b; import ("golang.org/fake/a"; _ "errors"); var B = a.A`,
|
||||
"b/b.go": `package b; import ("golang.org/fake/a"; _ "container/list"); var B = a.A`,
|
||||
"c/c.go": `package c; import (_ "golang.org/fake/b"; _ "unsafe")`,
|
||||
"c/c2.go": "// +build ignore\n\n" + `package c; import _ "fmt"`,
|
||||
"subdir/d/d.go": `package d`,
|
||||
@ -93,7 +93,7 @@ func testLoadImportsGraph(t *testing.T, exporter packagestest.Exporter) {
|
||||
// Check graph topology.
|
||||
graph, all := importGraph(initial)
|
||||
wantGraph := `
|
||||
errors
|
||||
container/list
|
||||
golang.org/fake/a
|
||||
golang.org/fake/b
|
||||
* golang.org/fake/c
|
||||
@ -104,7 +104,7 @@ func testLoadImportsGraph(t *testing.T, exporter packagestest.Exporter) {
|
||||
* golang.org/fake/subdir/d_test [golang.org/fake/subdir/d.test]
|
||||
math/bits
|
||||
unsafe
|
||||
golang.org/fake/b -> errors
|
||||
golang.org/fake/b -> container/list
|
||||
golang.org/fake/b -> golang.org/fake/a
|
||||
golang.org/fake/c -> golang.org/fake/b
|
||||
golang.org/fake/c -> unsafe
|
||||
@ -132,7 +132,7 @@ func testLoadImportsGraph(t *testing.T, exporter packagestest.Exporter) {
|
||||
// Check graph topology.
|
||||
graph, all = importGraph(initial)
|
||||
wantGraph = `
|
||||
errors
|
||||
container/list
|
||||
golang.org/fake/a
|
||||
golang.org/fake/b
|
||||
* golang.org/fake/c
|
||||
@ -143,7 +143,7 @@ func testLoadImportsGraph(t *testing.T, exporter packagestest.Exporter) {
|
||||
* golang.org/fake/subdir/d_test [golang.org/fake/subdir/d.test]
|
||||
math/bits
|
||||
unsafe
|
||||
golang.org/fake/b -> errors
|
||||
golang.org/fake/b -> container/list
|
||||
golang.org/fake/b -> golang.org/fake/a
|
||||
golang.org/fake/c -> golang.org/fake/b
|
||||
golang.org/fake/c -> unsafe
|
||||
@ -173,7 +173,7 @@ func testLoadImportsGraph(t *testing.T, exporter packagestest.Exporter) {
|
||||
{"golang.org/fake/b", "b", "package", "b.go"},
|
||||
{"golang.org/fake/c", "c", "package", "c.go"}, // c2.go is ignored
|
||||
{"golang.org/fake/e", "main", "command", "e.go e2.go"},
|
||||
{"errors", "errors", "package", "errors.go"},
|
||||
{"container/list", "list", "package", "list.go"},
|
||||
{"golang.org/fake/subdir/d", "d", "package", "d.go"},
|
||||
{"golang.org/fake/subdir/d.test", "main", "command", "0.go"},
|
||||
{"unsafe", "unsafe", "package", ""},
|
||||
@ -1717,6 +1717,7 @@ func importGraph(initial []*packages.Package) (string, map[string]*packages.Pack
|
||||
}
|
||||
// math/bits took on a dependency on unsafe in 1.12, which breaks some
|
||||
// tests. As a short term hack, prune that edge.
|
||||
// ditto for ("errors", "internal/reflectlite") in 1.13.
|
||||
// TODO(matloob): think of a cleaner solution, or remove math/bits from the test.
|
||||
if p.ID == "math/bits" && imp.ID == "unsafe" {
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user