go/packages: fix tests for new go list behaviour

go list has been changed so that when -tests is added it reports the
test packages as well as the test mains in the initial set.
This fixes all the tests that assumed the old behaviour.
I changed the test that checked the initial set to check the entire
graph because the comparison became unreadable with the expanded set,
and this seemd like a nicer standardised way to check the behaviour.

Change-Id: I69404f8ef77cd092b0f02011a7789db71bee9b47
Reviewed-on: https://go-review.googlesource.com/126796
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Ian Cottrell 2018-07-30 17:36:35 -04:00
parent 0700b576e4
commit cfaff8d5db
1 changed files with 20 additions and 5 deletions

View File

@ -112,9 +112,9 @@ func TestMetadataImportGraph(t *testing.T) {
errors errors
math/bits math/bits
* subdir/d * subdir/d
subdir/d [subdir/d.test] * subdir/d [subdir/d.test]
* subdir/d.test * subdir/d.test
subdir/d_test [subdir/d.test] * subdir/d_test [subdir/d.test]
unsafe unsafe
b -> a b -> a
b -> errors b -> errors
@ -204,9 +204,24 @@ func TestMetadataImportGraph(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
const want = "[subdir/d subdir/e subdir/d.test]" graph, all = importGraph(initial)
if fmt.Sprint(initial) != want { wantGraph = `
t.Errorf("for subdir/... wildcard, got %s, want %s", initial, want) math/bits
* subdir/d
* subdir/d [subdir/d.test]
* subdir/d.test
* subdir/d_test [subdir/d.test]
* subdir/e
subdir/d [subdir/d.test] -> math/bits
subdir/d.test -> os (pruned)
subdir/d.test -> subdir/d [subdir/d.test]
subdir/d.test -> subdir/d_test [subdir/d.test]
subdir/d.test -> testing (pruned)
subdir/d.test -> testing/internal/testdeps (pruned)
subdir/d_test [subdir/d.test] -> subdir/d [subdir/d.test]
`[1:]
if graph != wantGraph {
t.Errorf("wrong import graph: got <<%s>>, want <<%s>>", graph, wantGraph)
} }
} }
} }