Skip to content

Commit

Permalink
go/packages: fix tests for new go list behaviour
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ianthehat committed Jul 31, 2018
1 parent 0700b57 commit cfaff8d
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions go/packages/packages_test.go
Expand Up @@ -112,9 +112,9 @@ func TestMetadataImportGraph(t *testing.T) {
errors
math/bits
* 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]
unsafe
b -> a
b -> errors
Expand Down Expand Up @@ -204,9 +204,24 @@ func TestMetadataImportGraph(t *testing.T) {
if err != nil {
t.Fatal(err)
}
const want = "[subdir/d subdir/e subdir/d.test]"
if fmt.Sprint(initial) != want {
t.Errorf("for subdir/... wildcard, got %s, want %s", initial, want)
graph, all = importGraph(initial)
wantGraph = `
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)
}
}
}
Expand Down

0 comments on commit cfaff8d

Please sign in to comment.