github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/testutils/lint/nightly_lint_test.go (about) 1 // Copyright 2016 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 // +build lint,nightly 12 13 package lint 14 15 import ( 16 "bytes" 17 "os" 18 "os/exec" 19 "testing" 20 21 "github.com/cockroachdb/cockroach/pkg/cmd/urlcheck/lib/urlcheck" 22 sqlparser "github.com/cockroachdb/cockroach/pkg/sql/parser" 23 ) 24 25 func TestNightlyLint(t *testing.T) { 26 _, pkgSpecified := os.LookupEnv("PKG") 27 28 // TestHelpURLs checks that all help texts have a valid documentation URL. 29 t.Run("TestHelpURLs", func(t *testing.T) { 30 if testing.Short() { 31 t.Skip("short flag") 32 } 33 if pkgSpecified { 34 t.Skip("PKG specified") 35 } 36 37 t.Parallel() 38 var buf bytes.Buffer 39 for key, body := range sqlparser.HelpMessages { 40 msg := sqlparser.HelpMessage{Command: key, HelpMessageBody: body} 41 buf.WriteString(msg.String()) 42 } 43 cmd := exec.Command("grep", "-nE", urlcheck.URLRE) 44 cmd.Stdin = &buf 45 if err := urlcheck.CheckURLsFromGrepOutput(cmd); err != nil { 46 t.Fatal(err) 47 } 48 }) 49 }