bd sync: 2025-12-27 15:56:42

This commit is contained in:
Steve Yegge
2025-12-27 15:56:42 -08:00
parent 87f535a65e
commit c8b912cbe6
179 changed files with 3051 additions and 10283 deletions

View File

@@ -157,26 +157,23 @@ func TestDebouncer_MultipleSequentialTriggerCycles(t *testing.T) {
})
t.Cleanup(debouncer.Cancel)
awaitCount := func(want int32) {
deadline := time.Now().Add(500 * time.Millisecond)
for time.Now().Before(deadline) {
if got := atomic.LoadInt32(&count); got >= want {
return
}
time.Sleep(5 * time.Millisecond)
}
got := atomic.LoadInt32(&count)
t.Fatalf("timeout waiting for count=%d (got %d)", want, got)
debouncer.Trigger()
time.Sleep(40 * time.Millisecond)
if got := atomic.LoadInt32(&count); got != 1 {
t.Errorf("first cycle: got %d, want 1", got)
}
debouncer.Trigger()
awaitCount(1)
time.Sleep(40 * time.Millisecond)
if got := atomic.LoadInt32(&count); got != 2 {
t.Errorf("second cycle: got %d, want 2", got)
}
debouncer.Trigger()
awaitCount(2)
debouncer.Trigger()
awaitCount(3)
time.Sleep(40 * time.Millisecond)
if got := atomic.LoadInt32(&count); got != 3 {
t.Errorf("third cycle: got %d, want 3", got)
}
}
func TestDebouncer_CancelImmediatelyAfterTrigger(t *testing.T) {