summaryrefslogtreecommitdiff
path: root/internal/tui/tui_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 14:41:28 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 14:41:28 +0300
commitde3405c275898c8cd528a636dbd40e1b685cfaa5 (patch)
tree53711959800677aa694e18331476add24a21b8ef /internal/tui/tui_test.go
parentd392eebe5bd127e1573734321b0cabaad4182d7c (diff)
use errgroup instead of WaitGroup for concurrent snapshot builders
Replace sync.WaitGroup with errgroup.Group in buildSubSnapshots so errors from sub-builders (buildSyscallSnapshots, buildFileSnapshots, buildProcessSnapshots, buildHistogramSnapshot) are captured and propagated rather than silently dropped. Change Engine.Snapshot() to return (*Snapshot, error), update runtime.SnapshotSource and dashboard.SnapshotSource interfaces accordingly, and adjust all callers in tui.go, dashboard/model.go, and the test helpers. Each sub-builder now returns (result, error); the error return is currently always nil but establishes the contract for future validation. The per-type Snapshot() convenience methods (histogram, syscall, file, process) panic on error since they are internal helpers where failure would be a programming bug. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tui/tui_test.go')
-rw-r--r--internal/tui/tui_test.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 5f007e4..d76ccde 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -459,8 +459,8 @@ type fakeDashboardSource struct {
snap *statsengine.Snapshot
}
-func (f fakeDashboardSource) Snapshot() *statsengine.Snapshot {
- return f.snap
+func (f fakeDashboardSource) Snapshot() (*statsengine.Snapshot, error) {
+ return f.snap, nil
}
type fakeResettableDashboardSource struct {
@@ -468,8 +468,8 @@ type fakeResettableDashboardSource struct {
resetCalls int
}
-func (f *fakeResettableDashboardSource) Snapshot() *statsengine.Snapshot {
- return f.snap
+func (f *fakeResettableDashboardSource) Snapshot() (*statsengine.Snapshot, error) {
+ return f.snap, nil
}
func (f *fakeResettableDashboardSource) Reset() {
@@ -484,7 +484,10 @@ func TestDashboardRefreshPicksLateBoundSource(t *testing.T) {
want := &statsengine.Snapshot{TotalSyscalls: 77}
runtime.SetDashboardSnapshotSource(fakeDashboardSource{snap: want})
- got := source.Snapshot()
+ got, err := source.Snapshot()
+ if err != nil {
+ t.Fatalf("unexpected snapshot error: %v", err)
+ }
if got != want {
t.Fatalf("expected late-bound source to use latest runtime source")
}