Use powershell sleep in unit tests#6332
Conversation
Fixes #6265 The sleep NuGet package (https://www.nuget.org/packages/sleep) was uploaded to the dotnet-public feed for us by Matt Mitchell. The source is here: https://github.com/KirillOsenkov/Misc/tree/main/Sleep This makes our build less dependent on the machine state. Currently on Windows it may pick up C:\Program Files\Git\usr\bin\sleep.exe if it is installed and on the PATH (this is what happens on CI). But for users that don't have it on the PATH the test fails. Let's make sure our build is hermetic and self-sufficient. Also renaming a method parameter to add clarity.
Forgind
left a comment
There was a problem hiding this comment.
Thanks! I appreciate this.
|
This looks great although I wonder if the extra dependency is worth it if we can simply make the test run |
|
lol NOW you show up! I had no idea this exists: Sigh I'm just too lazy to redo it. Maybe I should. |
|
@ladipro I've switched to |
b9957ef to
0b098be
Compare
|
Unfortunately when I tried to use timeout.exe on CI it failed with exit code 1. I have no idea why :-/ I force pushed my original approach with a custom NuGet package which seems to work both locally and on CI. If anyone wants to investigate the timeout approach, you can use the commit b9957ef |
ladipro
left a comment
There was a problem hiding this comment.
@KirillOsenkov apologies for randomizing you. No idea why timeout wouldn't work in CI and not worth spending time on it for sure. Thank you!
|
No problem at all, I did learn something. I'm guessing |
|
We've solved this in the past with no external dependencies. Let me see how that works and try to use it here. |
|
There it is: msbuild/src/Shared/UnitTests/ObjectModelHelpers.cs Lines 1843 to 1852 in 369631b |
|
Nice, thanks for fixing this for me. |
Fixes #6265
The sleep NuGet package (https://www.nuget.org/packages/sleep) was uploaded to the dotnet-public feed for us by Matt Mitchell.
The source is here: https://github.com/KirillOsenkov/Misc/tree/main/Sleep
This makes our build less dependent on the machine state. Currently on Windows it may pick up C:\Program Files\Git\usr\bin\sleep.exe if it is installed and on the PATH (this is what happens on CI). But for users that don't have it on the PATH the test fails. Let's make sure our build is hermetic and self-sufficient.
Also renaming a method parameter to add clarity.