Skip to content

Commit

Permalink
Working on #831:
Browse files Browse the repository at this point in the history
Update ICSharpCode.Decompiler.Tests.csproj to new project format.
Seems like we cannot make the tests work with .NET Standard/.NET Core because we have some special cases:
- tests for UndocumentedExpressions depend on the full framework
- the .NET Core Test Runner wants to inject a custom main method and implicitly turns the project into a console app (tooling bug?),
  which in turn fails to compile because we use a lot of Main methods in our test cases which get compiled during tests.
- Needed to update all the Nuget packages: most notably DiffLib
  • Loading branch information
siegfriedpammer committed Aug 30, 2017
1 parent 3a38646 commit d986bdc
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 210 deletions.
2 changes: 1 addition & 1 deletion ICSharpCode.Decompiler/Tests/CorrectnessTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace ICSharpCode.Decompiler.Tests
[TestFixture]
public class CorrectnessTestRunner
{
const string TestCasePath = @"../../Tests/TestCases/Correctness";
const string TestCasePath = @"../../../../TestCases/Correctness";

[Test]
public void AllFilesHaveTests()
Expand Down
39 changes: 19 additions & 20 deletions ICSharpCode.Decompiler/Tests/Helpers/CodeAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,43 @@ public static class CodeComparer
{
public static bool Compare(string input1, string input2, StringWriter diff, Func<string, string> normalizeLine)
{
var differ = new AlignedDiff<string>(
NormalizeAndSplitCode(input1),
NormalizeAndSplitCode(input2),
new CodeLineEqualityComparer(normalizeLine),
new StringSimilarityComparer(),
new StringAlignmentFilter());
var a = NormalizeAndSplitCode(input1);
var b = NormalizeAndSplitCode(input2);
var sections = Diff.CalculateSections(a, b, new CodeLineEqualityComparer(normalizeLine));
var elements = Diff.AlignElements(a, b, sections, new StringSimilarityDiffElementAligner());

bool result = true, ignoreChange;

int line1 = 0, line2 = 0;

foreach (var change in differ.Generate()) {
switch (change.Change) {
case ChangeType.Same:
foreach (var element in elements) {
switch (element.Operation) {
case DiffOperation.Match:
diff.Write("{0,4} {1,4} ", ++line1, ++line2);
diff.Write(" ");
diff.WriteLine(change.Element1);
diff.WriteLine(element.ElementFromCollection1.Value);
break;
case ChangeType.Added:
case DiffOperation.Insert:
diff.Write(" {1,4} ", line1, ++line2);
result &= ignoreChange = ShouldIgnoreChange(change.Element2);
result &= ignoreChange = ShouldIgnoreChange(element.ElementFromCollection2.Value);
diff.Write(ignoreChange ? " " : " + ");
diff.WriteLine(change.Element2);
diff.WriteLine(element.ElementFromCollection2.Value);
break;
case ChangeType.Deleted:
case DiffOperation.Delete:
diff.Write("{0,4} ", ++line1, line2);
result &= ignoreChange = ShouldIgnoreChange(change.Element1);
result &= ignoreChange = ShouldIgnoreChange(element.ElementFromCollection1.Value);
diff.Write(ignoreChange ? " " : " - ");
diff.WriteLine(change.Element1);
diff.WriteLine(element.ElementFromCollection1.Value);
break;
case ChangeType.Changed:
case DiffOperation.Replace:
case DiffOperation.Modify:
diff.Write("{0,4} ", ++line1, line2);
result = false;
diff.Write("(-) ");
diff.WriteLine(change.Element1);
diff.WriteLine(element.ElementFromCollection1.Value);
diff.Write(" {1,4} ", line1, ++line2);
diff.Write("(+) ");
diff.WriteLine(change.Element2);
diff.WriteLine(element.ElementFromCollection2.Value);
break;
}
}
Expand Down Expand Up @@ -114,7 +113,7 @@ private static bool ShouldIgnoreChange(string line)
return NormalizeLine(line) == string.Empty;
}

private static IEnumerable<string> NormalizeAndSplitCode(string input)
private static IList<string> NormalizeAndSplitCode(string input)
{
return input.Split(new[] { "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
}
Expand Down
264 changes: 92 additions & 172 deletions ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,189 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Decompiler.Tests</RootNamespace>
<AssemblyName>ICSharpCode.Decompiler.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<NoWarn>67,169,1058,728,1720,649</NoWarn>
<TargetFrameworkProfile />
<NoWin32Manifest>False</NoWin32Manifest>
<SignAssembly>True</SignAssembly>
<TargetFramework>net461</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<OutputType>Library</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\bin\Release\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>bin\Debug\net461\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="DiffLib">
<HintPath>..\..\packages\DiffLib.1.0.0.55\lib\net35-Client\DiffLib.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="nunit.core, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.core.interfaces, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="nunit.util, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NUnit.VisualStudio.TestAdapter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Collections.Immutable.1.3.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Reflection.Metadata, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Reflection.Metadata.1.2.0\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="TestCases\Correctness\BitNot.il" />
<None Include="TestCases\Correctness\Readme.txt" />
<Compile Remove="CustomAttributes\**" />
<Compile Remove="FSharpPatterns\**" />
<Compile Remove="IL\**" />
<Compile Remove="Types\**" />
<EmbeddedResource Remove="CustomAttributes\**" />
<EmbeddedResource Remove="FSharpPatterns\**" />
<EmbeddedResource Remove="IL\**" />
<EmbeddedResource Remove="Types\**" />
<None Remove="CustomAttributes\**" />
<None Remove="FSharpPatterns\**" />
<None Remove="IL\**" />
<None Remove="Types\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\cecil\Mono.Cecil.csproj">
<Project>{d68133bd-1e63-496e-9ede-4fbdbf77b486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\ICSharpCode.Decompiler.csproj">
<Project>{984cc812-9470-4a13-aff9-cc44068d666c}</Project>
<Name>ICSharpCode.Decompiler</Name>
</ProjectReference>
<Compile Remove="CheckedUnchecked.cs" />
<Compile Remove="CustomAttributes.code.cs" />
<Compile Remove="CustomShortCircuitOperators.cs" />
<Compile Remove="DelegateConstruction.cs" />
<Compile Remove="DoubleConstants.cs" />
<Compile Remove="ExceptionHandling.cs" />
<Compile Remove="ExpressionTrees.cs" />
<Compile Remove="Generics.cs" />
<Compile Remove="IncrementDecrement.cs" />
<Compile Remove="Lock.cs" />
<Compile Remove="MultidimensionalArray.cs" />
<Compile Remove="NotUsingBlock.cs" />
<Compile Remove="PInvoke.cs" />
<Compile Remove="PropertiesAndEvents.cs" />
<Compile Remove="QueryExpressions.cs" />
<Compile Remove="Switch.cs" />
<Compile Remove="TestCases\Pretty\LiftedOperators.cs" />
<Compile Remove="TypeAnalysisTests.cs" />
<Compile Remove="ValueTypes.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Helpers\CodeAssert.cs" />
<Compile Include="Helpers\SdkUtility.cs" />
<Compile Include="Helpers\RemoveCompilerAttribute.cs" />
<Compile Include="Helpers\Tester.cs" />
<Compile Include="Helpers\TypeSystemHelper.cs" />
<Compile Include="TestCases\Pretty\LiftedOperators.cs" />
<Compile Include="PrettyTestRunner.cs" />
<Compile Include="RoundtripAssembly.cs" />
<Compile Include="TestCases\Correctness\Capturing.cs" />
<Compile Include="TestCases\Correctness\OverloadResolution.cs" />
<Compile Include="TestCases\Pretty\AnonymousTypes.cs" />
<Compile Include="TestCases\Pretty\Async.cs" />
<Compile Include="TestCases\Correctness\CompoundAssignment.cs" />
<Compile Include="TestCases\Correctness\ConditionalAttr.cs" />
<Compile Include="TestCases\Correctness\ControlFlow.cs" />
<Compile Include="TestCases\Correctness\Conversions.cs" />
<Compile Include="TestCases\Correctness\DecimalFields.cs" />
<Compile Include="TestCases\Correctness\Comparisons.cs" />
<Compile Include="TestCases\Correctness\Generics.cs" />
<Compile Include="TestCases\Correctness\HelloWorld.cs" />
<Compile Include="TestCases\Correctness\InitializerTests.cs" />
<Compile Include="TestCases\Correctness\MemberLookup.cs" />
<Compile Include="TestCases\Correctness\PropertiesAndEvents.cs" />
<Compile Include="TestCases\Correctness\Switch.cs" />
<Compile Include="TestCases\Correctness\UndocumentedExpressions.cs" />
<Compile Include="TestCases\Correctness\UnsafeCode.cs" />
<Compile Include="TestCases\Correctness\ValueTypeCall.cs" />
<Compile Include="CorrectnessTestRunner.cs" />
<Compile Include="TestCases\Pretty\AutoProperties.cs" />
<Compile Include="TestCases\Pretty\Loops.cs" />
<Compile Include="TestCases\Correctness\YieldReturn.cs" />
<Compile Include="TestCases\Pretty\CompoundAssignmentTest.cs" />
<Compile Include="TestCases\Pretty\ExceptionHandling.cs" />
<Compile Include="TestCases\Pretty\HelloWorld.cs" />
<Compile Include="TestCases\Pretty\InlineAssignmentTest.cs" />
<Compile Include="TestCases\Pretty\PropertiesAndEvents.cs" />
<Compile Include="TestCases\Pretty\ShortCircuit.cs" />
<Compile Include="TestTraceListener.cs" />
<Compile Include="Util\IntervalTests.cs" />
<Compile Include="Util\LongSetTests.cs" />
<Compile Include="CustomAttributes\CustomAttributeTests.cs" />
<Compile Include="CustomAttributes\S_AssemblyCustomAttribute.cs" />
<Compile Include="CustomAttributes\S_CustomAttributeSamples.cs" />
<Compile Include="CustomAttributes\S_CustomAttributes.cs" />
<Compile Include="DecompilerTestBase.cs" />
<Compile Include="CodeSampleFileParser.cs" />
<None Remove="BooleanConsumedAsInteger.il" />
<None Remove="TestCases\Pretty\AnonymousTypes.il" />
<None Remove="TestCases\Pretty\AnonymousTypes.opt.il" />
<None Remove="TestCases\Pretty\AnonymousTypes.opt.res" />
<None Remove="TestCases\Pretty\AnonymousTypes.res" />
<None Remove="TestCases\Pretty\AutoProperties.opt.roslyn.il" />
<None Remove="TestCases\Pretty\AutoProperties.roslyn.il" />
<None Remove="TestCases\Pretty\CompoundAssignmentTest.il" />
<None Remove="TestCases\Pretty\CompoundAssignmentTest.opt.il" />
<None Remove="TestCases\Pretty\CompoundAssignmentTest.opt.res" />
<None Remove="TestCases\Pretty\CompoundAssignmentTest.opt.roslyn.il" />
<None Remove="TestCases\Pretty\CompoundAssignmentTest.res" />
<None Remove="TestCases\Pretty\CompoundAssignmentTest.roslyn.il" />
<None Remove="TestCases\Pretty\ExceptionHandling.il" />
<None Remove="TestCases\Pretty\ExceptionHandling.opt.il" />
<None Remove="TestCases\Pretty\ExceptionHandling.opt.res" />
<None Remove="TestCases\Pretty\ExceptionHandling.res" />
<None Remove="TestCases\Pretty\HelloWorld.il" />
<None Remove="TestCases\Pretty\HelloWorld.res" />
<None Remove="TestCases\Pretty\InlineAssignmentTest.il" />
<None Remove="TestCases\Pretty\InlineAssignmentTest.opt.il" />
<None Remove="TestCases\Pretty\InlineAssignmentTest.opt.res" />
<None Remove="TestCases\Pretty\InlineAssignmentTest.res" />
<None Remove="TestCases\Pretty\LiftedOperators.il" />
<None Remove="TestCases\Pretty\LiftedOperators.opt.il" />
<None Remove="TestCases\Pretty\LiftedOperators.opt.res" />
<None Remove="TestCases\Pretty\LiftedOperators.opt.roslyn.il" />
<None Remove="TestCases\Pretty\LiftedOperators.res" />
<None Remove="TestCases\Pretty\LiftedOperators.roslyn.il" />
<None Remove="TestCases\Pretty\PropertiesAndEvents.il" />
<None Remove="TestCases\Pretty\PropertiesAndEvents.opt.il" />
<None Remove="TestCases\Pretty\PropertiesAndEvents.opt.res" />
<None Remove="TestCases\Pretty\PropertiesAndEvents.opt.roslyn.il" />
<None Remove="TestCases\Pretty\PropertiesAndEvents.res" />
<None Remove="TestCases\Pretty\PropertiesAndEvents.roslyn.il" />
<None Remove="TestCases\Pretty\ShortCircuit.il" />
<None Remove="TestCases\Pretty\ShortCircuit.opt.il" />
<None Remove="TestCases\Pretty\ShortCircuit.opt.res" />
<None Remove="TestCases\Pretty\ShortCircuit.opt.roslyn.il" />
<None Remove="TestCases\Pretty\ShortCircuit.res" />
<None Remove="TestCases\Pretty\ShortCircuit.roslyn.il" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<PackageReference Include="difflib" Version="2017.7.26.1241" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.3.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.4.0" />
<PackageReference Include="System.CodeDom" Version="4.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="coveralls.net" Version="0.7.0" />
<PackageReference Include="nunit" Version="3.7.1" />
<PackageReference Include="nunit.console" Version="3.7.0" />
<PackageReference Include="NUnit.Runners" Version="3.7.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
</ItemGroup>
<ItemGroup>
<None Include="TestCases\Pretty\CompoundAssignmentTest.il">
<DependentUpon>CompoundAssignmentTest.cs</DependentUpon>
</None>
<None Include="TestCases\Pretty\HelloWorld.il">
<DependentUpon>HelloWorld.cs</DependentUpon>
</None>
<None Include="TestCases\Pretty\InlineAssignmentTest.il">
<DependentUpon>InlineAssignmentTest.cs</DependentUpon>
</None>
<None Include="TestCases\Pretty\Readme.txt" />
<ProjectReference Include="..\ICSharpCode.Decompiler.csproj" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>
3 changes: 2 additions & 1 deletion ICSharpCode.Decompiler/Tests/PrettyTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

namespace ICSharpCode.Decompiler.Tests
{
[TestFixture]
public class PrettyTestRunner
{
const string TestCasePath = @"../../Tests/TestCases/Pretty";
const string TestCasePath = @"../../../../TestCases/Pretty";

[Test]
public void AllFilesHaveTests()
Expand Down
2 changes: 1 addition & 1 deletion ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.Tests
{
public class RoundtripAssembly
{
static readonly string testDir = Path.GetFullPath("../../../ILSpy-tests");
static readonly string testDir = Path.GetFullPath("../../../../../../ILSpy-tests");
static readonly string nunit = Path.Combine(testDir, "nunit", "nunit3-console.exe");

[Test]
Expand Down
Loading

0 comments on commit d986bdc

Please sign in to comment.