From 6c18d0ec2e01c69c79a005e8ce4194567b945cc2 Mon Sep 17 00:00:00 2001 From: Ben Luddy Date: Mon, 1 Jul 2024 21:23:19 -0400 Subject: [PATCH] Fix fmt verbs for strings in roundtrip test errors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some of the calls to t.Errorf from apitesting/roundtrip use the %#v verb (Go-syntax representation) for string arguments that are have already been formatted for legibility by something like like cmp.Diff. Quoting and escaping newlines in these strings makes them harder to read, like this: > ... > "(*storage.CSIDriver)({\n TypeMeta: (v1.TypeMeta) {\n Kind: (string) \"\",\n APIVersion: (string) > \"\"\n },\n ObjectMeta: (v1.ObjectMeta) {\n Name: (string) (len=15) \"犱âM邽[ǎ*ʄ\",\n > ... --- .../apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go index eb6c7cfa81c..54968948601 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go @@ -350,14 +350,14 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object // decode (deserialize) the encoded data back into an object obj2, err := runtime.Decode(codec, data) if err != nil { - t.Errorf("%v: %v\nCodec: %#v\nData: %s\nSource: %#v", name, err, codec, dataAsString(data), dump.Pretty(object)) + t.Errorf("%v: %v\nCodec: %#v\nData: %s\nSource: %s", name, err, codec, dataAsString(data), dump.Pretty(object)) panic("failed") } // ensure that the object produced from decoding the encoded data is equal // to the original object if !apiequality.Semantic.DeepEqual(original, obj2) { - t.Errorf("%v: diff: %v\nCodec: %#v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, cmp.Diff(original, obj2), codec, dump.Pretty(original), dataAsString(data), dump.Pretty(obj2)) + t.Errorf("%v: diff: %v\nCodec: %#v\nSource:\n\n%s\n\nEncoded:\n\n%s\n\nFinal:\n\n%s", name, cmp.Diff(original, obj2), codec, dump.Pretty(original), dataAsString(data), dump.Pretty(obj2)) return }