dotnet / dotnet/runtime

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

Open
#127,786 4 comments 0 reactions 0 assignees View on GitHub
area-NativeAOT-coreclr disabled-test os-ios os-maccatalyst os-tvos
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

## 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.Name` — `Module.Name` returns `""` (expected `"system.runtime.tests.dll"`).
2. `System.Reflection.Tests.ModuleTests.FullyQualifiedName` — `Module.FullyQualifiedName` returns `""` (expected empty).
3. `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 `""`) 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. `` plus inclusion in `BundleFiles` / AppleAppBuilder resources) and resolve the path via `AppContext.BaseDirectory` instead of `Directory.GetCurrentDirectory()`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.