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 2 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 @@ -878,17 +878,36 @@ namespace ICSharpCode.Decompiler.Tests
string tempDir = Path.Combine(Path.GetTempPath(), "ICSharpCode.Decompiler.Tests", baseTempName);
if (Directory.Exists(tempDir))
{
int idx = 2;
string newDir;
while (true)
void PrepareNewDirName()
{
newDir = Path.Combine(Path.GetTempPath(), "ICSharpCode.Decompiler.Tests", baseTempName + " (" + idx + ")");
if (!Directory.Exists(newDir))
int idx = 2;
string newDir;
while (true)
{
tempDir = newDir;
break;
newDir = Path.Combine(Path.GetTempPath(), "ICSharpCode.Decompiler.Tests", baseTempName + " (" + idx + ")");
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);

Loading…
Cancel
Save