Fix flaky UrlProtocolTest.RegistrarTest race condition. Fixes #25223#25255
Fix flaky UrlProtocolTest.RegistrarTest race condition. Fixes #25223#25255rolfbjarne merged 2 commits intomainfrom
Conversation
StopLoading is called asynchronously by the URL loading system after the download task completes. The test was asserting State==5 immediately when the task finished, but StopLoading (which increments State from 4 to 5) hadn't fired yet. Fix by: - Using the RunAsync(timeout, task, check_completed) overload that polls until State>=5 instead of returning as soon as the task completes. - Resetting State=0 at test start to prevent cross-test interference. Fixes #25223 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a race in the UrlProtocolTest.RegistrarTest where the test could assert State == 5 before NSUrlProtocol.StopLoading had been invoked, causing intermittent failures on CI (issue #25223).
Changes:
- Reset
CustomUrlProtocol.Stateat the start ofRegistrarTestto avoid cross-test interference. - Switch to the
TestRuntime.RunAsync(timeout, task, check_completed)overload to wait untilCustomUrlProtocol.State >= 5(i.e., untilStopLoadinghas fired), not just until the download task completes.
…coltest-flaky # Conflicts: # tests/monotouch-test/Foundation/UrlProtocolTest.cs
✅ [PR Build #859b6c4] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #859b6c4] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #859b6c4] Build passed (Build macOS tests) ✅Pipeline on Agent |
🚀 [CI Build #859b6c4] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 156 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
StopLoading is called asynchronously by the URL loading system after the download task completes. The test was asserting
State==5immediately when the task finished, butStopLoading(which increments State from 4 to 5) hadn't fired yet.Fix by:
RunAsync(timeout, task, check_completed)overload that polls untilState>=5instead of returning as soon as the task completes.State=0at test start to prevent cross-test interference.Fixes #25223