Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/AccessTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be possible to avoid these boilerplate .ilproj files by writing msbuild traversal rule. I have opted for the boilerplate files since there is not that many of them and they are much easier to understand than msbuild traversal rules.

</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/AccessTestsExtern.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/AccessTestsFriend.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/ArrayTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/BasicArithmeticTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/BranchingTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/CallTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/CastingTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/ComparisonTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/DelegateTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/ExceptionRegionTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/FieldTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/FtnTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
17 changes: 17 additions & 0 deletions src/ILVerification/tests/ILTests/ILTests.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />

<PropertyGroup>
<OutputType>Library</OutputType>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<OutputPath>$(BaseOutputPath)$(OSPlatformConfig)/ILVerification.Tests/Tests</OutputPath>
<SkipTestRun>true</SkipTestRun>
<SkipSigning>true</SkipSigning>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(MSBuildProjectName).il" />
</ItemGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/NewobjTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/PrefixTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/ReturnTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/ShiftTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/ThisStateTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
3 changes: 3 additions & 0 deletions src/ILVerification/tests/ILTests/ValueTypeTests.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="ILTests.targets" />
</Project>
7 changes: 7 additions & 0 deletions src/ILVerification/tests/ILVerification.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
<ProjectReference Include="..\src\ILVerification.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="ILTests\*.ilproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>Content</OutputItemType>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
Expand Down
18 changes: 8 additions & 10 deletions src/ILVerification/tests/TestDataLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ namespace ILVerification.Tests
{
/// <summary>
/// Parses the methods in the test assemblies.
/// It loads all assemblies from the test folder defined in <code>TestDataLoader.TESTASSEMBLYPATH</code>
/// It loads all assemblies from the test folder defined in <code>TestDataLoader.TestAssemblyPath</code>
/// This class feeds the xunit Theories
/// </summary>
class TestDataLoader
{
/// <summary>
/// The folder with the binaries which are compiled from the test driver IL Code
/// Currently the test .il code is built manually, but the plan is to have a ProjectReference and automatically build the .il files.
/// See: https://github.com/dotnet/corert/pull/3725#discussion_r118820770
/// The folder with the test binaries
/// </summary>
public static string TESTASSEMBLYPATH = @"..\..\..\ILTests\";
private const string TestAssemblyPath = @"Tests\";

private const string SPECIALTEST_PREFIX = "special.";
private const string SpecialTestPrefix = "special.";

/// <summary>
/// Returns all methods that contain valid IL code based on the following naming convention:
Expand Down Expand Up @@ -129,11 +127,11 @@ private static TheoryData<TestCase> GetTestMethodsFromDll(Func<string[], MethodD

private static MethodDefinitionHandle HandleSpecialTests(string[] methodParams, EcmaMethod method)
{
if (!methodParams[0].StartsWith(SPECIALTEST_PREFIX))
if (!methodParams[0].StartsWith(SpecialTestPrefix))
return method.Handle;

// Cut off special prefix
var specialParams = methodParams[0].Substring(SPECIALTEST_PREFIX.Length);
var specialParams = methodParams[0].Substring(SpecialTestPrefix.Length);

// Get friendly name / special name
int delimiter = specialParams.IndexOf('.');
Expand All @@ -152,7 +150,7 @@ private static MethodDefinitionHandle HandleSpecialTests(string[] methodParams,

private static IEnumerable<string> GetAllTestDlls()
{
foreach (var item in Directory.GetFiles(TESTASSEMBLYPATH))
foreach (var item in Directory.GetFiles(TestAssemblyPath))
{
if (item.ToLower().EndsWith(".dll"))
{
Expand All @@ -167,7 +165,7 @@ public static EcmaModule GetModuleForTestAssembly(string assemblyName)

foreach (var fileName in GetAllTestDlls())
{
simpleNameToPathMap.Add(Path.GetFileNameWithoutExtension(fileName), TESTASSEMBLYPATH + fileName);
simpleNameToPathMap.Add(Path.GetFileNameWithoutExtension(fileName), TestAssemblyPath + fileName);
}

Assembly coreAssembly = typeof(object).GetTypeInfo().Assembly;
Expand Down
12 changes: 0 additions & 12 deletions src/ILVerify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ The code is split into three projects:

To test the ILVerification library we have small methods checked in as .il files testing specific verification scenarios. These tests live under [src/ILVerification/tests/ILTests](../ILVerification/tests/ILTests). Tests are grouped into .il files based on functionalities they test. There is no strict policy here, the goal is to have a few dozen .il files instead of thousands containing each only a single method.

Currently the IL files are NOT compiled automatically. You have to compile manually (We want to automate this step later):

```
ilasm [filename.il] /dll /ERROR
```

Note: if you run the tests and get an error similar to this then it means that the .il files were not compiled, or none of them contained methods that follow the naming convention described below:

```
Result Message: System.InvalidOperationException : No data found for ILVerify.Tests.ILMethodTester.TestMethodsWithInvalidIL
```

The test project itself is under [src/ILVerification/tests](../ILVerification/tests)

Method names in the .il files must follow the following naming convention:
Expand Down
6 changes: 2 additions & 4 deletions src/dirs.proj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
<Import Project="dir.props" />

<ItemGroup>
<!-- This project requires ILASM and we have access to that only on Windows -->
<!-- These projects requires ILASM and we have access to that only on Windows -->
<ExcludeProjects Condition="'$(OSEnvironment)'!='Windows_NT'" Include="**\TypeSystem.Tests.csproj" />
<ExcludeProjects Condition="'$(OSEnvironment)'!='Windows_NT'" Include="**\ILCompiler.MetadataTransform.Tests.csproj" />

<!-- This project required manual build step -->
<ExcludeProjects Include="**\ILVerification.Tests.csproj" />
<ExcludeProjects Condition="'$(OSEnvironment)'!='Windows_NT'" Include="**\ILVerification.Tests.csproj" />

<Project Include="AotPackageReference\AotPackageReference.depproj" />

Expand Down