Commit 84986acb authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 56497b45
tTreeEnv += Run to run subtest
Canceled becase too much change for sole single use-case.
Probably drop this patch.
diff --git a/wcfs/internal/xbtree/δbtail_test.go b/wcfs/internal/xbtree/δbtail_test.go
index c810941a..ed8020be 100644
--- a/wcfs/internal/xbtree/δbtail_test.go
+++ b/wcfs/internal/xbtree/δbtail_test.go
@@ -905,7 +905,7 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
// assertTrack verifies that trackSet == trackSetOK.
// XXX place
// XXX inline into δbtail.assertTrack?
-func _assertTrack(t *testing.T, subj string, trackSet, trackSetOK PPTreeSubSet) {
+func _assertTrack(t testing.TB, subj string, trackSet, trackSetOK PPTreeSubSet) {
t.Helper()
if !trackSet.Equal(trackSetOK) {
t.Errorf("%s:\n\thave: %v\n\twant: %v", subj, trackSet, trackSetOK)
@@ -915,7 +915,7 @@ func _assertTrack(t *testing.T, subj string, trackSet, trackSetOK PPTreeSubSet)
// assertTrack verifies state of .trackSet and ΔTtail.trackNew.
// it assumes that only one tree root is being tracked.
// XXX place
-func (δBtail *ΔBtail) assertTrack(t *testing.T, subj string, trackSetOK PPTreeSubSet, trackNewOK PPTreeSubSet) {
+func (δBtail *ΔBtail) assertTrack(t testing.TB, subj string, trackSetOK PPTreeSubSet, trackNewOK PPTreeSubSet) {
t.Helper()
_assertTrack(t, subj + ": trackSet", δBtail.trackSet, trackSetOK)
@@ -954,11 +954,17 @@ func (δBtail *ΔBtail) assertTrack(t *testing.T, subj string, trackSetOK PPTree
// xverifyΔBTail_rebuild verifies ΔBtail.rebuild during t0->t1->t2 transition.
//
+// t0,t1,t2 are taken as t.Head~~,t.Head~,t.Head
+//
// t0->t1 exercises from-scratch rebuild,
// t1->t2 further exercises incremental rebuild.
//
// It also exercises rebuild phase of ΔBtail.Update.
-func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1, t2 *tTreeCommit) {
+func xverifyΔBTail_rebuild(t tTreeEnv) {
+ t2 := t.Head()
+ t1 := t2.prev
+ t0 := t1.prev
+
t.Run(fmt.Sprintf("rebuild/%s→%s", t0.tree, t1.tree), func(t *testing.T) {
tAllKeys := allTestKeys(t0, t1, t2)
tAllKeyv := tAllKeys.SortedElements()
@@ -1001,12 +1007,12 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
}
}
- t.Run(fmt.Sprintf(" T%s;R", keys1), func(t *testing.T) {
- δbtail := NewΔBtail(t0.at, db)
+ t.Run(fmt.Sprintf(" T%s;R", keys1), func(t tTreeEnv) {
+ δbtail := NewΔBtail(t0.at, t.DB())
// assert trackSet=ø, trackNew=ø, vδB=[]
δbtail.assertTrack(t, "@at0", ø, ø)
- assertΔTtail(t, "@at0", δbtail, t0, treeRoot, xat,
+ assertΔTtail(t, "@at0", δbtail, xat,
/*vδT=ø*/)
xverifyΔBTail_rebuild_U(t, δbtail, treeRoot, t0, t1, xat,
@@ -1120,10 +1126,10 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
/* trackSet=*/ t2.xkv.trackSet(keys12R2),
/*vδT=*/ δkv1_k12R2, δkv2_k12R2)
- // XXX move vvv to separate test (out of this inner loop)
- // ΔBtail.Clone had bug that aliased klon data to orig
- assertΔTtail(t, "BUG: after clone check", δbtail, t2, treeRoot, xat,
- /*vδT=*/ δkv1_k1R2, δkv2_k1R2)
+// // XXX move vvv to separate test (out of this inner loop)
+// // ΔBtail.Clone had bug that aliased klon data to orig
+// assertΔTtail(t, "BUG: after clone check", δbtail, t2, treeRoot, xat,
+// /*vδT=*/ δkv1_k1R2, δkv2_k1R2)
//})
}
})
@@ -1143,7 +1149,7 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, treeRoot zodb.Oid,
// Update ati -> atj
δB, err := δbtail.Update(tj.δZ); X(err)
δbtail.assertTrack(t, subj, trackSet, ø)
- assertΔTtail(t, subj, δbtail, tj, treeRoot, xat, vδTok...)
+ assertΔTtail(t, subj, δbtail, xat, vδTok...)
// assert δB = vδTok[-1]
var δT, δTok map[Key]Δstring
@@ -1196,14 +1202,16 @@ func xverifyΔBTail_rebuild_TR(t *testing.T, δbtail *ΔBtail, tj *tTreeCommit,
// XXX verify Get -> XXX assertΔTtail ?
// verify δbtail.vδTbyRoot[treeRoot]
- assertΔTtail(t, subj, δbtail, tj, treeRoot, xat, vδTok...)
+ assertΔTtail(t, subj, δbtail, xat, vδTok...)
}
// assertΔTtail verifies state of ΔTtail that corresponds to treeRoot in δbtail.
-func assertΔTtail(t *testing.T, subj string, δbtail *ΔBtail, tj *tTreeCommit, treeRoot zodb.Oid, xat map[zodb.Tid]string, vδTok ...map[Key]Δstring) {
+func assertΔTtail(t tTreeEnv, subj string, δbtail *ΔBtail, xat map[zodb.Tid]string, vδTok ...map[Key]Δstring) {
t.Helper()
// XXX +KVAtTail, +lastRevOf
+ tj := t.Head() // XXX just used head?
+
l := len(vδTok)
var vatOK []zodb.Tid
var vδTok_ []map[Key]Δstring
@@ -1219,7 +1227,7 @@ func assertΔTtail(t *testing.T, subj string, δbtail *ΔBtail, tj *tTreeCommit,
at2t[t0.at] = t0
}
vδTok = vδTok_
- δTtail, ok := δbtail.vδTbyRoot[treeRoot]
+ δTtail, ok := δbtail.vδTbyRoot[t.Root()]
var vδToid []ΔTree
if ok {
vδToid = δTtail.vδT
@@ -1391,12 +1399,27 @@ func ΔBTest(xtest interface{}) ΔBTestEntry {
}
+// tTreeEnv is tree-based testing environment.
+//
+// It provides client side read-only access to ZODB with committed trees.
+type tTreeEnv interface {
+ Root() zodb.Oid // oid of root node
+ Head() *tTreeCommit // most-recently committed tree
+ DB() *zodb.DB // DB that provides access to ZODB storage
+
+ // Run runs a subtest similarly to testing.T.Run
+ Run(name string, f func(t tTreeEnv)) bool
+
+ testing.TB
+}
+
+
// tTreeEnv is tree-based testing environment.
//
// It combines TreeSrv and client side access to ZODB with committed trees. XXX
//
-// Create it with tTreeEnv().
-type tTreeEnv struct {
+// Create it with tNewTreeEnv().
+type tTreeEnvMain struct {
*testing.T
work string // working directory
@@ -1638,7 +1661,7 @@ func testΔBTail(t_ *testing.T, testq chan ΔBTestEntry) {
// ΔBTail.rebuild
if t0 != nil {
- xverifyΔBTail_rebuild(t.T, t.db, t.treeSrv.treeRoot, t0,t1,t2)
+ xverifyΔBTail_rebuild(t)
}
t0, t1 = t1, t2
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