Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip the test when dotnet.exe is locked #66196

Merged
merged 4 commits into from
Apr 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
when dotnet.exe is locked, wait a little bit and try few more times
  • Loading branch information
adamsitnik committed Mar 4, 2022
commit 99f019328a82f8f5e18b68c859fda9d3304de68f
Original file line number Diff line number Diff line change
@@ -490,7 +490,22 @@ public void TestUserCredentialsPropertiesOnWindows()
p.StartInfo.UserName = username;
p.StartInfo.PasswordInClearText = password;

hasStarted = p.Start();
int tryCount = 0;
while (true)
{
try
{
hasStarted = p.Start();
break;
}
catch (Win32Exception ex) when (ex.NativeErrorCode == ERROR_SHARING_VIOLATION && ++tryCount < 10)
{
// for some reason the dotnet.exe is sometimes locked by some other process
// that has opened it for writing with exclusive file access
// https://github.com/dotnet/runtime/issues/65820
Thread.Sleep(TimeSpan.FromMilliseconds(50));
}
}

if (Interop.OpenProcessToken(p.SafeHandle, 0x8u, out handle))
{
@@ -1210,6 +1225,7 @@ public static TheoryData<bool> UseShellExecute
private const int ERROR_SUCCESS = 0x0;
private const int ERROR_FILE_NOT_FOUND = 0x2;
private const int ERROR_BAD_EXE_FORMAT = 0xC1;
private const int ERROR_SHARING_VIOLATION = 0x20;

[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34685", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]