Skip to content

Commit ee4540b

Browse files
committed
test: fix DownloaderTest to retry tempdir cleanup
1 parent a58864e commit ee4540b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Tests.Vpn.Service/DownloaderTest.cs

+21-2
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,28 @@ public void Setup()
231231
}
232232

233233
[TearDown]
234-
public void TearDown()
234+
public async Task TearDown()
235235
{
236-
Directory.Delete(_tempDir, true);
236+
const int maxAttempts = 10;
237+
for (var attempt = 1; attempt <= maxAttempts; attempt++)
238+
{
239+
try
240+
{
241+
Directory.Delete(_tempDir, true);
242+
return;
243+
}
244+
catch (IOException e)
245+
{
246+
await TestContext.Out.WriteLineAsync(
247+
$"failed to delete temp dir (attempt {attempt} of {maxAttempts}): {e.Message}");
248+
if (attempt == maxAttempts)
249+
{
250+
throw;
251+
}
252+
253+
await Task.Delay(100);
254+
}
255+
}
237256
}
238257

239258
private string _tempDir;

0 commit comments

Comments
 (0)