Skip to content

Commit 3ec2f67

Browse files
authored
Enable skipped Runtime.Extensions tests on Android (#56586)
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
1 parent 0f04d34 commit 3ec2f67

File tree

4 files changed

+62
-46
lines changed

4 files changed

+62
-46
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public static partial class PlatformDetection
5454
public static bool Is64BitProcess => IntPtr.Size == 8;
5555
public static bool IsNotWindows => !IsWindows;
5656

57+
public static bool IsCaseInsensitiveOS => IsWindows || IsOSX;
58+
public static bool IsCaseSensitiveOS => !IsCaseInsensitiveOS;
59+
5760
public static bool IsThreadingSupported => !IsBrowser;
5861
public static bool IsBinaryFormatterSupported => IsNotMobile;
5962

src/libraries/System.Runtime.Extensions/tests/System/AppDomainTests.cs

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ public void RelativeSearchPath_Is_Null()
4444
}
4545

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

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

841-
public static TheoryData<string, string, string, string, Type> TestingCreateInstanceFromObjectHandleData => new TheoryData<string, string, string, string, Type>
839+
public static IEnumerable<object[]> TestingCreateInstanceFromObjectHandleData()
842840
{
841+
Type exceptionType;
842+
843+
if (PlatformDetection.IsCaseSensitiveOS && PlatformDetection.IsMonoRuntime)
844+
{
845+
exceptionType = typeof(FileNotFoundException);
846+
}
847+
else
848+
{
849+
exceptionType = typeof(TypeLoadException);
850+
}
851+
843852
// string physicalFileName, string assemblyFile, string typeName, returnedFullNameType, expectedException
844-
{ "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassSample", "AssemblyResolveTestApp.PublicClassSample", null },
845-
{ "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclasssample", "AssemblyResolveTestApp.PublicClassSample", typeof(TypeLoadException) },
853+
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassSample", "AssemblyResolveTestApp.PublicClassSample", null };
854+
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclasssample", "AssemblyResolveTestApp.PublicClassSample", exceptionType };
846855

847-
{ "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PrivateClassSample", "AssemblyResolveTestApp.PrivateClassSample", null },
848-
{ "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.privateclasssample", "AssemblyResolveTestApp.PrivateClassSample", typeof(TypeLoadException) },
856+
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PrivateClassSample", "AssemblyResolveTestApp.PrivateClassSample", null };
857+
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.privateclasssample", "AssemblyResolveTestApp.PrivateClassSample", exceptionType };
849858

850-
{ "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", typeof(MissingMethodException) },
851-
{ "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclassnodefaultconstructorsample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", typeof(TypeLoadException) }
852-
};
859+
yield return new object[] { "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.dll", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", typeof(MissingMethodException) };
860+
yield return new object[] { "AssemblyResolveTestApp.dll", "assemblyresolvetestapp.dll", "assemblyresolvetestapp.publicclassnodefaultconstructorsample", "AssemblyResolveTestApp.PublicClassNoDefaultConstructorSample", exceptionType };
861+
}
853862

854863
[Theory]
855864
[MemberData(nameof(TestingCreateInstanceObjectHandleData))]
@@ -901,7 +910,7 @@ public static void TestingCreateInstanceObjectHandle(string assemblyName, string
901910
};
902911

903912
[Theory]
904-
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux | TestPlatforms.Browser | TestPlatforms.Android, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
913+
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux | TestPlatforms.Browser, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
905914
[MemberData(nameof(TestingCreateInstanceFromObjectHandleFullSignatureData))]
906915
[ActiveIssue("https://github.com/dotnet/runtime/issues/36896", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
907916
public static void TestingCreateInstanceFromObjectHandleFullSignature(string physicalFileName, string assemblyFile, string type, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, string returnedFullNameType)
@@ -919,14 +928,17 @@ public static IEnumerable<object[]> TestingCreateInstanceFromObjectHandleFullSig
919928
{
920929
// string physicalFileName, string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, returnedFullNameType
921930
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" };
922-
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" };
923931
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" };
924-
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" };
925-
926932
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" };
927-
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" };
928933
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" };
929-
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" };
934+
935+
if (PlatformDetection.IsCaseInsensitiveOS)
936+
{
937+
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" };
938+
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" };
939+
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" };
940+
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" };
941+
}
930942
}
931943

932944
[Theory]

src/libraries/System.Runtime.Extensions/tests/System/Environment.Exit.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public static void ExitCode_Roundtrips(int exitCode)
4141
[InlineData(1)] // setting ExitCode and exiting Main
4242
[InlineData(2)] // setting ExitCode both from Main and from an Unloading event handler.
4343
[InlineData(3)] // using Exit(exitCode)
44-
[SkipOnPlatform(TestPlatforms.Browser | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on Browser, iOS, MacCatalyst, or tvOS.")]
45-
[ActiveIssue("https://github.com/dotnet/runtime/issues/49868", TestPlatforms.Android)]
44+
[SkipOnPlatform(TestPlatforms.Android | TestPlatforms.Browser | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on Android, Browser, iOS, MacCatalyst, or tvOS.")]
4645
public static void ExitCode_VoidMainAppReturnsSetValue(int mode)
4746
{
4847
int expectedExitCode = 123;

src/libraries/System.Runtime.Extensions/tests/System/StringComparer.cs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static IEnumerable<object[]> UpperLowerCasing_TestData()
8787
yield return new object[] { "abcd", "ABCD", "en-US" };
8888
yield return new object[] { "latin i", "LATIN I", "en-US" };
8989

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

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

167-
public static TheoryData<string, string, string, CompareOptions, bool> CreateFromCultureAndOptionsData =>
168-
new TheoryData<string, string, string, CompareOptions, bool>
166+
public static IEnumerable<object[]> CreateFromCultureAndOptionsData()
167+
{
168+
yield return new object[] { "abcd", "ABCD", "en-US", CompareOptions.None, false};
169+
yield return new object[] { "latin i", "LATIN I", "en-US", CompareOptions.None, false};
170+
yield return new object[] { "turky \u0131", "TURKY I", "tr-TR", CompareOptions.None, false};
171+
yield return new object[] { "turky i", "TURKY \u0130", "tr-TR", CompareOptions.None, false};
172+
yield return new object[] { "abcd", "ABCD", "en-US", CompareOptions.IgnoreCase, true};
173+
yield return new object[] { "latin i", "LATIN I", "en-US", CompareOptions.IgnoreCase, true};
174+
175+
// Android has its own ICU, which doesn't work well with tr
176+
if (!PlatformDetection.IsAndroid)
169177
{
170-
{ "abcd", "ABCD", "en-US", CompareOptions.None, false},
171-
{ "latin i", "LATIN I", "en-US", CompareOptions.None, false},
172-
{ "turky \u0131", "TURKY I", "tr-TR", CompareOptions.None, false},
173-
{ "turky i", "TURKY \u0130", "tr-TR", CompareOptions.None, false},
174-
{ "abcd", "ABCD", "en-US", CompareOptions.IgnoreCase, true},
175-
{ "latin i", "LATIN I", "en-US", CompareOptions.IgnoreCase, true},
176-
{ "turky \u0131", "TURKY I", "tr-TR", CompareOptions.IgnoreCase, true},
177-
{ "turky i", "TURKY \u0130", "tr-TR", CompareOptions.IgnoreCase, true},
178-
{ "abcd", "ab cd", "en-US", CompareOptions.IgnoreSymbols, true },
179-
{ "abcd", "ab+cd", "en-US", CompareOptions.IgnoreSymbols, true },
180-
{ "abcd", "ab%cd", "en-US", CompareOptions.IgnoreSymbols, true },
181-
{ "abcd", "ab&cd", "en-US", CompareOptions.IgnoreSymbols, true },
182-
{ "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
183-
{ "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
184-
{ "a-bcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
185-
{ "abcd*", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
186-
{ "ab$dd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, false },
187-
{ "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true },
188-
};
178+
yield return new object[] { "turky \u0131", "TURKY I", "tr-TR", CompareOptions.IgnoreCase, true};
179+
yield return new object[] { "turky i", "TURKY \u0130", "tr-TR", CompareOptions.IgnoreCase, true};
180+
}
181+
182+
yield return new object[] { "abcd", "ab cd", "en-US", CompareOptions.IgnoreSymbols, true };
183+
yield return new object[] { "abcd", "ab+cd", "en-US", CompareOptions.IgnoreSymbols, true };
184+
yield return new object[] { "abcd", "ab%cd", "en-US", CompareOptions.IgnoreSymbols, true };
185+
yield return new object[] { "abcd", "ab&cd", "en-US", CompareOptions.IgnoreSymbols, true };
186+
yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
187+
yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
188+
yield return new object[] { "a-bcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
189+
yield return new object[] { "abcd*", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
190+
yield return new object[] { "ab$dd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, false };
191+
yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true };
192+
}
189193

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

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

0 commit comments

Comments
 (0)