1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:54:43 -07:00

debug: use strings.Builder

Change-Id: I59db11212758b478248f34c031501a167335348c
Reviewed-on: https://go-review.googlesource.com/c/go/+/428257
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
cuiweixie 2022-09-04 17:31:08 +08:00 committed by Gopher Robot
parent 32f68b5ab7
commit a89c3d76ba

View File

@ -80,13 +80,13 @@ func TestReadFile(t *testing.T) {
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o="+outPath, "-buildmode="+buildmode) cmd := exec.Command(testenv.GoToolPath(t), "build", "-o="+outPath, "-buildmode="+buildmode)
cmd.Dir = dir cmd.Dir = dir
cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOOS="+goos, "GOARCH="+goarch) cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOOS="+goos, "GOARCH="+goarch)
stderr := &bytes.Buffer{} stderr := &strings.Builder{}
cmd.Stderr = stderr cmd.Stderr = stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
if badmodeMsg := badmode(goos, goarch, buildmode); strings.Contains(stderr.String(), badmodeMsg) { if badmodeMsg := badmode(goos, goarch, buildmode); strings.Contains(stderr.String(), badmodeMsg) {
t.Skip(badmodeMsg) t.Skip(badmodeMsg)
} }
t.Fatalf("failed building test file: %v\n%s", err, stderr.Bytes()) t.Fatalf("failed building test file: %v\n%s", err, stderr.String())
} }
return outPath return outPath
} }
@ -106,13 +106,13 @@ func TestReadFile(t *testing.T) {
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o="+outPath, "-buildmode="+buildmode) cmd := exec.Command(testenv.GoToolPath(t), "build", "-o="+outPath, "-buildmode="+buildmode)
cmd.Dir = pkgDir cmd.Dir = pkgDir
cmd.Env = append(os.Environ(), "GO111MODULE=off", "GOPATH="+gopathDir, "GOOS="+goos, "GOARCH="+goarch) cmd.Env = append(os.Environ(), "GO111MODULE=off", "GOPATH="+gopathDir, "GOOS="+goos, "GOARCH="+goarch)
stderr := &bytes.Buffer{} stderr := &strings.Builder{}
cmd.Stderr = stderr cmd.Stderr = stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
if badmodeMsg := badmode(goos, goarch, buildmode); strings.Contains(stderr.String(), badmodeMsg) { if badmodeMsg := badmode(goos, goarch, buildmode); strings.Contains(stderr.String(), badmodeMsg) {
t.Skip(badmodeMsg) t.Skip(badmodeMsg)
} }
t.Fatalf("failed building test file: %v\n%s", err, stderr.Bytes()) t.Fatalf("failed building test file: %v\n%s", err, stderr.String())
} }
return outPath return outPath
} }