Skip to content

[NativeAOT] System.Runtime.Tests fail under single-file/static-link app bundle #127786

@kotlarmilos

Description

@kotlarmilos

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:

  1. System.Reflection.Tests.ModuleTests.NameModule.Name returns "<Unknown>" (expected "system.runtime.tests.dll").
  2. System.Reflection.Tests.ModuleTests.FullyQualifiedNameModule.FullyQualifiedName returns "<Unknown>" (expected empty).
  3. System.Tests.DoubleTests.ParsePatternsFileNotFoundException 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().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions