Browse Source

Add test configuration for mcs 5.23.0

pull/2546/head
Siegfried Pammer 4 years ago
parent
commit
7b3940a818
  1. 16
      ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
  2. 2
      ICSharpCode.Decompiler.Tests/Helpers/Tester.VB.cs
  3. 21
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  4. 6
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  5. 2
      ILSpy-tests

16
ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs

@ -75,8 +75,10 @@ namespace ICSharpCode.Decompiler.Tests
CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0, CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0,
CompilerOptions.UseRoslynLatest, CompilerOptions.UseRoslynLatest,
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest, CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
CompilerOptions.UseMcs, CompilerOptions.UseMcs2_6_4,
CompilerOptions.Optimize | CompilerOptions.UseMcs CompilerOptions.Optimize | CompilerOptions.UseMcs2_6_4,
CompilerOptions.UseMcs5_23,
CompilerOptions.Optimize | CompilerOptions.UseMcs5_23
}; };
static readonly CompilerOptions[] roslynOnlyOptions = static readonly CompilerOptions[] roslynOnlyOptions =
@ -286,7 +288,7 @@ namespace ICSharpCode.Decompiler.Tests
[Test] [Test]
public void UnsafeCode([ValueSource(nameof(defaultOptions))] CompilerOptions options) public void UnsafeCode([ValueSource(nameof(defaultOptions))] CompilerOptions options)
{ {
if (options.HasFlag(CompilerOptions.UseMcs)) if (options.HasFlag(CompilerOptions.UseMcs2_6_4))
{ {
Assert.Ignore("Decompiler bug with mono!"); Assert.Ignore("Decompiler bug with mono!");
} }
@ -314,7 +316,7 @@ namespace ICSharpCode.Decompiler.Tests
[Test] [Test]
public void YieldReturn([ValueSource(nameof(defaultOptions))] CompilerOptions options) public void YieldReturn([ValueSource(nameof(defaultOptions))] CompilerOptions options)
{ {
if (options.HasFlag(CompilerOptions.UseMcs)) if ((options & CompilerOptions.UseMcsMask) != 0)
{ {
Assert.Ignore("Decompiler bug with mono!"); Assert.Ignore("Decompiler bug with mono!");
} }
@ -348,7 +350,7 @@ namespace ICSharpCode.Decompiler.Tests
[Test] [Test]
public void MiniJSON([ValueSource(nameof(defaultOptions))] CompilerOptions options) public void MiniJSON([ValueSource(nameof(defaultOptions))] CompilerOptions options)
{ {
if (options.HasFlag(CompilerOptions.UseMcs)) if (options.HasFlag(CompilerOptions.UseMcs2_6_4))
{ {
Assert.Ignore("Decompiler bug with mono!"); Assert.Ignore("Decompiler bug with mono!");
} }
@ -366,12 +368,12 @@ namespace ICSharpCode.Decompiler.Tests
outputFile = Tester.CompileCSharp(Path.Combine(TestCasePath, testFileName), options, outputFile = Tester.CompileCSharp(Path.Combine(TestCasePath, testFileName), options,
outputFileName: Path.Combine(TestCasePath, testOutputFileName)); outputFileName: Path.Combine(TestCasePath, testOutputFileName));
string decompiledCodeFile = Tester.DecompileCSharp(outputFile.PathToAssembly, Tester.GetSettings(options)); string decompiledCodeFile = Tester.DecompileCSharp(outputFile.PathToAssembly, Tester.GetSettings(options));
if (options.HasFlag(CompilerOptions.UseMcs)) if ((options & CompilerOptions.UseMcsMask) != 0)
{ {
// For second pass, use roslyn instead of mcs. // For second pass, use roslyn instead of mcs.
// mcs has some compiler bugs that cause it to not accept ILSpy-generated code, // mcs has some compiler bugs that cause it to not accept ILSpy-generated code,
// for example when there's unreachable code due to other compiler bugs in the first mcs run. // for example when there's unreachable code due to other compiler bugs in the first mcs run.
options &= ~CompilerOptions.UseMcs; options &= ~CompilerOptions.UseMcsMask;
options |= CompilerOptions.UseRoslynLatest; options |= CompilerOptions.UseRoslynLatest;
// Also, add an .exe.config so that we consistently use the .NET 4.x runtime. // Also, add an .exe.config so that we consistently use the .NET 4.x runtime.
File.WriteAllText(outputFile.PathToAssembly + ".config", @"<?xml version=""1.0"" encoding=""utf-8""?> File.WriteAllText(outputFile.PathToAssembly + ".config", @"<?xml version=""1.0"" encoding=""utf-8""?>

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

@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
var preprocessorSymbols = GetPreprocessorSymbols(flags).Select(symbol => new KeyValuePair<string, object>(symbol, 1)).ToList(); var preprocessorSymbols = GetPreprocessorSymbols(flags).Select(symbol => new KeyValuePair<string, object>(symbol, 1)).ToList();
if (!flags.HasFlag(CompilerOptions.UseMcs)) if ((flags & CompilerOptions.UseMcsMask) == 0)
{ {
CompilerResults results = new CompilerResults(new TempFileCollection()); CompilerResults results = new CompilerResults(new TempFileCollection());
results.PathToAssembly = outputFileName ?? Path.GetTempFileName(); results.PathToAssembly = outputFileName ?? Path.GetTempFileName();

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

@ -55,7 +55,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
Force32Bit = 0x4, Force32Bit = 0x4,
Library = 0x8, Library = 0x8,
UseRoslyn1_3_2 = 0x10, UseRoslyn1_3_2 = 0x10,
UseMcs = 0x20, UseMcs2_6_4 = 0x20,
ReferenceVisualBasic = 0x40, ReferenceVisualBasic = 0x40,
ReferenceCore = 0x80, ReferenceCore = 0x80,
GeneratePdb = 0x100, GeneratePdb = 0x100,
@ -63,6 +63,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
UseRoslyn2_10_0 = 0x400, UseRoslyn2_10_0 = 0x400,
UseRoslyn3_11_0 = 0x800, UseRoslyn3_11_0 = 0x800,
UseRoslynLatest = 0x1000, UseRoslynLatest = 0x1000,
UseMcs5_23 = 0x2000,
UseMcsMask = UseMcs2_6_4 | UseMcs5_23,
UseRoslynMask = UseRoslyn1_3_2 | UseRoslyn2_10_0 | UseRoslyn3_11_0 | UseRoslynLatest UseRoslynMask = UseRoslyn1_3_2 | UseRoslyn2_10_0 | UseRoslyn3_11_0 | UseRoslynLatest
} }
@ -335,7 +337,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
} }
} }
} }
else if (flags.HasFlag(CompilerOptions.UseMcs)) else if ((flags & CompilerOptions.UseMcsMask) != 0)
{ {
preprocessorSymbols.Add("MCS"); preprocessorSymbols.Add("MCS");
} }
@ -361,7 +363,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
var preprocessorSymbols = GetPreprocessorSymbols(flags); var preprocessorSymbols = GetPreprocessorSymbols(flags);
if (!flags.HasFlag(CompilerOptions.UseMcs)) if ((flags & CompilerOptions.UseMcsMask) == 0)
{ {
CompilerResults results = new CompilerResults(new TempFileCollection()); CompilerResults results = new CompilerResults(new TempFileCollection());
results.PathToAssembly = outputFileName ?? Path.GetTempFileName(); results.PathToAssembly = outputFileName ?? Path.GetTempFileName();
@ -476,7 +478,10 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
Assert.Ignore($"Compilation with mcs ignored: test directory '{testBasePath}' needs to be checked out separately." + Environment.NewLine + Assert.Ignore($"Compilation with mcs ignored: test directory '{testBasePath}' needs to be checked out separately." + Environment.NewLine +
$"git clone https://github.com/icsharpcode/ILSpy-tests \"{testBasePath}\""); $"git clone https://github.com/icsharpcode/ILSpy-tests \"{testBasePath}\"");
} }
string mcsPath = Path.Combine(testBasePath, @"mcs\2.6.4\bin\gmcs.bat"); string mcsPath = (flags & CompilerOptions.UseMcsMask) switch {
CompilerOptions.UseMcs5_23 => Path.Combine(testBasePath, @"mcs\5.23\bin\mcs.bat"),
_ => Path.Combine(testBasePath, @"mcs\2.6.4\bin\gmcs.bat")
};
string otherOptions = " -unsafe -o" + (flags.HasFlag(CompilerOptions.Optimize) ? "+ " : "- "); string otherOptions = " -unsafe -o" + (flags.HasFlag(CompilerOptions.Optimize) ? "+ " : "- ");
if (flags.HasFlag(CompilerOptions.Library)) if (flags.HasFlag(CompilerOptions.Library))
@ -544,7 +549,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
else else
{ {
var settings = new DecompilerSettings(CSharp.LanguageVersion.CSharp5); var settings = new DecompilerSettings(CSharp.LanguageVersion.CSharp5);
if (cscOptions.HasFlag(CompilerOptions.UseMcs)) if ((cscOptions & CompilerOptions.UseMcsMask) != 0)
{ {
// we don't recompile with mcs but with roslyn, so we can use ref locals // we don't recompile with mcs but with roslyn, so we can use ref locals
settings.UseRefLocalsForAccurateOrderOfEvaluation = true; settings.UseRefLocalsForAccurateOrderOfEvaluation = true;
@ -609,8 +614,10 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
suffix += ".roslyn3"; suffix += ".roslyn3";
if ((cscOptions & CompilerOptions.UseRoslynLatest) != 0) if ((cscOptions & CompilerOptions.UseRoslynLatest) != 0)
suffix += ".roslyn"; suffix += ".roslyn";
if ((cscOptions & CompilerOptions.UseMcs) != 0) if ((cscOptions & CompilerOptions.UseMcs2_6_4) != 0)
suffix += ".mcs"; suffix += ".mcs2";
if ((cscOptions & CompilerOptions.UseMcs5_23) != 0)
suffix += ".mcs5";
return suffix; return suffix;
} }

6
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -127,8 +127,10 @@ namespace ICSharpCode.Decompiler.Tests
CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0, CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0,
CompilerOptions.UseRoslynLatest, CompilerOptions.UseRoslynLatest,
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest, CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
CompilerOptions.UseMcs, CompilerOptions.UseMcs2_6_4,
CompilerOptions.Optimize | CompilerOptions.UseMcs CompilerOptions.Optimize | CompilerOptions.UseMcs2_6_4,
CompilerOptions.UseMcs5_23,
CompilerOptions.Optimize | CompilerOptions.UseMcs5_23
}; };
[Test] [Test]

2
ILSpy-tests

@ -1 +1 @@
Subproject commit aa8f1197e6a513bcc10bcc38ec7d2143d27a2246 Subproject commit 6f8860e420b54bdfd726ec3c58a4d178416f9156
Loading…
Cancel
Save