aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2023-09-12 18:46:45 -0700
committerGopher Robot <gobot@golang.org>2023-09-20 18:57:24 +0000
commit5b37d720e39037fec4e298c3ae44d6487f029f92 (patch)
tree013854f0d963a6b33e17fea28d48b51f9d175d10 /src
parent77a1104975ebf5646f38978a054afe7ca4501fd8 (diff)
downloadgo-5b37d720e39037fec4e298c3ae44d6487f029f92.tar.xz
all: stop using fmt.Sprintf in t.Error/t.Fatal
Change-Id: Id63e1e5ae7e225e4a6a721673bf2d43b6c398c25 Reviewed-on: https://go-review.googlesource.com/c/go/+/527701 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/internal/obj/ppc64/asm_test.go4
-rw-r--r--src/context/x_test.go3
-rw-r--r--src/runtime/defer_test.go27
3 files changed, 17 insertions, 17 deletions
diff --git a/src/cmd/internal/obj/ppc64/asm_test.go b/src/cmd/internal/obj/ppc64/asm_test.go
index b8995dc7e1..433df5c8aa 100644
--- a/src/cmd/internal/obj/ppc64/asm_test.go
+++ b/src/cmd/internal/obj/ppc64/asm_test.go
@@ -198,11 +198,11 @@ func TestPfxAlign(t *testing.T) {
t.Errorf("Failed to compile %v: %v\n", pgm, err)
}
if !strings.Contains(string(out), pgm.align) {
- t.Errorf(fmt.Sprintf("Fatal, misaligned text with prefixed instructions:\n%s\n", string(out)))
+ t.Errorf("Fatal, misaligned text with prefixed instructions:\n%s", out)
}
hasNop := strings.Contains(string(out), "00 00 00 60")
if hasNop != pgm.hasNop {
- t.Errorf(fmt.Sprintf("Fatal, prefixed instruction is missing nop padding:\n%s\n", string(out)))
+ t.Errorf("Fatal, prefixed instruction is missing nop padding:\n%s", out)
}
}
}
diff --git a/src/context/x_test.go b/src/context/x_test.go
index e006e53470..b1012fad87 100644
--- a/src/context/x_test.go
+++ b/src/context/x_test.go
@@ -408,8 +408,9 @@ func testLayers(t *testing.T, seed int64, testTimeout bool) {
t.Parallel()
r := rand.New(rand.NewSource(seed))
+ prefix := fmt.Sprintf("seed=%d", seed)
errorf := func(format string, a ...any) {
- t.Errorf(fmt.Sprintf("seed=%d: %s", seed, format), a...)
+ t.Errorf(prefix+format, a...)
}
const (
minLayers = 30
diff --git a/src/runtime/defer_test.go b/src/runtime/defer_test.go
index 3a54951c31..d73202ae6a 100644
--- a/src/runtime/defer_test.go
+++ b/src/runtime/defer_test.go
@@ -5,7 +5,6 @@
package runtime_test
import (
- "fmt"
"reflect"
"runtime"
"testing"
@@ -85,7 +84,7 @@ func TestConditionalDefers(t *testing.T) {
}
want := []int{4, 2, 1}
if !reflect.DeepEqual(want, list) {
- t.Fatal(fmt.Sprintf("wanted %v, got %v", want, list))
+ t.Fatalf("wanted %v, got %v", want, list)
}
}()
@@ -133,13 +132,13 @@ func TestAbortedPanic(t *testing.T) {
defer func() {
r := recover()
if r != nil {
- t.Fatal(fmt.Sprintf("wanted nil recover, got %v", r))
+ t.Fatalf("wanted nil recover, got %v", r)
}
}()
defer func() {
r := recover()
if r != "panic2" {
- t.Fatal(fmt.Sprintf("wanted %v, got %v", "panic2", r))
+ t.Fatalf("wanted %v, got %v", "panic2", r)
}
}()
defer func() {
@@ -156,7 +155,7 @@ func TestRecoverMatching(t *testing.T) {
defer func() {
r := recover()
if r != "panic1" {
- t.Fatal(fmt.Sprintf("wanted %v, got %v", "panic1", r))
+ t.Fatalf("wanted %v, got %v", "panic1", r)
}
}()
defer func() {
@@ -166,7 +165,7 @@ func TestRecoverMatching(t *testing.T) {
// not directly called by the panic.
r := recover()
if r != nil {
- t.Fatal(fmt.Sprintf("wanted nil recover, got %v", r))
+ t.Fatalf("wanted nil recover, got %v", r)
}
}()
}()
@@ -213,25 +212,25 @@ func TestNonSSAableArgs(t *testing.T) {
defer func() {
if globint1 != 1 {
- t.Fatal(fmt.Sprintf("globint1: wanted: 1, got %v", globint1))
+ t.Fatalf("globint1: wanted: 1, got %v", globint1)
}
if save1 != 5 {
- t.Fatal(fmt.Sprintf("save1: wanted: 5, got %v", save1))
+ t.Fatalf("save1: wanted: 5, got %v", save1)
}
if globint2 != 1 {
- t.Fatal(fmt.Sprintf("globint2: wanted: 1, got %v", globint2))
+ t.Fatalf("globint2: wanted: 1, got %v", globint2)
}
if save2 != 2 {
- t.Fatal(fmt.Sprintf("save2: wanted: 2, got %v", save2))
+ t.Fatalf("save2: wanted: 2, got %v", save2)
}
if save3 != 4 {
- t.Fatal(fmt.Sprintf("save3: wanted: 4, got %v", save3))
+ t.Fatalf("save3: wanted: 4, got %v", save3)
}
if globint3 != 1 {
- t.Fatal(fmt.Sprintf("globint3: wanted: 1, got %v", globint3))
+ t.Fatalf("globint3: wanted: 1, got %v", globint3)
}
if save4 != 4 {
- t.Fatal(fmt.Sprintf("save1: wanted: 4, got %v", save4))
+ t.Fatalf("save1: wanted: 4, got %v", save4)
}
}()
@@ -264,7 +263,7 @@ func TestDeferForFuncWithNoExit(t *testing.T) {
cond := 1
defer func() {
if cond != 2 {
- t.Fatal(fmt.Sprintf("cond: wanted 2, got %v", cond))
+ t.Fatalf("cond: wanted 2, got %v", cond)
}
if recover() != "Test panic" {
t.Fatal("Didn't find expected panic")