1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 "golang.org/x/tools/internal/lsp/tests"
12 "golang.org/x/tools/internal/span"
15 func (r *runner) SuggestedFix(t *testing.T, spn span.Span, actionKinds []string, expectedActions int) {
17 filename := uri.Filename()
18 args := []string{"fix", "-a", fmt.Sprintf("%s", spn)}
19 for _, kind := range actionKinds {
20 if kind == "refactor.rewrite" {
21 t.Skip("refactor.rewrite is not yet supported on the command line")
24 args = append(args, actionKinds...)
25 got, stderr := r.NormalizeGoplsCmd(t, args...)
26 if stderr == "ExecuteCommand is not yet supported on the command line" {
29 want := string(r.data.Golden("suggestedfix_"+tests.SpanName(spn), filename, func() ([]byte, error) {
30 return []byte(got), nil
33 t.Errorf("suggested fixes failed for %s:\n%s", filename, tests.Diff(t, want, got))