Skip to content

Commit

Permalink
WASM: Enable System.Reflection tests (dotnet#39696)
Browse files Browse the repository at this point in the history
Disable tests that won't work on browser.
  • Loading branch information
akoeplinger authored Jul 21, 2020
1 parent b11aea3 commit f501577
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,19 @@
<ExtraAssemblies Include="$(PublishDir)System.Xml.dll" />
<ExtraAssemblies Include="$(PublishDir)WindowsBase.dll" />
</ItemGroup>
<!-- these tests load assemblies from the file system -->
<ItemGroup Condition="'$(AssemblyName)' == 'System.Reflection.MetadataLoadContext.Tests'">
<WasmFilesToIncludeInFileSystem Include="$(PublishDir)System.Private.CoreLib.dll" />
<WasmFilesToIncludeInFileSystem Include="$(PublishDir)System.Reflection.MetadataLoadContext.Tests.dll" />
<WasmFilesToIncludeInFileSystem Include="$(PublishDir)mscorlib.dll" />
</ItemGroup>
<ItemGroup Condition="'$(AssemblyName)' == 'System.Reflection.Metadata.Tests'">
<WasmFilesToIncludeInFileSystem Include="$(PublishDir)System.Reflection.Metadata.Tests.dll" />
</ItemGroup>
<ItemGroup Condition="'$(AssemblyName)' == 'System.Reflection.Tests'">
<WasmFilesToIncludeInFileSystem Include="$(PublishDir)System.Reflection.Tests.dll" />
<WasmFilesToIncludeInFileSystem Include="$(PublishDir)System.Reflection.Tests.pdb" />
</ItemGroup>
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)')" Text="MicrosoftNetCoreAppRuntimePackRidDir=$(MicrosoftNetCoreAppRuntimePackRidDir) doesn't exist" />
<WasmAppBuilder
AppDir="$(BundleDir)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public void BasicValidation(Machine machine)
}

[Fact]
[PlatformSpecific(~TestPlatforms.Browser)] // System.Security.Cryptography isn't supported on browser
public void BasicValidationSigned()
{
using (var peStream = new MemoryStream())
Expand Down Expand Up @@ -654,13 +655,15 @@ private static IEnumerable<string> GetBlobRanges(BlobBuilder builder, IEnumerabl
}

[Fact]
[PlatformSpecific(~TestPlatforms.Browser)] // System.Security.Cryptography isn't supported on browser
public void Checksum()
{
Assert.True(TestChecksumAndAuthenticodeSignature(new MemoryStream(Misc.Signed), Misc.KeyPair));
Assert.False(TestChecksumAndAuthenticodeSignature(new MemoryStream(Misc.Deterministic)));
}

[Fact]
[PlatformSpecific(~TestPlatforms.Browser)] // System.Security.Cryptography isn't supported on browser
public void ChecksumFXAssemblies()
{
var paths = new[]
Expand Down
7 changes: 5 additions & 2 deletions src/libraries/System.Reflection/tests/AssemblyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public void ExportedTypes(Type type, bool expected)
}

[Fact]
[PlatformSpecific(~TestPlatforms.Browser)] // entry assembly won't be xunit.console on browser
public void GetEntryAssembly()
{
Assert.NotNull(Assembly.GetEntryAssembly());
Expand All @@ -157,15 +158,17 @@ public void GetFile()
AssertExtensions.Throws<ArgumentException>(null, () => typeof(AssemblyTests).Assembly.GetFile(""));
Assert.Null(typeof(AssemblyTests).Assembly.GetFile("NonExistentfile.dll"));
Assert.NotNull(typeof(AssemblyTests).Assembly.GetFile("System.Reflection.Tests.dll"));
Assert.Equal(typeof(AssemblyTests).Assembly.GetFile("System.Reflection.Tests.dll").Name, typeof(AssemblyTests).Assembly.Location);
if (PlatformDetection.IsNotBrowser) // see https://github.com/dotnet/runtime/issues/39650
Assert.Equal(typeof(AssemblyTests).Assembly.GetFile("System.Reflection.Tests.dll").Name, typeof(AssemblyTests).Assembly.Location);
}

[Fact]
public void GetFiles()
{
Assert.NotNull(typeof(AssemblyTests).Assembly.GetFiles());
Assert.Equal(1, typeof(AssemblyTests).Assembly.GetFiles().Length);
Assert.Equal(typeof(AssemblyTests).Assembly.GetFiles()[0].Name, typeof(AssemblyTests).Assembly.Location);
if (PlatformDetection.IsNotBrowser) // see https://github.com/dotnet/runtime/issues/39650
Assert.Equal(typeof(AssemblyTests).Assembly.GetFiles()[0].Name, typeof(AssemblyTests).Assembly.Location);
}

public static IEnumerable<object[]> GetHashCode_TestData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace System.Reflection.Tests
public class AssemblyTests
{
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/39650", TestPlatforms.Browser)]
public void CurrentLocation_HasLocaton()
{
string location = GetExecutingAssembly().Location;
Expand Down
3 changes: 0 additions & 3 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.Uri\tests\FunctionalTests\System.Private.Uri.Functional.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.Xml\tests\XmlSerializer\ReflectionOnly\System.Xml.XmlSerializer.ReflectionOnly.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.Xml\tests\XmlSerializer\System.Xml.XmlSerializer.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Reflection.Metadata\tests\System.Reflection.Metadata.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Reflection\tests\CoreCLR\System.Reflection.CoreCLR.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Reflection\tests\System.Reflection.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Security.Permissions\tests\System.Security.Permissions.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Threading.Thread\tests\System.Threading.Thread.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.ValueTuple\tests\System.ValueTuple.Tests.csproj" />
Expand Down

0 comments on commit f501577

Please sign in to comment.