Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libraries] Update System.Runtime.Extensions tests for iOS,MacCatalyst,tvOS #57210

Merged
merged 6 commits into from
Aug 14, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ 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 IsCaseInsensitiveOS => IsWindows || IsOSX || IsMacCatalyst;
public static bool IsCaseSensitiveOS => !IsCaseInsensitiveOS;

public static bool IsThreadingSupported => !IsBrowser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,6 @@ public static void GetPermissionSet()
}

[Theory]
[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)
{
Expand Down Expand Up @@ -910,9 +908,7 @@ public static void TestingCreateInstanceObjectHandle(string assemblyName, string
};

[Theory]
[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)
{
ObjectHandle oh = AppDomain.CurrentDomain.CreateInstanceFrom(assemblyFile: assemblyFile, typeName: type, ignoreCase: ignoreCase, bindingAttr: bindingAttr, binder: binder, args: args, culture: culture, activationAttributes: activationAttributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public static void ExitCode_Roundtrips(int exitCode)
Environment.ExitCode = 0; // in case the test host has a void returning Main
}

[Theory]
[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
[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.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 @@ -161,7 +161,7 @@ public void OSVersion_ValidVersion()

// On non-OSX Unix, we must parse the version from uname -r
[Theory]
[PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.OSX & ~TestPlatforms.Browser)]
[PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.OSX & ~TestPlatforms.Browser & ~TestPlatforms.iOS & ~TestPlatforms.tvOS & ~TestPlatforms.MacCatalyst)]
[InlineData("2.6.19-1.2895.fc6", 2, 6, 19, 1)]
[InlineData("xxx1yyy2zzz3aaa4bbb", 1, 2, 3, 4)]
[InlineData("2147483647.2147483647.2147483647.2147483647", int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue)]
Expand All @@ -171,7 +171,6 @@ public void OSVersion_ValidVersion()
[InlineData("nelknet 4.15.0-24201807041620-generic", 4, 15, 0, int.MaxValue)] // integer overflow
[InlineData("", 0, 0, 0, 0)]
[InlineData("1abc", 1, 0, 0, 0)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/36896", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public void OSVersion_ParseVersion(string input, int major, int minor, int build, int revision)
{
var getOSMethod = typeof(Environment).GetMethod("GetOperatingSystem", BindingFlags.Static | BindingFlags.NonPublic);
Expand Down Expand Up @@ -333,7 +332,8 @@ public void FailFast_ExceptionStackTrace_InnerException()

[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix | TestPlatforms.Browser)] // Tests OS-specific environment
[ActiveIssue("https://github.com/dotnet/runtime/issues/36896", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not valid on iOS or tvOS")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/36896", TestPlatforms.MacCatalyst)]
Copy link
Member

Choose a reason for hiding this comment

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

Do you expect that this test can be fixed to be valid on Catalyst? Catalyst is generally like iOS.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah Catalyst has the same behavior as iOS here. We can actually enable parts of the test since we just use a different value for SpecialFolder.Personal / SpecialFolder.MyDocuments. Will push to the PR.

Copy link
Member Author

@mdh1418 mdh1418 Aug 13, 2021

Choose a reason for hiding this comment

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

Looking more closely, it looks like Environment.GetEnvironmentVariable("Home") is null or empty on iOSSimulator and tvOSSimulator. However, on MacCatalyst, it seems to be /Users/mdhwang and the tests expected paths are
Environment.GetFolderPath(Environment.SpecialFolder.Personal) evaluates to /Users/mdhwang/Documents
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) evaluates to /Users/mdhwang/Documents
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) evaluates to /Users/mdhwang

However, it seems like a previous tvOSSimulator's failure message was
Assert.Equal() Failure\n ↓ (pos 161)\nExpected: ···F1-ADDB-B49F66D98B32\nActual: ···F1-ADDB-B49F66D98B32/Documents\n ↑ (pos 161) which suggests that sometimes the Home environment variable is not empty or null? possibly flakey?

@filipnavara

GetFolderPath_Unix_PersonalIsHomeAndUserProfile is not valid for iOS, tvOS

Could you elaborate on why its not valid for iOS/tvOS?

Copy link
Member

Choose a reason for hiding this comment

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

Hm I tried with preview7 on iOSSimulator and Environment.GetEnvironmentVariable("HOME") returned a path there. did you test with Home or HOME?

Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate on why its not valid for iOS/tvOS?

On iOS:

  • Personal/MyDocuments (same enum value) returns value of NSSearchPathDirectory.NSDocumentDirectory
  • UserProfile return the HOME environment variable. I remember testing it but I don't remember the value anymore, my previous comment would imply that it was null

On tvOS:

Copy link
Member Author

@mdh1418 mdh1418 Aug 13, 2021

Choose a reason for hiding this comment

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

did you test with Home or HOME?

I used HOME and I temporarily modified the test for these OSes and it passes on MacCatalyst after this modification.

[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix | TestPlatforms.Browser)]  // Tests OS-specific environment
public void GetFolderPath_Unix_PersonalIsHomeAndUserProfile()
{
    Console.WriteLine("Mitchell Hwang");
    Console.WriteLine(Environment.GetEnvironmentVariable("HOME"));
    Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
    Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
    Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
    Assert.Equal(Environment.GetEnvironmentVariable("HOME")+"/Documents", Environment.GetFolderPath(Environment.SpecialFolder.Personal));
    Assert.Equal(Environment.GetEnvironmentVariable("HOME")+"/Documents", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
    Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
}

The most recent run locally on preview 6 was
Assert.Equal() Failure\nExpected: (null)\nActual: /Users/mdhwang/Library/Developer/CoreSimulator/Devices/71D00C72-A1BD-4EF7-87EA-B22842EC1650/data/Containers/Data/Application/E3609B50-9E46-4864-A413-A1C506C5295D/Documents

public void GetFolderPath_Unix_PersonalIsHomeAndUserProfile()
{
Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.Personal));
Expand Down