Debian Codegraph @

gopls/internal/protocol/command/interface_test.go

raw symbols SCIP
1 // Copyright 2021 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.
4
5 package command_test
6
7 import (
8 "os"
9 "testing"
10
11 "github.com/google/go-cmp/cmp"
12 "golang.org/x/tools/gopls/internal/protocol/command/gen"
13 "golang.org/x/tools/internal/testenv"
14 )
15
16 // TestGenerated ensures that we haven't forgotten to update command_gen.go.
17 func TestGenerated(t *testing.T) {
18 testenv.NeedsGoPackages(t)
19 testenv.NeedsLocalXTools(t)
20
21 onDisk, err := os.ReadFile("command_gen.go")
22 if err != nil {
23 t.Fatal(err)
24 }
25
26 generated, err := gen.Generate()
27 if err != nil {
28 t.Fatal(err)
29 }
30 if diff := cmp.Diff(string(generated), string(onDisk)); diff != "" {
31 t.Errorf("command_gen.go is stale -- regenerate (-generated +on disk)\n%s", diff)
32 }
33 }