Skip to content

Commit

Permalink
[tests] Fix PlatformDetection.IsMonoInterpreter for mobile (#59587)
Browse files Browse the repository at this point in the history
* [tests] Correctly detect the Mono interpreter

Checking for MONO_ENV_OPTIONS is not reliable for the mobile test runners
because they use the embedding API to enable the interpreter, rather than
setting an environment option.

Instead detect the interpreter by checking the values of the
IsDynamicCodeSupported and IsDynamicCodeCompiled runtime features.

* [tests] Run System.Threading.Tasks.Dataflow.Tests on Apple platforms

* Only check RuntimeFeature on netcoreapp.  Otherwise return false

these tests are not running on mono if they're running on .NET Framework
  • Loading branch information
lambdageek committed Sep 25, 2021
1 parent c344d64 commit 234b789
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Expand Up @@ -467,13 +467,10 @@ private static bool GetTls13Support()
private static bool GetIsRunningOnMonoInterpreter()
{
#if NETCOREAPP
if (IsBrowser)
return RuntimeFeature.IsDynamicCodeSupported;
return IsMonoRuntime && RuntimeFeature.IsDynamicCodeSupported && !RuntimeFeature.IsDynamicCodeCompiled;
#else
return false;
#endif
// 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"));
}

private static bool GetIsBrowserDomSupported()
Expand Down
1 change: 0 additions & 1 deletion src/libraries/tests.proj
Expand Up @@ -170,7 +170,6 @@
<ProjectExclusions Include="$(RepoRoot)/src/tests/FunctionalTests/tvOS/Simulator/AOT/tvOS.Simulator.Aot.Test.csproj" />
<!-- Crashes randomly during test runs https://github.com/dotnet/runtime/issues/52460 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Threading.Tasks\tests\System.Threading.Tasks.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Threading.Tasks.Dataflow\tests\System.Threading.Tasks.Dataflow.Tests.csproj" />

<!-- Crash https://github.com/dotnet/runtime/issues/56085 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Roslyn3.11.Tests.csproj" />
Expand Down

0 comments on commit 234b789

Please sign in to comment.