From 05d60cda2c5e250a6fa6a20e8c0538edea2b9829 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Thu, 6 Dec 2018 16:44:24 -0800 Subject: [PATCH] reflect/prototype: disable detrand for test Change-Id: I62cadc7f02afb9a6ee84c5ae2d7857be4b405360 Reviewed-on: https://go-review.googlesource.com/c/153021 Reviewed-by: Herbie Ong --- reflect/prototype/type_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/reflect/prototype/type_test.go b/reflect/prototype/type_test.go index 698f0d0f..1465f4ba 100644 --- a/reflect/prototype/type_test.go +++ b/reflect/prototype/type_test.go @@ -13,6 +13,7 @@ import ( "testing" protoV1 "github.com/golang/protobuf/proto" + detrand "github.com/golang/protobuf/v2/internal/detrand" scalar "github.com/golang/protobuf/v2/internal/scalar" pdesc "github.com/golang/protobuf/v2/reflect/protodesc" pref "github.com/golang/protobuf/v2/reflect/protoreflect" @@ -21,6 +22,11 @@ import ( descriptorpb "github.com/golang/protobuf/v2/types/descriptor" ) +func init() { + // Disable detrand to enable direct comparisons on outputs. + detrand.Disable() +} + // TODO: Test protodesc.NewFile with imported files. func TestFile(t *testing.T) { @@ -811,7 +817,6 @@ func testFileFormat(t *testing.T, fd pref.FileDescriptor) { tests := []struct{ fmt, want string }{{"%v", compactMultiFormat(want)}, {"%+v", want}} for _, tt := range tests { got := fmt.Sprintf(tt.fmt, fd) - got = strings.Replace(got, "FileDescriptor ", "FileDescriptor", 1) // cleanup randomizer if got != tt.want { t.Errorf("fmt.Sprintf(%q, fd):\ngot: %s\nwant: %s", tt.fmt, got, tt.want) }