diff --git a/build/bazelutil/nogo_config.json b/build/bazelutil/nogo_config.json index 32a8763648ca..4f6f5b2f979a 100644 --- a/build/bazelutil/nogo_config.json +++ b/build/bazelutil/nogo_config.json @@ -118,6 +118,9 @@ } }, "printf": { + "analyzer_flags": { + "funcs": "ErrEvent,ErrEventf,Error,Errorf,ErrorfDepth,Event,Eventf,Fatal,Fatalf,FatalfDepth,Info,Infof,InfofDepth,AssertionFailedf,AssertionFailedWithDepthf,NewAssertionErrorWithWrappedErrf,DangerousStatementf,pgerror.New,pgerror.NewWithDepthf,pgerror.Newf,SetDetailf,SetHintf,Unimplemented,Unimplementedf,UnimplementedWithDepthf,UnimplementedWithIssueDetailf,UnimplementedWithIssuef,VEvent,VEventf,Warning,Warningf,WarningfDepth,Wrapf,WrapWithDepthf,redact.Fprint,redact.Fprintf,redact.Sprint,redact.Sprintf" + }, "only_files": { "cockroach/pkg/.*$": "first-party code" } diff --git a/pkg/testutils/docker/single_node_docker_test.go b/pkg/testutils/docker/single_node_docker_test.go index c76bbd4832d2..6317c838dc7a 100644 --- a/pkg/testutils/docker/single_node_docker_test.go +++ b/pkg/testutils/docker/single_node_docker_test.go @@ -568,7 +568,7 @@ func cleanQueryResult(queryRes string) (string, error) { r := regexp.MustCompile(`([\s\S]+)\n{3}Time:.+`) res := r.FindStringSubmatch(formatted) if len(res) < 2 { - return "", errors.Wrapf(errors.Newf("%s", queryRes), "cannot parse the query result: %#v") + return "", errors.Errorf("cannot parse the query result: %s", queryRes) } return res[1], nil diff --git a/pkg/testutils/lint/lint_test.go b/pkg/testutils/lint/lint_test.go index 5ab18dfa97de..900ce4c359bc 100644 --- a/pkg/testutils/lint/lint_test.go +++ b/pkg/testutils/lint/lint_test.go @@ -16,6 +16,7 @@ package lint import ( "bufio" "bytes" + "encoding/json" "fmt" "go/build" "os" @@ -2164,47 +2165,16 @@ func TestLint(t *testing.T) { // A function may be a Printf or Print wrapper if its last argument is ...interface{}. // If the next-to-last argument is a string, then this may be a Printf wrapper. // Otherwise it may be a Print wrapper. - printfuncs := strings.Join([]string{ - "ErrEvent", - "ErrEventf", - "Error", - "Errorf", - "ErrorfDepth", - "Event", - "Eventf", - "Fatal", - "Fatalf", - "FatalfDepth", - "Info", - "Infof", - "InfofDepth", - "AssertionFailedf", - "AssertionFailedWithDepthf", - "NewAssertionErrorWithWrappedErrf", - "DangerousStatementf", - "pgerror.New", - "pgerror.NewWithDepthf", - "pgerror.Newf", - "SetDetailf", - "SetHintf", - "Unimplemented", - "Unimplementedf", - "UnimplementedWithDepthf", - "UnimplementedWithIssueDetailf", - "UnimplementedWithIssuef", - "VEvent", - "VEventf", - "Warning", - "Warningf", - "WarningfDepth", - "Wrapf", - "WrapWithDepthf", - "redact.Fprint", - "redact.Fprintf", - "redact.Sprint", - "redact.Sprintf", - }, ",") - + // Note we retrieve the list of printfuncs from nogo_config.json. + jsonFile, err := os.ReadFile(filepath.Join(crdb.Dir, "build", "bazelutil", "nogo_config.json")) + if err != nil { + t.Error(err) + } + var printSchema map[string]map[string]map[string]string + if err := json.Unmarshal(jsonFile, &printSchema); err != nil { + t.Error(err) + } + printfuncs := printSchema["printf"]["analyzer_flags"]["funcs"] nakedGoroutineExceptions := `(` + strings.Join([]string{ `pkg/.*_test\.go`, `pkg/acceptance/.*\.go`,