fix: add open progress staging and forced key evidence to display_diag (#3)

This commit is contained in:
2026-11-28 14:43:32 +01:00
parent 903c5c69b6
commit acc721e7e7
5 changed files with 496 additions and 49 deletions
+43
View File
@@ -24,6 +24,49 @@ func TestFormatDiagLineRendersTheExactStableSchema(t *testing.T) {
}
}
func TestDiagCapBudgetCoversBothRolesWorstCase(t *testing.T) {
// Worst-case record budget for both roles through one shared emitter:
// start, per role one open_begin, open, eight open stages, forced
// first_redraw, four query stages, query, up to three snapshot
// transitions, two video transitions, two stack targets, and the
// forced summary — everything distinct, nothing deduplicated. The
// total must stay under the cap so no stage, transition or summary is
// ever dropped in normal operation.
var buf bytes.Buffer
d := NewDiag(&buf)
d.EmitForced("start", "", "pid=4321", "vcs=0123abcd")
for _, role := range []string{"canvas", "osd"} {
d.Emit("open_begin", role)
d.Emit("open", role, "window=0x600001")
for _, stage := range []string{"cursor", "window", "shapes", "map_confirm",
"presence", "wmctrl", "font_list", "font_query"} {
d.Emit("open_stage", role, "stage="+stage)
}
d.EmitForced("first_redraw", role, "trigger=initial")
for _, stage := range []string{"query_shape", "query_geom", "query_parent", "query_stack"} {
d.Emit("open_stage", role, "stage="+stage)
}
d.EmitForced("query", role, "shape=0x0+0+0")
d.Emit("snap", role, "state=none")
d.Emit("snap", role, "state=fresh")
d.Emit("snap", role, "state=stale")
d.Emit("video", role, "state=off")
d.Emit("video", role, "state=on")
d.Emit("stack", role, "target=top")
d.Emit("stack", role, "target=video/0x2c00002")
d.EmitForced("summary", role, "flushes=1")
}
emitted := strings.Count(buf.String(), "\n")
if emitted != 49 {
t.Fatalf("emitted=%d want the full 49-record worst case within the cap", emitted)
}
if emitted > DiagCap {
t.Fatalf("emitted=%d exceeds the cap %d", emitted, DiagCap)
}
}
func TestDiagCollectCommandTargetsTheStableTagWithATailCap(t *testing.T) {
// The documented collection command must filter the journal on the
// stable tag and cap the output, so it stays pasteable.