Skip to content

Tests: Replace WhenAny/Delay timeouts with WaitOrTimeoutAsync - #141

Merged
Menelion merged 1 commit into
masterfrom
fix/ca2027-test-timeouts
Nov 14, 2026
Merged

Menelion merged 1 commit into
masterfrom
fix/ca2027-test-timeouts

Conversation

@Menelion

Copy link
Copy Markdown
Contributor

Why

Dependabot PR #139 bumps Microsoft.CodeAnalysis.NetAnalyzers to 11.0.100, which adds CA2027: Task.WhenAny(task, Task.Delay(...)) leaves the delay timer running after the task completes. dotnet format --verify-no-changes reports it, so the format check fails (12 warnings, all in tests).

What

  • New test helper WaitOrTimeoutAsync(timeout) in tests/SharpSync.Tests/Fixtures/TaskExtensions.cs, built on Task.WaitAsync. It returns false on timeout instead of throwing, so the timing-tolerant pause tests keep their current behavior.
  • All 12 WhenAny/Delay sites in SyncEngineTests, SyncEngineEdgeCaseTests and SyncEngineThreadSafetyTests now use it. The unused pauseOrTimeout variables are gone.

Verification

  • dotnet test: 819 passed, 0 failed, 130 integration tests skipped.
  • dotnet format --verify-no-changes passes with NetAnalyzers 10.0.403 and with 11.0.100 swapped in locally.

After merging, @dependabot rebase on #139 should turn it green.

Microsoft.CodeAnalysis.NetAnalyzers 11 adds CA2027, which flags
Task.WhenAny(task, Task.Delay(...)) because the delay timer keeps
running after the task completes. dotnet format reports it, which
fails the format check in CI (Dependabot PR #139).

Add a WaitOrTimeoutAsync test helper built on Task.WaitAsync that
returns false on timeout instead of throwing, so the timing-tolerant
pause tests keep their current behavior, and use it at all 12 sites.
@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.82%. Comparing base (9e7c9fd) to head (48d8ea9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #141   +/-   ##
=======================================
  Coverage   78.82%   78.82%           
=======================================
  Files          44       44           
  Lines        4874     4874           
  Branches      726      726           
=======================================
  Hits         3842     3842           
  Misses        775      775           
  Partials      257      257           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Menelion
Menelion merged commit d7934f7 into master Nov 14, 2026
5 checks passed
@Menelion
Menelion deleted the fix/ca2027-test-timeouts branch November 14, 2026 01:10
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