Browse Source

In `PrettyTestRunner`, when a test case fails, prioritize using a folder without a numbered suffix for the output directory.

pull/3598/head
sonyps5201314 5 months ago
parent
commit
5a67d15e0f
  1. 35
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

35
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -878,17 +878,36 @@ namespace ICSharpCode.Decompiler.Tests
string tempDir = Path.Combine(Path.GetTempPath(), "ICSharpCode.Decompiler.Tests", baseTempName); string tempDir = Path.Combine(Path.GetTempPath(), "ICSharpCode.Decompiler.Tests", baseTempName);
if (Directory.Exists(tempDir)) if (Directory.Exists(tempDir))
{ {
int idx = 2; void PrepareNewDirName()
string newDir;
while (true)
{ {
newDir = Path.Combine(Path.GetTempPath(), "ICSharpCode.Decompiler.Tests", baseTempName + " (" + idx + ")"); int idx = 2;
if (!Directory.Exists(newDir)) string newDir;
while (true)
{ {
tempDir = newDir; newDir = Path.Combine(Path.GetTempPath(), "ICSharpCode.Decompiler.Tests", baseTempName + " (" + idx + ")");
break; if (!Directory.Exists(newDir))
{
tempDir = newDir;
break;
}
idx++;
} }
idx++; }
const bool preferOverwrite = true;
if (preferOverwrite)
{
try
{
Tester.RepeatOnIOError(() => Directory.Delete(tempDir, true));
}
catch
{
PrepareNewDirName();
}
}
else
{
PrepareNewDirName();
} }
} }
Directory.CreateDirectory(tempDir); Directory.CreateDirectory(tempDir);

Loading…
Cancel
Save