Skip to content

Commit

Permalink
Enable skipped Runtime.Extensions tests on Android (#56586)
Browse files Browse the repository at this point in the history
1. AppDomain TestingCreateInstanceFromObjectHandle and TestingCreateInstanceFromObjectHandleFullSignature were failing because the assembly file to load has to be case sensitive and wasn't.

2. AppDomain TargetFrameworkTest was permanently skipped

3. StringComparerTests CreateFromCultureAndOptions, CreateFromCultureAndOptionsStringSort, and CreateWithCulturesTest skips testing the turkish culture as it's problematic on Android

4. Environment.Exit ExitCode_VoidMainAppReturnsSetValue was permanently skipped

Fixes #49868
  • Loading branch information
steveisok authored Jul 31, 2021
1 parent 0f04d34 commit 3ec2f67
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public static partial class PlatformDetection
public static bool Is64BitProcess => IntPtr.Size == 8;
public static bool IsNotWindows => !IsWindows;

public static bool IsCaseInsensitiveOS => IsWindows || IsOSX;
public static bool IsCaseSensitiveOS => !IsCaseInsensitiveOS;

public static bool IsThreadingSupported => !IsBrowser;
public static bool IsBinaryFormatterSupported => IsNotMobile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public void RelativeSearchPath_Is_Null()
}

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "throws pNSE")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/49868", TestPlatforms.Android)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/36896", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
[SkipOnPlatform(TestPlatforms.Browser | TestPlatforms.Android | TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "The dotnet sdk will not be available on these platforms")]
public void TargetFrameworkTest()
{
const int ExpectedExitCode = 0;
Expand Down Expand Up @@ -800,9 +798,9 @@ public static void GetPermissionSet()
}

[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux | TestPlatforms.Browser | TestPlatforms.Android, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[MemberData(nameof(TestingCreateInstanceFromObjectHandleData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux | TestPlatforms.Browser, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/36896", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
[MemberData(nameof(TestingCreateInstanceFromObjectHandleData))]
public static void TestingCreateInstanceFromObjectHandle(string physicalFileName, string assemblyFile, string type, string returnedFullNameType, Type exceptionType)
{
ObjectHandle oh = null;
Expand Down Expand Up @@ -838,18 +836,29 @@ public static void TestingCreateInstanceFromObjectHandle(string physicalFileName
Assert.True(File.Exists(physicalFileName));
}

public static TheoryData<string, string, string, string, Type> TestingCreateInstanceFromObjectHandleData => new TheoryData<string, string, string, string, Type>
public static IEnumerable<object[]> TestingCreateInstanceFromObjectHandleData()
{
Type exceptionType;

if (PlatformDetection.IsCaseSensitiveOS && PlatformDetection.IsMonoRuntime)
{
exceptionType = typeof(FileNotFoundException);
}
else
{
exceptionType = typeof(TypeLoadException);
}

// string physicalFileName, string assemblyFile, string typeName, returnedFullNameType, expectedException
{ "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassSample", "AssemblyResolveTestApp.PublicClassSample", null },
{ "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclasssample", "AssemblyResolveTestApp.PublicClassSample", typeof(TypeLoadException) },
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassSample", "AssemblyResolveTestApp.PublicClassSample", null };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclasssample", "AssemblyResolveTestApp.PublicClassSample", exceptionType };

{ "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PrivateClassSample", "AssemblyResolveTestApp.PrivateClassSample", null },
{ "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.privateclasssample", "AssemblyResolveTestApp.PrivateClassSample", typeof(TypeLoadException) },
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PrivateClassSample", "AssemblyResolveTestApp.PrivateClassSample", null };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.privateclasssample", "AssemblyResolveTestApp.PrivateClassSample", exceptionType };

{ "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", typeof(MissingMethodException) },
{ "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclassnodefaultconstructorsample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", typeof(TypeLoadException) }
};
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", typeof(MissingMethodException) };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclassnodefaultconstructorsample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", exceptionType };
}

[Theory]
[MemberData(nameof(TestingCreateInstanceObjectHandleData))]
Expand Down Expand Up @@ -901,7 +910,7 @@ public static void TestingCreateInstanceObjectHandle(string assemblyName, string
};

[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux | TestPlatforms.Browser | TestPlatforms.Android, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux | TestPlatforms.Browser, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[MemberData(nameof(TestingCreateInstanceFromObjectHandleFullSignatureData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/36896", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public static void TestingCreateInstanceFromObjectHandleFullSignature(string physicalFileName, string assemblyFile, string type, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, string returnedFullNameType)
Expand All @@ -919,14 +928,17 @@ public static IEnumerable<object[]> TestingCreateInstanceFromObjectHandleFullSig
{
// string physicalFileName, string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, returnedFullNameType
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassSample", false, BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[0], CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PublicClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclasssample", true, BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[0], CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PublicClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassSample", false, BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[1] { 1 }, CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PublicClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclasssample", true, BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[1] { 1 }, CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PublicClassSample" };

yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PrivateClassSample", false, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[0], CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PrivateClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.privateclasssample", true, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[0], CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PrivateClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PrivateClassSample", false, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[1] { 1 }, CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PrivateClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.privateclasssample", true, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[1] { 1 }, CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PrivateClassSample" };

if (PlatformDetection.IsCaseInsensitiveOS)
{
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclasssample", true, BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[0], CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PublicClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclasssample", true, BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[1] { 1 }, CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PublicClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.privateclasssample", true, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[0], CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PrivateClassSample" };
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.privateclasssample", true, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, Type.DefaultBinder, new object[1] { 1 }, CultureInfo.InvariantCulture, null, "AssemblyResolveTestApp.PrivateClassSample" };
}
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public static void ExitCode_Roundtrips(int exitCode)
[InlineData(1)] // setting ExitCode and exiting Main
[InlineData(2)] // setting ExitCode both from Main and from an Unloading event handler.
[InlineData(3)] // using Exit(exitCode)
[SkipOnPlatform(TestPlatforms.Browser | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on Browser, iOS, MacCatalyst, or tvOS.")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/49868", TestPlatforms.Android)]
[SkipOnPlatform(TestPlatforms.Android | TestPlatforms.Browser | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on Android, Browser, iOS, MacCatalyst, or tvOS.")]
public static void ExitCode_VoidMainAppReturnsSetValue(int mode)
{
int expectedExitCode = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static IEnumerable<object[]> UpperLowerCasing_TestData()
yield return new object[] { "abcd", "ABCD", "en-US" };
yield return new object[] { "latin i", "LATIN I", "en-US" };

if (PlatformDetection.IsNotInvariantGlobalization)
if (PlatformDetection.IsNotInvariantGlobalization && !PlatformDetection.IsAndroid)
{
yield return new object[] { "turky \u0131", "TURKY I", "tr-TR" };
yield return new object[] { "turky i", "TURKY \u0130", "tr-TR" };
Expand All @@ -96,7 +96,6 @@ public static IEnumerable<object[]> UpperLowerCasing_TestData()

[Theory]
[MemberData(nameof(UpperLowerCasing_TestData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/49868", TestPlatforms.Android)]
public static void CreateWithCulturesTest(string lowerForm, string upperForm, string cultureName)
{
CultureInfo ci = CultureInfo.GetCultureInfo(cultureName);
Expand Down Expand Up @@ -164,28 +163,33 @@ public static void FromComparisonInvalidTest()
AssertExtensions.Throws<ArgumentException>("comparisonType", () => StringComparer.FromComparison(maxInvalid));
}

public static TheoryData<string, string, string, CompareOptions, bool> CreateFromCultureAndOptionsData =>
new TheoryData<string, string, string, CompareOptions, bool>
public static IEnumerable<object[]> CreateFromCultureAndOptionsData()
{
yield return new object[] { "abcd", "ABCD", "en-US", CompareOptions.None, false};
yield return new object[] { "latin i", "LATIN I", "en-US", CompareOptions.None, false};
yield return new object[] { "turky \u0131", "TURKY I", "tr-TR", CompareOptions.None, false};
yield return new object[] { "turky i", "TURKY \u0130", "tr-TR", CompareOptions.None, false};
yield return new object[] { "abcd", "ABCD", "en-US", CompareOptions.IgnoreCase, true};
yield return new object[] { "latin i", "LATIN I", "en-US", CompareOptions.IgnoreCase, true};

// Android has its own ICU, which doesn't work well with tr
if (!PlatformDetection.IsAndroid)
{
{ "abcd", "ABCD", "en-US", CompareOptions.None, false},
{ "latin i", "LATIN I", "en-US", CompareOptions.None, false},
{ "turky \u0131", "TURKY I", "tr-TR", CompareOptions.None, false},
{ "turky i", "TURKY \u0130", "tr-TR", CompareOptions.None, false},
{ "abcd", "ABCD", "en-US", CompareOptions.IgnoreCase, true},
{ "latin i", "LATIN I", "en-US", CompareOptions.IgnoreCase, true},
{ "turky \u0131", "TURKY I", "tr-TR", CompareOptions.IgnoreCase, true},
{ "turky i", "TURKY \u0130", "tr-TR", CompareOptions.IgnoreCase, true},
{ "abcd", "ab cd", "en-US", CompareOptions.IgnoreSymbols, true },
{ "abcd", "ab+cd", "en-US", CompareOptions.IgnoreSymbols, true },
{ "abcd", "ab%cd", "en-US", CompareOptions.IgnoreSymbols, true },
{ "abcd", "ab&cd", "en-US", CompareOptions.IgnoreSymbols, true },
{ "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
{ "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
{ "a-bcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
{ "abcd*", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
{ "ab$dd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, false },
{ "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
};
yield return new object[] { "turky \u0131", "TURKY I", "tr-TR", CompareOptions.IgnoreCase, true};
yield return new object[] { "turky i", "TURKY \u0130", "tr-TR", CompareOptions.IgnoreCase, true};
}

yield return new object[] { "abcd", "ab cd", "en-US", CompareOptions.IgnoreSymbols, true };
yield return new object[] { "abcd", "ab+cd", "en-US", CompareOptions.IgnoreSymbols, true };
yield return new object[] { "abcd", "ab%cd", "en-US", CompareOptions.IgnoreSymbols, true };
yield return new object[] { "abcd", "ab&cd", "en-US", CompareOptions.IgnoreSymbols, true };
yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
yield return new object[] { "a-bcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
yield return new object[] { "abcd*", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
yield return new object[] { "ab$dd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, false };
yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
}

public static TheoryData<string, string, string, CompareOptions, bool> CreateFromCultureAndOptionsStringSortData => new TheoryData<string, string, string, CompareOptions, bool>
{
Expand All @@ -196,7 +200,6 @@ public static void FromComparisonInvalidTest()
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
[MemberData(nameof(CreateFromCultureAndOptionsData))]
[MemberData(nameof(CreateFromCultureAndOptionsStringSortData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/49868", TestPlatforms.Android)]
public static void CreateFromCultureAndOptions(string actualString, string expectedString, string cultureName, CompareOptions options, bool result)
{
CultureInfo ci = CultureInfo.GetCultureInfo(cultureName);
Expand All @@ -208,7 +211,6 @@ public static void CreateFromCultureAndOptions(string actualString, string expec

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
[MemberData(nameof(CreateFromCultureAndOptionsData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/49868", TestPlatforms.Android)]
public static void CreateFromCultureAndOptionsStringSort(string actualString, string expectedString, string cultureName, CompareOptions options, bool result)
{
CultureInfo ci = CultureInfo.GetCultureInfo(cultureName);
Expand Down

0 comments on commit 3ec2f67

Please sign in to comment.