Fail the whole-replay comparison where it compared no read set

This commit is contained in:
2026-09-28 22:26:35 +02:00
committed by Lillem4n
parent 0825819e44
commit 19033bf2e5
+13 -3
View File
@@ -160,12 +160,16 @@ func TestReplayPairsFindsWhatAWholeReplayFinds(t *testing.T) {
} }
return nil return nil
}) })
compared := 0
for _, root := range roots { for _, root := range roots {
wantPairsFindAll(t, root.label, renderDraws(root.t).reads) compared += wantPairsFindAll(t, root.label, renderDraws(root.t).reads)
if root.t.isRecord && len(root.t.fields) > 0 { if root.t.isRecord && len(root.t.fields) > 0 {
wantPairsFindAll(t, root.label+" as a record", columnDraws(root.t, sortedNames(root.t.fields)).reads) compared += wantPairsFindAll(t, root.label+" as a record", columnDraws(root.t, sortedNames(root.t.fields)).reads)
} }
} }
if compared == 0 {
t.Error("no read set rendering together holds two table reads, so the comparison proved nothing")
}
} }
func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) { func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) {
@@ -209,7 +213,8 @@ func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) {
} }
} }
func wantPairsFindAll(t *testing.T, label string, reads []pathRead) { // wantPairsFindAll counts the read sets rendering together that hold two table reads or more.
func wantPairsFindAll(t *testing.T, label string, reads []pathRead) int {
t.Helper() t.Helper()
var tabled []pathRead var tabled []pathRead
for _, r := range reads { for _, r := range reads {
@@ -219,7 +224,11 @@ func wantPairsFindAll(t *testing.T, label string, reads []pathRead) {
} }
pairs := replayPairs(reads) pairs := replayPairs(reads)
var whole error var whole error
compared := 0
eachRenderSet(tabled, func(set []pathRead) { eachRenderSet(tabled, func(set []pathRead) {
if len(set) > 1 {
compared++
}
var d pinSet var d pinSet
for _, r := range set { for _, r := range set {
if err := r.tr.replay(&d); err != nil && whole == nil { if err := r.tr.replay(&d); err != nil && whole == nil {
@@ -230,6 +239,7 @@ func wantPairsFindAll(t *testing.T, label string, reads []pathRead) {
if (pairs == nil) != (whole == nil) { if (pairs == nil) != (whole == nil) {
t.Errorf("%s: replayPairs = %v, a whole replay of every read set rendering together = %v", label, pairs, whole) t.Errorf("%s: replayPairs = %v, a whole replay of every read set rendering together = %v", label, pairs, whole)
} }
return compared
} }
// eachRenderSet calls fn with every maximal set of reads that render together, by Bron–Kerbosch. // eachRenderSet calls fn with every maximal set of reads that render together, by Bron–Kerbosch.