fix: FileSystemWatcher MoveTests parallel stability with MockFileSystem#966
fix: FileSystemWatcher MoveTests parallel stability with MockFileSystem#966
Conversation
Co-authored-by: vbreuss <3438234+vbreuss@users.noreply.github.com>
|
@copilot The unit tests failed on the CI build pipeline. Please check what happened and fix the issue |
The CI failures are pre-existing and unrelated to this PR's changes:
All 10,072 tests pass locally on net10.0 (0 failures). |
Please create two separate pull requests to fix the two flaky tests |
I'm unable to create new pull requests - I can only push changes to this PR's branch. If you'd like, I can fix both issues directly in this branch, or I can document the root causes and suggested fixes for you to open separate PRs manually. Issue 1 – macOS crash in Issue 2 – Windows net48 Let me know if you'd like me to implement these fixes here. |
|
@copilot can you create two issues that describe the flaky tests? |
There was a problem hiding this comment.
Pull request overview
Improves parallel stability of FileSystemWatcher tests (notably MoveTests and EventTests) by addressing MockFileSystem watcher scheduling behavior and aligning test wait timeouts with “expected to fire” vs “expected not to fire” semantics.
Changes:
- Replace the
FileSystemWatcherMockchannel-consumer busy-spin with an asyncWaitToReadAsyncloop to avoid ThreadPool starvation under parallel load. - Update
MoveTests*to useExpectSuccessfor events that must fire (keepingExpectTimeoutfor “should not fire” assertions). - Remove prior
[NotInParallel]workarounds fromMoveTestsandEventTests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.cs | Removes parallel workaround and fixes “must fire” waits to use ExpectSuccess. |
| Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Windows.cs | Adjusts event waits to use success vs timeout depending on expected behavior. |
| Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Unix.cs | Adjusts event waits to use success vs timeout depending on expected behavior. |
| Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs | Removes [NotInParallel] now that underlying causes are addressed. |
| Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherMock.cs | Reworks event loop to avoid CPU spinning and refactors some rename/event arg helpers. |
Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherMock.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
|
This is addressed in release v6.0.0. |

MoveTests(andEventTests) were marked[NotInParallel]as a workaround for flakiness when running againstMockFileSystem. Two distinct bugs caused this:Root Causes & Fixes
1. CPU busy-wait in
FileSystemWatcherMockevent loopThe background task consumed channel items with a tight spin loop, starving the ThreadPool under parallel load:
2. Incorrect timeout for expected-to-fire events in
MoveTestsAll
Wait()calls usedExpectTimeout(30 ms) — including assertions where an event should fire. Consistent withNotifyFiltersTestsandIncludeSubdirectoriesTests, events that must fire useExpectSuccess(30 000 ms); only "should not fire" assertions keepExpectTimeout:Same fix applied in
MoveTests.Unix.csandMoveTests.Windows.cs.3. Removed
[NotInParallel]workaroundsWith the above fixes,
[NotInParallel]is no longer needed onMoveTestsorEventTests.Original prompt
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.