wire/test: support multi-line errors and -record mode in tests (google/go-cloud#550)

This commit is contained in:
Robert van Gent
2018-10-17 16:43:33 -07:00
committed by Ross Light
parent a8825fef58
commit 97e5c83e18
21 changed files with 80 additions and 54 deletions

View File

@@ -20,6 +20,7 @@ import (
"go/ast"
"go/token"
"go/types"
"sort"
"strings"
"golang.org/x/tools/go/types/typeutil"
@@ -381,7 +382,10 @@ func verifyAcyclic(providerMap *typeutil.Map, hasher typeutil.Hasher) []error {
visited := new(typeutil.Map) // to bool
visited.SetHasher(hasher)
ec := new(errorCollector)
for _, root := range providerMap.Keys() {
// Sort output types so that errors about cycles are consistent.
outputs := providerMap.Keys()
sort.Slice(outputs, func(i, j int) bool { return types.TypeString(outputs[i], nil) < types.TypeString(outputs[j], nil) })
for _, root := range outputs {
// Depth-first search using a stack of trails through the provider map.
stk := [][]types.Type{{root}}
for len(stk) > 0 {