Skip to content
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
Prev Previous commit
Fix .NET test
Co-Authored-By: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com>
  • Loading branch information
SteveSandersonMS and SteveSandersonMS committed Apr 7, 2026
commit b78db61da0ae5b9562a36441c90e0f8b41e3012c
49 changes: 41 additions & 8 deletions dotnet/test/SessionFsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task Should_Route_File_Operations_Through_The_Session_Fs_Provider()
}
finally
{
TryDeleteDirectory(providerRoot);
await TryDeleteDirectoryAsync(providerRoot);
}
}

Expand Down Expand Up @@ -84,7 +84,7 @@ public async Task Should_Load_Session_Data_From_Fs_Provider_On_Resume()
}
finally
{
TryDeleteDirectory(providerRoot);
await TryDeleteDirectoryAsync(providerRoot);
}
}

Expand Down Expand Up @@ -133,7 +133,7 @@ public async Task Should_Reject_SetProvider_When_Sessions_Already_Exist()
}
finally
{
TryDeleteDirectory(providerRoot);
await TryDeleteDirectoryAsync(providerRoot);
}
}

Expand Down Expand Up @@ -174,10 +174,11 @@ await session.SendAndWaitAsync(new MessageOptions

var fileContent = await ReadAllTextSharedAsync(GetStoredPath(providerRoot, session.SessionId, match.Groups[1].Value));
Assert.Equal(suppliedFileContent, fileContent);
await session.DisposeAsync();
}
finally
{
TryDeleteDirectory(providerRoot);
await TryDeleteDirectoryAsync(providerRoot);
}
}

Expand Down Expand Up @@ -222,7 +223,7 @@ await WaitForConditionAsync(async () =>
}
finally
{
TryDeleteDirectory(providerRoot);
await TryDeleteDirectoryAsync(providerRoot);
}
}

Expand Down Expand Up @@ -310,11 +311,43 @@ private static async Task<string> ReadAllTextSharedAsync(string path, Cancellati
return await reader.ReadToEndAsync(cancellationToken);
}

private static void TryDeleteDirectory(string path)
private static async Task TryDeleteDirectoryAsync(string path)
{
if (Directory.Exists(path))
if (!Directory.Exists(path))
{
return;
}

var deadline = DateTime.UtcNow + TimeSpan.FromSeconds(5);
Exception? lastException = null;

while (DateTime.UtcNow < deadline)
{
try
{
if (!Directory.Exists(path))
{
return;
}

Directory.Delete(path, recursive: true);
return;
}
catch (IOException ex)
{
lastException = ex;
}
catch (UnauthorizedAccessException ex)
{
lastException = ex;
}

await Task.Delay(100);
}

if (lastException is not null)
{
Directory.Delete(path, recursive: true);
throw lastException;
}
}

Expand Down
Loading