detached ad7909a

test(core): guard zero allocations in animate

commit
ad7909a4729781f46aada651e9e1411ae87ab87c
author
brice · · 2026-10-04 16:45 UTC
committer
brice · · 2026-10-04 19:08 UTC
parent
dc38814
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +44 -1
M Makefile +1 -1
@@ -60,7 +60,7 @@ arch:
6060 $(HOME)/go/bin/hexcheck -hexcheck.config .hexcheck.yaml -hexcheck.root . ./...
6161 # Fast, mandatory guards for tiled content publications and SHM copies.
6262 perf-check:
63- CGO_ENABLED=0 go test ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=1
63+ CGO_ENABLED=0 go test ./internal/core ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestAnimateAllocations|TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=1
6464 check: vet test arch fakes-check log-check perf-check
6565
6666 # On-demand SDR/HDR colour check with examples/testpattern on a headless
@@ -60,7 +60,7 @@ arch:
60 $(HOME)/go/bin/hexcheck -hexcheck.config .hexcheck.yaml -hexcheck.root . ./...60 $(HOME)/go/bin/hexcheck -hexcheck.config .hexcheck.yaml -hexcheck.root . ./...
61 # Fast, mandatory guards for tiled content publications and SHM copies.61 # Fast, mandatory guards for tiled content publications and SHM copies.
62 perf-check:62 perf-check:
63- CGO_ENABLED=0 go test ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=163+ CGO_ENABLED=0 go test ./internal/core ./internal/app ./internal/adapters/drm ./internal/adapters/vulkan ./internal/adapters/wayland -run '^(TestAnimateAllocations|TestOutputRoutingAllocations|TestReportSeenAllocations|TestFrameLifecycleTransitionsAllocations|TestFullscreenShownAllocations|TestFrameDecisionAllocations|TestCommitFrameAllocations|TestColorPipelineAllocations|TestShownBySnapshotAllocations|TestDueFramesAllocations|TestRenderSteadyStateAllocations|TestAccountFlipAllocations|TestFlipDoneAllocations|TestSceneWalkUnchangedTiledSHM|TestTiledCommitPublishAllocations|TestCapturedCommitApplyAllocations|TestCapturedViewportApplyAllocations|TestEffectiveInputEmptyTreeAllocations|TestHeadlessTiledSHMCallbackAndCopyBudget)$$' -count=1
64 check: vet test arch fakes-check log-check perf-check64 check: vet test arch fakes-check log-check perf-check
65 65
66 # On-demand SDR/HDR colour check with examples/testpattern on a headless66 # On-demand SDR/HDR colour check with examples/testpattern on a headless
A internal/core/animate_alloc_test.go +43 -0
@@ -0,0 +1,43 @@
1+package core
2+
3+import (
4+ "testing"
5+ "time"
6+)
7+
8+// TestAnimateAllocations guards animate: with a camera, a switch and 20 rect
9+// motions running it allocates nothing.
10+func TestAnimateAllocations(t *testing.T) {
11+ c, ic := indicatorCore(t)
12+ c.cfg.Animations.On = true
13+ sc := c.cur()
14+ t0 := ic.now
15+ m := sc.mon
16+ m.AddWindow(1)
17+ m.AddWindow(2)
18+
19+ ws := m.Workspaces[0]
20+ ws.motion = c.spring(viewSpring(100, 0), t0)
21+ ws.shift = 100
22+ m.switchMotion = c.spring(workspaceSpring(100, 0), t0)
23+ m.switchOff = 100
24+ sc.rects = make(map[WindowID]rectMotion, 20)
25+ for i := range 20 {
26+ sp := viewSpring(50, 0)
27+ sc.rects[WindowID(100+i)] = rectMotion{
28+ x: c.spring(sp, t0), y: c.spring(sp, t0),
29+ w: c.spring(sp, t0), h: c.spring(sp, t0),
30+ dx: 50, dy: 50, dw: 50, dh: 50,
31+ }
32+ }
33+
34+ now := t0.Add(10 * time.Millisecond)
35+ for name, only := range map[string]*screen{"all": nil, "only": sc} {
36+ if n := testing.AllocsPerRun(100, func() { c.animate(now, only) }); n != 0 {
37+ t.Errorf("animate(%s) allocs = %v, want 0", name, n)
38+ }
39+ }
40+ if !ws.motion.on || !m.switchMotion.on || len(sc.rects) != 20 {
41+ t.Fatalf("motions settled: camera %v switch %v rects %d", ws.motion.on, m.switchMotion.on, len(sc.rects))
42+ }
43+}
@@ -0,0 +1,43 @@
1+package core
2+
3+import (
4+ "testing"
5+ "time"
6+)
7+
8+// TestAnimateAllocations guards animate: with a camera, a switch and 20 rect
9+// motions running it allocates nothing.
10+func TestAnimateAllocations(t *testing.T) {
11+ c, ic := indicatorCore(t)
12+ c.cfg.Animations.On = true
13+ sc := c.cur()
14+ t0 := ic.now
15+ m := sc.mon
16+ m.AddWindow(1)
17+ m.AddWindow(2)
18+
19+ ws := m.Workspaces[0]
20+ ws.motion = c.spring(viewSpring(100, 0), t0)
21+ ws.shift = 100
22+ m.switchMotion = c.spring(workspaceSpring(100, 0), t0)
23+ m.switchOff = 100
24+ sc.rects = make(map[WindowID]rectMotion, 20)
25+ for i := range 20 {
26+ sp := viewSpring(50, 0)
27+ sc.rects[WindowID(100+i)] = rectMotion{
28+ x: c.spring(sp, t0), y: c.spring(sp, t0),
29+ w: c.spring(sp, t0), h: c.spring(sp, t0),
30+ dx: 50, dy: 50, dw: 50, dh: 50,
31+ }
32+ }
33+
34+ now := t0.Add(10 * time.Millisecond)
35+ for name, only := range map[string]*screen{"all": nil, "only": sc} {
36+ if n := testing.AllocsPerRun(100, func() { c.animate(now, only) }); n != 0 {
37+ t.Errorf("animate(%s) allocs = %v, want 0", name, n)
38+ }
39+ }
40+ if !ws.motion.on || !m.switchMotion.on || len(sc.rects) != 20 {
41+ t.Fatalf("motions settled: camera %v switch %v rects %d", ws.motion.on, m.switchMotion.on, len(sc.rects))
42+ }
43+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 26

Tags 10

↑↓ moveenter openesc close