Skip to content

Fix flaky Kill_Test on macOS by waiting for process exit before asserting#117

Merged
Tyrrrz merged 5 commits intoprimefrom
copilot/fix-flaky-test-on-macos
Apr 17, 2026
Merged

Fix flaky Kill_Test on macOS by waiting for process exit before asserting#117
Tyrrrz merged 5 commits intoprimefrom
copilot/fix-flaky-test-on-macos

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

ProcessTests.Kill_Test was intermittently failing on macOS because Process.Kill() sends SIGKILL and returns before the OS reaps the process — making HasExited transiently false.

Change

Added process.WaitForExit() between the Kill(true) call and the HasExited assertion, ensuring the process is fully terminated before the check:

// Act
process.Kill(true);
process.WaitForExit(); // ← added

// Assert
process.HasExited.Should().BeTrue();

@Tyrrrz Tyrrrz added the bug Something isn't working label Apr 17, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 17, 2026 09:55
Copilot AI review requested due to automatic review settings April 17, 2026 09:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an intermittent macOS test failure in ProcessTests.Kill_Test by ensuring the killed process has fully exited before asserting HasExited, aligning the test with how Process.Kill() can return before the OS reaps the process.

Changes:

  • Added process.WaitForExit() after process.Kill(true) in Kill_Test to reduce flakiness on macOS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PolyShim.Tests/NetCore30/ProcessTests.cs Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.82%. Comparing base (0cd6e1d) to head (ba9b6ec).
⚠️ Report is 1 commits behind head on prime.

Additional details and impacted files
@@            Coverage Diff             @@
##            prime     #117      +/-   ##
==========================================
+ Coverage   90.77%   90.82%   +0.04%     
==========================================
  Files         284      284              
  Lines        4934     4935       +1     
  Branches      404      404              
==========================================
+ Hits         4479     4482       +3     
+ Misses        365      363       -2     
  Partials       90       90              

☔ View full report in Codecov by Sentry.
📢 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.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 17, 2026

@copilot build/test failing

…(TimeSpan) (net6.0 compat)

Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/80c57795-1f5b-4b25-a4db-1c8fd7a3cff2

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 17, 2026

@copilot build/test failing

Fixed in 3b8c712. The WaitForExit(TimeSpan) overload is only available on .NET 7+, which caused the build failure on net6.0. Switched to WaitForExit(int milliseconds) which is available on all target frameworks.

Copilot AI requested a review from Tyrrrz April 17, 2026 10:11
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 17, 2026

@copilot I've added the TimeSpan polyfill in the latest prime. Please update and revert last change. Also update the test's arrange phase so that it's consistent with the other similar tests, such as those added in the last commit to prime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants