Skip to content

test(core): stabilise flaky FileWatcher debounce test#17

Merged
tgiachi merged 1 commit into
developfrom
fix/flaky-filewatcher-debounce
Jun 30, 2026
Merged

test(core): stabilise flaky FileWatcher debounce test#17
tgiachi merged 1 commit into
developfrom
fix/flaky-filewatcher-debounce

Conversation

@tgiachi

@tgiachi tgiachi commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Problem

CI failed on an unrelated, pre-existing flaky test:

SquidStd.Tests.Core.Files.FileWatcherServiceTests.Watch_RapidWritesToSameFile_DebouncesToSingleEvent
Assert.Single() Failure: The collection contained 2 matching items
Failed: 1, Passed: 916

The test does five rapid writes and expects the 200ms debounce to collapse them into one FileChangedEvent. On a loaded CI runner, a scheduler/GC pause >200ms between writes splits the burst across two debounce windows → two events → Assert.Single fails. It is a test-timing race, not a product bug; the FileWatcher debounce works correctly.

Fix

For this test only: use a 1s debounce window and a tight synchronous write loop (no await points the scheduler can preempt mid-burst), so the five writes reliably land in one window. The assertion's intent (rapid writes collapse to a single event) is unchanged.

Test plan

  • FileWatcherServiceTests green across 3 consecutive local runs (7/7 each)
  • Test project builds (0 errors)

Watch_RapidWritesToSameFile_DebouncesToSingleEvent assumed five rapid writes
fall inside one 200ms debounce window; on a loaded CI runner a scheduler/GC
pause between writes split the burst across two windows, emitting two events and
failing Assert.Single. Use a 1s debounce window for this test and a tight
synchronous write loop so the burst reliably collapses to a single event without
weakening the assertion's intent.
@tgiachi
tgiachi merged commit fe2f1ff into develop Jun 30, 2026
3 checks passed
@tgiachi
tgiachi deleted the fix/flaky-filewatcher-debounce branch June 30, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant