Repository navigation
test: deflake FileWatcher/AuditRunner timing tests + clear nullable warning - #66
Merged
Merged
Conversation
Both tests asserted on outcomes the OS/thread-pool scheduler controls, so a loaded CI runner could fail them though the production code was correct. FileWatcher_CoalescesRapidBurst drove a real OS FileSystemWatcher on the real clock and asserted a 6-write burst debounced to exactly one notification. Under load the watcher event pump stalls >100ms mid-burst, elapsing the debounce window and splitting the burst into two notifications (the failing main CI run). Drive the debounce off a FakeTimeProvider instead: the raw events still arrive in real time, but the timer only fires on Advance, so load can no longer split the window. Reproduced 3/8 failures under CPU saturation on the old test; 12/12 pass on the new one under the same load. AuditRunner's headless-one-shot test polled the cache for up to 500ms after ApplicationStarted, which could expire under thread-pool starvation; the dev-mode test slept a flat 100ms before asserting the rendered auditor never ran. Both now await the purpose-built WaitForInitialPassAsync() seam, removing the timing entirely.
IElement.GetAttribute("href") returns a nullable string, so passing it straight
to ShouldContain tripped CS8604. Assert the href is present first, then match on
it — clears the warning via flow analysis and makes a missing href fail loudly
instead of NRE-ing inside the matcher.
|
🛰️ Docs preview: https://pr-66.pennington-dev.pages.dev Rebuilt on every push to this PR; torn down when it closes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The
cirun onmainfailed onFileWatcher_CoalescesRapidBurst_IntoSingleNotification— a flaky test, not a product regression. This PR deflakes it, sweeps the suite for the same class of defect (assertions on outcomes the OS/scheduler/clock control), and clears the one build warning that was riding along.Changes
test: deflake timing-sensitive FileWatcher and AuditRunner testsFileWatcher_CoalescesRapidBurstdrove a real OSFileSystemWatcheron the real clock and asserted a 6-write burst debounced to exactly one notification. Under load the watcher's event pump stalls >100 ms mid-burst, elapsing the 100 ms debounce window and splitting the burst into two notifications — the failing CI run. Now driven off aFakeTimeProvider: raw events still arrive in real time, but the debounce timer only fires onAdvance, so load can no longer split the window. The production debounce is unchanged.AuditRunnertests — the headless-one-shot test polled the cache for up to 500 ms afterApplicationStarted(can expire under thread-pool starvation); the dev-mode test slept a flat 100 ms before asserting the rendered auditor never ran. Both nowawaitthe purpose-builtWaitForInitialPassAsync()seam, removing the timing entirely.test(docsite): fix CS8604 nullable-argument warning in area-home testIElement.GetAttribute("href")returns a nullable string; passing it straight toShouldContaintripped CS8604. Assert the href is present first, then match — clears the warning and makes a missing href fail loudly.Audit of the rest of the suite
Swept all four test projects for the same pattern. Everything else is either well-constructed or can't false-fail:
BuildHtmlCacheTestsconcurrent coalesce —TaskCompletionSource-gated, deterministic.RenderedHtmlFetcherTests50-way concurrent — stub-backed race stress test; a failure signals a real race, not flakiness.RedirectMiddlewareTests(real Kestrel socket) — ephemeral port:0, awaitsStartAsync()(no raced sleep).FileWatcherTestsreal-OS-watcher waits use a generous 5 s ceiling on a positive "did it fire" assertion.Verification