[Apple mobile] Skip unsupported tests on Apple mobile platforms#126631
[Apple mobile] Skip unsupported tests on Apple mobile platforms#126631kotlarmilos wants to merge 11 commits intodotnet:mainfrom
Conversation
- PlatformDetection.IsMethodBodySupported: use IsBuiltWithAggressiveTrimming to exclude platforms where IL bodies are stripped (NativeAOT, Apple mobile) - ProcessTests.Start_Disposed_ThrowsObjectDisposedException: skip on iOS/tvOS/MacCatalyst where Process.Start throws PlatformNotSupportedException before checking disposed state - CustomMethodInfoTests/CustomConstructorInfoTests: guard GetMethodImplementationFlags_ReturnsIL with IsMethodBodySupported since AOT IL stripping changes flags from IL to NoInlining Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Tagging subscribers to this area: @akoeplinger, @matouskozak, @simonrozsival |
There was a problem hiding this comment.
Pull request overview
Fixes test failures on Apple mobile platforms (iOS/tvOS/MacCatalyst) caused by Mono AOT IL stripping altering/removing method bodies, by skipping or conditioning affected tests.
Changes:
- Update
IsMethodBodySupportedto account for aggressively-trimmed builds (incl. Apple mobile). - Make
GetMethodImplementationFlags_ReturnsILtests conditional on method-body availability. - Skip
ProcessTests.Start_Disposed_ThrowsObjectDisposedExceptionon Apple mobile platforms.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs |
Makes the implementation-flags assertion conditional on PlatformDetection.IsMethodBodySupported. |
src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs |
Same conditional gating for constructor implementation-flags test. |
src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs |
Skips a disposed-start exception test on select Apple platforms. |
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs |
Broadens IsMethodBodySupported to treat aggressively trimmed builds as unsupported for method-body-based tests. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
vitek-karas
left a comment
There was a problem hiding this comment.
Looks good
@adamsitnik can you quickly review the process test changes just to be sure?
|
I'm also trying to add #126635 into this since it looks like the same root cause (agressive trimming) |
adamsitnik
left a comment
There was a problem hiding this comment.
Process part LGTM, thank you @kotlarmilos !
src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs
Outdated
Show resolved
Hide resolved
…f IsMethodBodySupported These tests check method implementation flags, not method bodies. Mono IL stripping changes flags from IL to NoInlining, but R2R IL stripping does not. Skip on Mono only to preserve NativeAOT coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs
Show resolved
Hide resolved
…ming Add the active issue for the aggressive-trimming failure tracked by dotnet#126635. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs:195
- This test is now conditioned on PlatformDetection.IsNotMonoRuntime, but the rationale (and nearby tests) point to method bodies/flags changing under aggressive trimming/IL stripping. Gating on IsNotMonoRuntime will skip the test on all Mono runtimes (even when method bodies are available) and may still run under trimmed CoreCLR scenarios. Consider conditioning on PlatformDetection.IsMethodBodySupported or PlatformDetection.IsNotBuiltWithAggressiveTrimming instead, so the skip matches the actual failing environment.
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
public void GetMethodImplementationFlags_ReturnsIL()
{
MethodImplAttributes flags = _customMethod.GetMethodImplementationFlags();
Assert.Equal(MethodImplAttributes.IL, flags);
}
src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs:163
- This test is now conditioned on PlatformDetection.IsNotMonoRuntime, but the underlying failure mode described for Apple mobile is aggressive trimming/IL stripping affecting implementation flags. Using IsNotMonoRuntime is broader than necessary and may also fail to skip trimmed non-Mono runs. Consider gating on PlatformDetection.IsMethodBodySupported or PlatformDetection.IsNotBuiltWithAggressiveTrimming so the skip condition matches the scenario being worked around.
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
public void GetMethodImplementationFlags_ReturnsIL()
{
MethodImplAttributes flags = _customConstructor.GetMethodImplementationFlags();
Assert.Equal(MethodImplAttributes.IL, flags);
}
...ource/tests/System.Diagnostics.TraceSource.Config.Tests/TraceSourceWithConfigurationTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs:194
GetMethodImplementationFlags_ReturnsILis now conditioned onPlatformDetection.IsNotMonoRuntime, which will still run on NativeAOT and on CoreCLR-based Apple mobile runs. Those are exactly the environments where aggressive trimming/AOT can changeMethodImplAttributesaway fromIL, so this test may still fail. If the intent is to skip when method bodies/IL are stripped, gate this onPlatformDetection.IsMethodBodySupported(orIsNotBuiltWithAggressiveTrimming) instead ofIsNotMonoRuntime, or update the assertion to accept the trimmed/AOT flags when appropriate.
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
public void GetMethodImplementationFlags_ReturnsIL()
{
MethodImplAttributes flags = _customMethod.GetMethodImplementationFlags();
Assert.Equal(MethodImplAttributes.IL, flags);
src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs:162
- Same issue as
CustomMethodInfoTests: conditioning this test onPlatformDetection.IsNotMonoRuntimewill still execute it on NativeAOT (and potentially CoreCLR-based Apple mobile), where trimming/AOT can changeGetMethodImplementationFlags()away fromMethodImplAttributes.IL. Consider gating onPlatformDetection.IsMethodBodySupported/IsNotBuiltWithAggressiveTrimming, or broaden the expected flags for trimmed/AOT builds.
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
public void GetMethodImplementationFlags_ReturnsIL()
{
MethodImplAttributes flags = _customConstructor.GetMethodImplementationFlags();
Assert.Equal(MethodImplAttributes.IL, flags);
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
src/libraries/System.Reflection.Context/tests/CustomMethodInfoTests.cs:195
- Using PlatformDetection.IsNotMonoRuntime here skips the test on all Mono configurations, but it still runs on NativeAOT (which is also affected by aggressive trimming/IL stripping). If the intent is to avoid failures when method bodies are stripped and the implementation flags change, consider conditioning on PlatformDetection.IsNotBuiltWithAggressiveTrimming (or another trimming/AOT-specific predicate) instead so the test continues to run on non-trimmed Mono and is skipped on NativeAOT/Apple-mobile where it’s known to differ.
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
public void GetMethodImplementationFlags_ReturnsIL()
{
MethodImplAttributes flags = _customMethod.GetMethodImplementationFlags();
Assert.Equal(MethodImplAttributes.IL, flags);
}
src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs:163
- Same issue as CustomMethodInfoTests: PlatformDetection.IsNotMonoRuntime will skip on all Mono configurations but still run on NativeAOT. If this assertion is only valid when method bodies aren’t aggressively trimmed, condition it on PlatformDetection.IsNotBuiltWithAggressiveTrimming (or similar) so it’s skipped on NativeAOT/Apple-mobile but still exercised on non-trimmed Mono.
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]
public void GetMethodImplementationFlags_ReturnsIL()
{
MethodImplAttributes flags = _customConstructor.GetMethodImplementationFlags();
Assert.Equal(MethodImplAttributes.IL, flags);
}
Instead of using a class-level ActiveIssue with IsBuiltWithAggressiveTrimming (which also suppresses NativeAOT), exclude the entire project from compilation and Helix submission for Apple mobile CoreCLR. All individual tests already have ActiveIssue for iOS/tvOS/Android, so zero tests would run anyway. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Summary
Skip unsupported tests on Apple mobile platforms.
Changes