Skip to content

Commit

Permalink
Added support for tests to check if they are running under the mono i…
Browse files Browse the repository at this point in the history
…nterpreter (dotnet#33106)

The mono interpreter is activated by passing --interpreter into the MONO_ENV_OPTIONS
environment variable.
  • Loading branch information
steveisok authored Mar 4, 2020
1 parent 33f2807 commit ebfb4ca
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static partial class PlatformDetection

public static bool IsNetCore => RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase);
public static bool IsMonoRuntime => Type.GetType("Mono.RuntimeStructs") != null;
public static bool IsMonoInterpreter => GetIsRunningOnMonoInterpreter();
public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"));
public static bool IsNetBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"));

Expand Down Expand Up @@ -201,5 +202,13 @@ private static bool GetSsl3Support()

return (IsOSX || (IsLinux && OpenSslVersion < new Version(1, 0, 2) && !IsDebian));
}

private static bool GetIsRunningOnMonoInterpreter()
{
// This is a temporary solution because mono does not support interpreter detection
// within the runtime.
var val = Environment.GetEnvironmentVariable("MONO_ENV_OPTIONS");
return (val != null && val.Contains("--interpreter"));
}
}
}

0 comments on commit ebfb4ca

Please sign in to comment.