|
|
|
@ -30,10 +30,11 @@ using NUnit.Framework;
@@ -30,10 +30,11 @@ using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.Decompiler.Tests |
|
|
|
|
{ |
|
|
|
|
[TestFixture, Parallelizable(ParallelScope.All)] |
|
|
|
|
public class RoundtripAssembly |
|
|
|
|
{ |
|
|
|
|
static readonly string testDir = Path.GetFullPath("../../../../ILSpy-tests"); |
|
|
|
|
static readonly string nunit = Path.Combine(testDir, "nunit", "nunit3-console.exe"); |
|
|
|
|
public static readonly string TestDir = Path.GetFullPath(Path.Combine(DecompilerTestBase.TestCasePath, "../../ILSpy-tests")); |
|
|
|
|
static readonly string nunit = Path.Combine(TestDir, "nunit", "nunit3-console.exe"); |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void Cecil_net45() |
|
|
|
@ -105,26 +106,30 @@ namespace ICSharpCode.Decompiler.Tests
@@ -105,26 +106,30 @@ namespace ICSharpCode.Decompiler.Tests
|
|
|
|
|
|
|
|
|
|
void RunWithTest(string dir, string fileToRoundtrip, string fileToTest) |
|
|
|
|
{ |
|
|
|
|
RunInternal(dir, fileToRoundtrip, () => RunTest(Path.Combine(testDir, dir) + "-output", fileToTest)); |
|
|
|
|
RunInternal(dir, fileToRoundtrip, outputDir => RunTest(outputDir, fileToTest)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RunWithOutput(string dir, string fileToRoundtrip) |
|
|
|
|
{ |
|
|
|
|
string inputDir = Path.Combine(testDir, dir); |
|
|
|
|
string outputDir = inputDir + "-output"; |
|
|
|
|
RunInternal(dir, fileToRoundtrip, () => Tester.RunAndCompareOutput(fileToRoundtrip, Path.Combine(inputDir, fileToRoundtrip), Path.Combine(outputDir, fileToRoundtrip))); |
|
|
|
|
string inputDir = Path.Combine(TestDir, dir); |
|
|
|
|
RunInternal(dir, fileToRoundtrip, |
|
|
|
|
outputDir => Tester.RunAndCompareOutput(fileToRoundtrip, Path.Combine(inputDir, fileToRoundtrip), Path.Combine(outputDir, fileToRoundtrip))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RunInternal(string dir, string fileToRoundtrip, Action testAction) |
|
|
|
|
void RunInternal(string dir, string fileToRoundtrip, Action<string> testAction) |
|
|
|
|
{ |
|
|
|
|
if (!Directory.Exists(testDir)) { |
|
|
|
|
Assert.Ignore($"Assembly-roundtrip test ignored: test directory '{testDir}' needs to be checked out separately." + Environment.NewLine + |
|
|
|
|
$"git clone https://github.com/icsharpcode/ILSpy-tests \"{testDir}\""); |
|
|
|
|
if (!Directory.Exists(TestDir)) { |
|
|
|
|
Assert.Ignore($"Assembly-roundtrip test ignored: test directory '{TestDir}' needs to be checked out separately." + Environment.NewLine + |
|
|
|
|
$"git clone https://github.com/icsharpcode/ILSpy-tests \"{TestDir}\""); |
|
|
|
|
} |
|
|
|
|
string inputDir = Path.Combine(testDir, dir); |
|
|
|
|
//RunTest(inputDir, fileToTest);
|
|
|
|
|
string inputDir = Path.Combine(TestDir, dir); |
|
|
|
|
string decompiledDir = inputDir + "-decompiled"; |
|
|
|
|
string outputDir = inputDir + "-output"; |
|
|
|
|
if (inputDir.EndsWith("TestCases")) { |
|
|
|
|
// make sure output dir names are unique so that we don't get trouble due to parallel test execution
|
|
|
|
|
decompiledDir += Path.GetFileNameWithoutExtension(fileToRoundtrip); |
|
|
|
|
outputDir += Path.GetFileNameWithoutExtension(fileToRoundtrip); |
|
|
|
|
} |
|
|
|
|
ClearDirectory(decompiledDir); |
|
|
|
|
ClearDirectory(outputDir); |
|
|
|
|
string projectFile = null; |
|
|
|
@ -157,7 +162,7 @@ namespace ICSharpCode.Decompiler.Tests
@@ -157,7 +162,7 @@ namespace ICSharpCode.Decompiler.Tests
|
|
|
|
|
Assert.IsNotNull(projectFile, $"Could not find {fileToRoundtrip}"); |
|
|
|
|
|
|
|
|
|
Compile(projectFile, outputDir); |
|
|
|
|
testAction(); |
|
|
|
|
testAction(outputDir); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void ClearDirectory(string dir) |
|
|
|
|