reflect/prototype: disable detrand for test
Change-Id: I62cadc7f02afb9a6ee84c5ae2d7857be4b405360
Reviewed-on: https://go-review.googlesource.com/c/153021
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/reflect/prototype/type_test.go b/reflect/prototype/type_test.go
index 698f0d0..1465f4b 100644
--- a/reflect/prototype/type_test.go
+++ b/reflect/prototype/type_test.go
@@ -13,6 +13,7 @@
"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 @@
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 @@
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)
}