Description
When System.Runtime.Tests.dll is built with NativeAOT and packaged into an Apple mobile .app (iOS / tvOS / MacCatalyst), three tests fail because the test project is statically linked into the app binary with no on-disk managed DLL, and the app's working directory does not point at bundled content files.
Failing tests:
System.Reflection.Tests.ModuleTests.Name — Module.Name returns "<Unknown>" (expected "system.runtime.tests.dll").
System.Reflection.Tests.ModuleTests.FullyQualifiedName — Module.FullyQualifiedName returns "<Unknown>" (expected empty).
System.Tests.DoubleTests.ParsePatterns — FileNotFoundException for /ibm-fpgen.txt; the test reads Directory.GetCurrentDirectory() + ibm-fpgen.txt, but cwd is / and ibm-fpgen.txt (from the System.Runtime.Numerics.TestData content-files NuGet) is not bundled into the .app.
Fix
ModuleTests.Name / ModuleTests.FullyQualifiedName: extend the existing #if SINGLE_FILE_TEST_RUNNER branch (which already asserts "<Unknown>") to cover NativeAOT-on-Apple-mobile. Either define SINGLE_FILE_TEST_RUNNER for that build, or replace the #if with a runtime check (e.g. if (PlatformDetection.IsAppleMobile && PlatformDetection.IsNativeAot)).
DoubleTests.ParsePatterns: bundle ibm-fpgen.txt into the .app (e.g. <Content Include="$(PkgSystem_Runtime_Numerics_TestData)/contentFiles/.../ibm-fpgen.txt" CopyToOutputDirectory="PreserveNewest" /> plus inclusion in BundleFiles / AppleAppBuilder resources) and resolve the path via AppContext.BaseDirectory instead of Directory.GetCurrentDirectory().
Description
When
System.Runtime.Tests.dllis built with NativeAOT and packaged into an Apple mobile.app(iOS / tvOS / MacCatalyst), three tests fail because the test project is statically linked into the app binary with no on-disk managed DLL, and the app's working directory does not point at bundled content files.Failing tests:
System.Reflection.Tests.ModuleTests.Name—Module.Namereturns"<Unknown>"(expected"system.runtime.tests.dll").System.Reflection.Tests.ModuleTests.FullyQualifiedName—Module.FullyQualifiedNamereturns"<Unknown>"(expected empty).System.Tests.DoubleTests.ParsePatterns—FileNotFoundExceptionfor/ibm-fpgen.txt; the test readsDirectory.GetCurrentDirectory() + ibm-fpgen.txt, but cwd is/andibm-fpgen.txt(from theSystem.Runtime.Numerics.TestDatacontent-files NuGet) is not bundled into the.app.Fix
ModuleTests.Name/ModuleTests.FullyQualifiedName: extend the existing#if SINGLE_FILE_TEST_RUNNERbranch (which already asserts"<Unknown>") to cover NativeAOT-on-Apple-mobile. Either defineSINGLE_FILE_TEST_RUNNERfor that build, or replace the#ifwith a runtime check (e.g.if (PlatformDetection.IsAppleMobile && PlatformDetection.IsNativeAot)).DoubleTests.ParsePatterns: bundleibm-fpgen.txtinto the.app(e.g.<Content Include="$(PkgSystem_Runtime_Numerics_TestData)/contentFiles/.../ibm-fpgen.txt" CopyToOutputDirectory="PreserveNewest" />plus inclusion inBundleFiles/ AppleAppBuilder resources) and resolve the path viaAppContext.BaseDirectoryinstead ofDirectory.GetCurrentDirectory().