Debian Codegraph @

gopls/internal/licenses/licenses_test.go

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 // Copyright 2020 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 licenses_test
6
7 import (
8 "bytes"
9 "os"
10 "os/exec"
11 "runtime"
12 "testing"
13 )
14
15 func TestLicenses(t *testing.T) {
16 if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
17 t.Skip("generating licenses only works on Unixes")
18 }
19 tmp, err := os.CreateTemp("", "")
20 if err != nil {
21 t.Fatal(err)
22 }
23 tmp.Close() // ignore error
24
25 if out, err := exec.Command("./gen-licenses.sh", tmp.Name()).CombinedOutput(); err != nil {
26 t.Fatalf("generating licenses failed: %q, %v", out, err)
27 }
28
29 got, err := os.ReadFile(tmp.Name())
30 if err != nil {
31 t.Fatal(err)
32 }
33 want, err := os.ReadFile("licenses.go")
34 if err != nil {
35 t.Fatal(err)
36 }
37 if !bytes.Equal(got, want) {
38 t.Error("combined license text needs updating. Run: `go generate ./internal/licenses` from the gopls module.")
39 }
40 }