Browse Source

Try to workaround non-deterministic test failures.

pull/1515/head
Daniel Grunwald 6 years ago
parent
commit
8ff34e5c8b
  1. 14
      ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
  2. 1
      ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
  3. 16
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

14
ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs

@ -329,8 +329,8 @@ namespace ICSharpCode.Decompiler.Tests @@ -329,8 +329,8 @@ namespace ICSharpCode.Decompiler.Tests
Tester.RunAndCompareOutput(testFileName, outputFile.PathToAssembly, decompiledOutputFile.PathToAssembly, decompiledCodeFile);
File.Delete(decompiledCodeFile);
File.Delete(decompiledOutputFile.PathToAssembly);
Tester.RepeatOnIOError(() => File.Delete(decompiledCodeFile));
Tester.RepeatOnIOError(() => File.Delete(decompiledOutputFile.PathToAssembly));
} finally {
if (outputFile != null)
outputFile.TempFiles.Delete();
@ -354,8 +354,8 @@ namespace ICSharpCode.Decompiler.Tests @@ -354,8 +354,8 @@ namespace ICSharpCode.Decompiler.Tests
Tester.RunAndCompareOutput(testFileName, outputFile.PathToAssembly, decompiledOutputFile.PathToAssembly, decompiledCodeFile);
File.Delete(decompiledCodeFile);
File.Delete(decompiledOutputFile.PathToAssembly);
Tester.RepeatOnIOError(() => File.Delete(decompiledCodeFile));
Tester.RepeatOnIOError(() => File.Delete(decompiledOutputFile.PathToAssembly));
} finally {
if (outputFile != null)
outputFile.TempFiles.Delete();
@ -375,9 +375,9 @@ namespace ICSharpCode.Decompiler.Tests @@ -375,9 +375,9 @@ namespace ICSharpCode.Decompiler.Tests
decompiledOutputFile = Tester.CompileCSharp(decompiledCodeFile, options);
Tester.RunAndCompareOutput(testFileName, outputFile, decompiledOutputFile.PathToAssembly, decompiledCodeFile);
File.Delete(decompiledCodeFile);
File.Delete(decompiledOutputFile.PathToAssembly);
Tester.RepeatOnIOError(() => File.Delete(decompiledCodeFile));
Tester.RepeatOnIOError(() => File.Delete(decompiledOutputFile.PathToAssembly));
} finally {
if (decompiledOutputFile != null)
decompiledOutputFile.TempFiles.Delete();

1
ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs

@ -5,6 +5,7 @@ using System.IO; @@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.VisualBasic;

16
ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

@ -518,5 +518,21 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -518,5 +518,21 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
Assert.Fail(b.ToString());
}
}
internal static void RepeatOnIOError(Action action, int numTries = 5)
{
for (int i = 0; i < numTries - 1; i++) {
try {
action();
return;
} catch (IOException) {
} catch (UnauthorizedAccessException) {
// potential virus scanner problem
}
Thread.Sleep(10);
}
// If the last try still fails, don't catch the exception
action();
}
}
}

Loading…
Cancel
Save