2019-11-21 14:28:59 -07:00
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package cmdtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"sort"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"golang.org/x/tools/internal/span"
|
|
|
|
)
|
|
|
|
|
2019-12-05 20:27:32 -07:00
|
|
|
func (r *runner) Implementation(t *testing.T, spn span.Span, imps []span.Span) {
|
2019-11-21 14:28:59 -07:00
|
|
|
var itemStrings []string
|
2019-12-05 20:27:32 -07:00
|
|
|
for _, i := range imps {
|
2019-11-21 14:28:59 -07:00
|
|
|
itemStrings = append(itemStrings, fmt.Sprint(i))
|
|
|
|
}
|
|
|
|
sort.Strings(itemStrings)
|
|
|
|
var expect string
|
|
|
|
for _, i := range itemStrings {
|
|
|
|
expect += i + "\n"
|
|
|
|
}
|
|
|
|
expect = r.Normalize(expect)
|
|
|
|
|
|
|
|
uri := spn.URI()
|
|
|
|
filename := uri.Filename()
|
|
|
|
target := filename + fmt.Sprintf(":%v:%v", spn.Start().Line(), spn.Start().Column())
|
|
|
|
|
2020-01-07 19:37:41 -07:00
|
|
|
got, stderr := r.NormalizeGoplsCmd(t, "implementation", target)
|
|
|
|
if stderr != "" {
|
|
|
|
t.Errorf("implementation failed for %s: %s", target, stderr)
|
|
|
|
} else if expect != got {
|
2019-11-21 14:28:59 -07:00
|
|
|
t.Errorf("implementation failed for %s expected:\n%s\ngot:\n%s", target, expect, got)
|
|
|
|
}
|
|
|
|
}
|