From 5a87dc04d31e76c46d3be57a4a440dfff0699eb6 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 29 Sep 2026 01:15:22 +0200 Subject: [PATCH] Pin readField's unheld-path panic past the trace check, and fail the gathered-reads test when nothing traced --- drawfence_test.go | 13 +++++++++---- hold_test.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drawfence_test.go b/drawfence_test.go index 03dca96..7bfb00c 100644 --- a/drawfence_test.go +++ b/drawfence_test.go @@ -61,8 +61,9 @@ func fenceRoots(t *testing.T, f *Generator) ([]fenceRoot, map[string]*table) { func TestEveryReadARenderMakesIsGathered(t *testing.T) { f := fenceCorpus(t) roots, tables := fenceRoots(t, f) + traced := 0 for _, root := range roots { - wantGathered(t, tables, root.label, renderDraws(root.t).reads, func(trace renderTrace) { renderRoot(f.rand, root.t, trace) }) + traced += wantGathered(t, tables, root.label, renderDraws(root.t).reads, func(trace renderTrace) { renderRoot(f.rand, root.t, trace) }) if !root.t.isRecord || len(root.t.fields) == 0 { continue } @@ -70,11 +71,14 @@ func TestEveryReadARenderMakesIsGathered(t *testing.T) { if err != nil { t.Fatalf("%s: recordOf = %v", root.label, err) } - wantGathered(t, tables, root.label+" as a record", columnDraws(root.t, sortedNames(root.t.fields)).reads, func(trace renderTrace) { renderRecordRoot(f.rand, root.t, columns, trace) }) + traced += wantGathered(t, tables, root.label+" as a record", columnDraws(root.t, sortedNames(root.t.fields)).reads, func(trace renderTrace) { renderRecordRoot(f.rand, root.t, columns, trace) }) + } + if traced == 0 { + t.Error("no render traced a reference read, so the comparison proved nothing") } } -func wantGathered(t *testing.T, tables map[string]*table, label string, gathered []pathRead, renderOnce func(renderTrace)) { +func wantGathered(t *testing.T, tables map[string]*table, label string, gathered []pathRead, renderWith func(renderTrace)) int { t.Helper() var reads []pathRead type traceKey struct { @@ -96,13 +100,14 @@ func wantGathered(t *testing.T, tables map[string]*table, label string, gathered } } for i := 0; i < 5; i++ { - renderOnce(trace) + renderWith(trace) } for _, r := range reads { if !gathers(gathered, r) { t.Errorf("%s: the render read {%s} in draw group %q from %s, and drawWalk gathered no such read", label, r.a.spelling, r.at.group, spellPins(&r.at.pins)) } } + return len(reads) } func gathers(gathered []pathRead, r pathRead) bool { diff --git a/hold_test.go b/hold_test.go index f6ede64..a2d4830 100644 --- a/hold_test.go +++ b/hold_test.go @@ -766,6 +766,6 @@ func TestReadFieldPanicsOnAnUnheldPath(t *testing.T) { t.Fatal("not a template") } mustPanic(t, "unheld arm with a path", func() { - readField(engine(1).rand, tm, nil, renderScope{}, arm{spelling: "w.x", key: "w", tail: []string{"x"}, path: "w.x"}) + readField(engine(1).rand, tm, nil, renderScope{set: &holdSet{}}, arm{spelling: "w.x", key: "w", tail: []string{"x"}, path: "w.x"}) }) }