From cfaff8d5dbb6477588b050b60eddd96008693f81 Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Mon, 30 Jul 2018 17:36:35 -0400 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Michael Matloob --- go/packages/packages_test.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/go/packages/packages_test.go b/go/packages/packages_test.go index 1ffa1c4e..66953e68 100644 --- a/go/packages/packages_test.go +++ b/go/packages/packages_test.go @@ -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 @@ -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) } } }