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.
14 "golang.org/x/tools/internal/testenv"
17 func TestLicenses(t *testing.T) {
18 // License text differs for older Go versions because staticcheck isn't
19 // supported for those versions.
20 testenv.NeedsGo1Point(t, 15)
22 if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
23 t.Skip("generating licenses only works on Unixes")
25 tmp, err := ioutil.TempFile("", "")
31 if out, err := exec.Command("./gen-licenses.sh", tmp.Name()).CombinedOutput(); err != nil {
32 t.Fatalf("generating licenses failed: %q, %v", out, err)
35 got, err := ioutil.ReadFile(tmp.Name())
39 want, err := ioutil.ReadFile("licenses.go")
43 if !bytes.Equal(got, want) {
44 t.Error("combined license text needs updating. Run: `go generate ./internal/hooks` from the gopls module.")