Commit 475647e2 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: persistent tests: Print all problems about checked object, not only the first one

Seeing all problems helps to understand what is going on, compared to
e.g. if it complains only about .jar being wrong.
parent 876a7509
...@@ -74,10 +74,9 @@ func checkObj(t testing.TB, obj IPersistent, jar *Connection, oid Oid, serial Ti ...@@ -74,10 +74,9 @@ func checkObj(t testing.TB, obj IPersistent, jar *Connection, oid Oid, serial Ti
xbase := reflect.ValueOf(obj).Elem().FieldByName("Persistent") xbase := reflect.ValueOf(obj).Elem().FieldByName("Persistent")
pbase := xbase.Addr().Interface().(*Persistent) pbase := xbase.Addr().Interface().(*Persistent)
var badv []string
badf := func(format string, argv ...interface{}) { badf := func(format string, argv ...interface{}) {
t.Helper() badv = append(badv, fmt.Sprintf(format, argv...))
msg := fmt.Sprintf(format, argv...)
t.Fatalf("%#v: %s", obj, msg)
} }
zc := pbase.zclass zc := pbase.zclass
...@@ -105,6 +104,14 @@ func checkObj(t testing.TB, obj IPersistent, jar *Connection, oid Oid, serial Ti ...@@ -105,6 +104,14 @@ func checkObj(t testing.TB, obj IPersistent, jar *Connection, oid Oid, serial Ti
if pbase.instance != obj { if pbase.instance != obj {
badf("base.instance != obj") badf("base.instance != obj")
} }
if len(badv) != 0 {
msg := fmt.Sprintf("%#v:\n", obj)
for _, bad := range badv {
msg += fmt.Sprintf("\t- %s\n", bad)
}
t.Fatal(msg)
}
} }
// tCheckObj binds checkObj to t. // tCheckObj binds checkObj to t.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment