diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-ioslike.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-ioslike.yml index 4b4c576ab3ee4a..388ee187de8fbc 100644 --- a/eng/pipelines/extra-platforms/runtime-extra-platforms-ioslike.yml +++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-ioslike.yml @@ -115,9 +115,9 @@ jobs: value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'] ] jobParameters: testGroup: innerloop - nameSuffix: AllSubsets_NativeAOT_Smoke - buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunSmokeTestsOnly=true /p:DevTeamProvisioning=- /p:BuildTestsOnHelix=true /p:UseNativeAOTRuntime=true /p:RunAOTCompilation=false /p:ContinuousIntegrationBuild=true - timeoutInMinutes: 180 + nameSuffix: AllSubsets_NativeAOT + buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:BuildTestsOnHelix=true /p:UseNativeAOTRuntime=true /p:RunAOTCompilation=false /p:ContinuousIntegrationBuild=true + timeoutInMinutes: 360 # extra steps, run tests postBuildSteps: - template: /eng/pipelines/libraries/helix.yml diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-ioslikesimulator.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-ioslikesimulator.yml index 1f9ca62d63d437..e2df4443791ad4 100644 --- a/eng/pipelines/extra-platforms/runtime-extra-platforms-ioslikesimulator.yml +++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-ioslikesimulator.yml @@ -110,9 +110,9 @@ jobs: value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'] ] jobParameters: testGroup: innerloop - nameSuffix: AllSubsets_NativeAOT_Smoke - buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunSmokeTestsOnly=true /p:DevTeamProvisioning=- /p:BuildTestsOnHelix=true /p:UseNativeAOTRuntime=true /p:RunAOTCompilation=false /p:ContinuousIntegrationBuild=true - timeoutInMinutes: 180 + nameSuffix: AllSubsets_NativeAOT + buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:BuildTestsOnHelix=true /p:UseNativeAOTRuntime=true /p:RunAOTCompilation=false /p:ContinuousIntegrationBuild=true + timeoutInMinutes: 360 # extra steps, run tests postBuildSteps: - template: /eng/pipelines/libraries/helix.yml diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-maccatalyst.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-maccatalyst.yml index 33275659ab10fe..145a0dd5f4d19b 100644 --- a/eng/pipelines/extra-platforms/runtime-extra-platforms-maccatalyst.yml +++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-maccatalyst.yml @@ -147,9 +147,9 @@ jobs: value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'] ] jobParameters: testGroup: innerloop - nameSuffix: AllSubsets_NativeAOT_Smoke - buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunSmokeTestsOnly=true /p:DevTeamProvisioning=adhoc /p:BuildTestsOnHelix=true /p:UseNativeAOTRuntime=true /p:RunAOTCompilation=false /p:ContinuousIntegrationBuild=true - timeoutInMinutes: 180 + nameSuffix: AllSubsets_NativeAOT + buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=adhoc /p:BuildTestsOnHelix=true /p:UseNativeAOTRuntime=true /p:RunAOTCompilation=false /p:ContinuousIntegrationBuild=true + timeoutInMinutes: 360 # extra steps, run tests postBuildSteps: - template: /eng/pipelines/libraries/helix.yml @@ -180,9 +180,9 @@ jobs: value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'] ] jobParameters: testGroup: innerloop - nameSuffix: AllSubsets_NativeAOT_Smoke_AppSandbox - buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunSmokeTestsOnly=true /p:DevTeamProvisioning=adhoc /p:BuildTestsOnHelix=true /p:UseNativeAOTRuntime=true /p:RunAOTCompilation=false /p:ContinuousIntegrationBuild=true /p:EnableAppSandbox=true - timeoutInMinutes: 180 + nameSuffix: AllSubsets_NativeAOT_AppSandbox + buildArgs: --cross -s clr.alljits+clr.tools+clr.nativeaotruntime+clr.nativeaotlibs+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=adhoc /p:BuildTestsOnHelix=true /p:UseNativeAOTRuntime=true /p:RunAOTCompilation=false /p:ContinuousIntegrationBuild=true /p:EnableAppSandbox=true + timeoutInMinutes: 360 # extra steps, run tests postBuildSteps: - template: /eng/pipelines/libraries/helix.yml diff --git a/eng/testing/tests.ioslike.targets b/eng/testing/tests.ioslike.targets index f0c89c5ada10e7..24de43e2a24225 100644 --- a/eng/testing/tests.ioslike.targets +++ b/eng/testing/tests.ioslike.targets @@ -3,6 +3,26 @@ $(BundleTestAppTargets);BundleTestAppleApp + + + true + true + true + <_IsPublishing Condition="'$(_IsPublishing)' == ''">true + Static + true + <_SuppressNativeLibEventSourceWarning>true + + + + + + + + + + helix helix @@ -80,6 +100,14 @@ Include="@(AppleAssembliesToBundle)" TargetDir="extraFiles\%(AppleAssembliesToBundle.RecursiveDir)" /> + + + <_NativeAotHelixLinkInputs Include="$(MicrosoftNetCoreAppRuntimePackDir)/runtimes/$(TargetOS)-$(TargetArchitecture)/native/*.a" /> + <_NativeAotHelixLinkInputs Include="$(CoreCLRAotSdkDir)*.a" /> + <_NativeAotHelixLinkInputs Include="$(CoreCLRAotSdkDir)*.o" /> + + + @@ -180,7 +208,8 @@ true true true - AppleTestRunner.dll + AppleTestRunner.dll + $(PublishDir) $(BundleDir) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index d38673115d6aa4..68b06a8e308013 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -126,7 +126,7 @@ Condition="'$(TestFramework)' == 'xunit'"> <_runnerFilesToPublish Include="$(AndroidTestRunnerDir)*" Condition="'$(TargetOS)' == 'android'" /> - <_runnerFilesToPublish Include="$(AppleTestRunnerDir)*" Condition="'$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'tvossimulator'" /> + <_runnerFilesToPublish Include="$(AppleTestRunnerDir)*" Condition="('$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'tvossimulator') and '$(TestNativeAot)' != 'true'" /> <_runnerFilesToPublish Include="$(WasmTestRunnerDir)*" Condition="'$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'wasi'" /> diff --git a/eng/testing/tests.singlefile.targets b/eng/testing/tests.singlefile.targets index 1a992b1b7e10d3..e282e93b74dd86 100644 --- a/eng/testing/tests.singlefile.targets +++ b/eng/testing/tests.singlefile.targets @@ -6,8 +6,8 @@ $([MSBuild]::NormalizePath('$(BundleDir)', '$(RunScriptOutputName)')) $(TargetRid) - $(AssemblyName).exe - chmod +rwx $(AssemblyName) && ./$(AssemblyName) + $(AssemblyName).exe + chmod +rwx $(AssemblyName) && ./$(AssemblyName) @@ -40,7 +40,7 @@ true - + $(DefineConstants);SINGLE_FILE_TEST_RUNNER @@ -51,12 +51,15 @@ + + + + Condition="'$(CLRTestKind)' == '' and '$(IsFunctionalTest)' != 'true' and '$(TargetsAppleMobile)' != 'true'" /> @@ -183,7 +186,7 @@ diff --git a/eng/testing/xunit/xunit.console.targets b/eng/testing/xunit/xunit.console.targets index cb79571f2f1d5c..e3b2fbfa916bb6 100644 --- a/eng/testing/xunit/xunit.console.targets +++ b/eng/testing/xunit/xunit.console.targets @@ -52,7 +52,7 @@ $(_withoutCategories.Replace(';', '%0dcategory=')) - + $(RunScriptCommand) -xml $(TestResultsName) diff --git a/src/libraries/Common/tests/AppleTestRunner/AppleTestRunner.cs b/src/libraries/Common/tests/AppleTestRunner/AppleTestRunner.cs index 62d01c6df836eb..2af27adacbe6d0 100644 --- a/src/libraries/Common/tests/AppleTestRunner/AppleTestRunner.cs +++ b/src/libraries/Common/tests/AppleTestRunner/AppleTestRunner.cs @@ -1,11 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + using System; using System.Linq; using System.Text; using System.IO; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Threading; using System.Threading.Tasks; @@ -24,6 +27,7 @@ public class SimpleTestRunner : iOSApplicationEntryPoint, IDevice public extern static void mono_ios_set_summary (string value); private static List s_testLibs = new List(); + private static List? s_testAssemblies; private static string? s_MainTestName; public static async Task Main(string[] args) @@ -37,6 +41,14 @@ public static async Task Main(string[] args) } Console.WriteLine("."); + string cwd = AppContext.BaseDirectory; + string maccatResources = Path.Combine(cwd, "..", "Resources"); + if (Directory.Exists(maccatResources)) + { + cwd = Path.GetFullPath(maccatResources); + } + Directory.SetCurrentDirectory(cwd); + foreach (string arg in args.Where(a => a.StartsWith("testlib:"))) { s_testLibs.Add(arg.Remove(0, "testlib:".Length)); @@ -45,13 +57,30 @@ public static async Task Main(string[] args) if (s_testLibs.Count < 1) { - // Look for *.Tests.dll files if target test suites are not set via "testlib:" arguments - s_testLibs = Directory.GetFiles(Environment.CurrentDirectory, "*.Tests.dll").ToList(); + if (!RuntimeFeature.IsDynamicCodeSupported) + { + s_testAssemblies = AppDomain.CurrentDomain.GetAssemblies() + .Where(a => a.GetName().Name?.EndsWith(".Tests") == true) + .ToList(); + s_testLibs = s_testAssemblies.Select(a => a.GetName().Name!).ToList(); + } + else + { + s_testLibs = Directory.GetFiles(Environment.CurrentDirectory, "*.Tests.dll").ToList(); + } } if (s_testLibs.Count < 1) { - Console.WriteLine($"Test libs were not found (*.Tests.dll was not found in {Environment.CurrentDirectory})"); + if (!RuntimeFeature.IsDynamicCodeSupported) + { + Console.WriteLine("No assemblies ending with '.Tests' were found among loaded assemblies."); + } + else + { + Console.WriteLine($"Test libs were not found (*.Tests.dll was not found in {Environment.CurrentDirectory})"); + } + return -1; } @@ -61,7 +90,9 @@ public static async Task Main(string[] args) Console.WriteLine(testLib); } Console.WriteLine("."); - s_MainTestName = Path.GetFileNameWithoutExtension(s_testLibs[0]); + s_MainTestName = s_testAssemblies is not null + ? s_testAssemblies[0].GetName().Name + : Path.GetFileNameWithoutExtension(s_testLibs[0]); mono_ios_set_summary($"Starting tests..."); var simpleTestRunner = new SimpleTestRunner(verbose); @@ -108,11 +139,23 @@ public SimpleTestRunner(bool verbose) } } + [UnconditionalSuppressMessage("Trimming", "IL2026:RequiresUnreferencedCode", + Justification = "On NativeAOT s_testAssemblies is populated from AppDomain.CurrentDomain.GetAssemblies() and the Assembly.LoadFrom branch is never taken.")] protected override IEnumerable GetTestAssemblies() { - foreach (string file in s_testLibs) + if (s_testAssemblies is not null) + { + foreach (Assembly assembly in s_testAssemblies) + { + yield return new TestAssemblyInfo(assembly, assembly.GetName().Name! + ".dll"); + } + } + else { - yield return new TestAssemblyInfo(Assembly.LoadFrom(file), file); + foreach (string file in s_testLibs) + { + yield return new TestAssemblyInfo(Assembly.LoadFrom(file), file); + } } } @@ -129,7 +172,29 @@ protected override void TerminateWithSuccess() protected override string? IgnoreFilesDirectory => null; - protected override string IgnoredTraitsFilePath => "xunit-excludes.txt"; + protected override string IgnoredTraitsFilePath + { + get + { + string path = Path.Combine(AppContext.BaseDirectory, "xunit-excludes.txt"); + if (File.Exists(path)) + { + return path; + } + + string? appBase = Path.GetDirectoryName(AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar)); + if (appBase is not null) + { + string resourcesPath = Path.Combine(appBase, "Resources", "xunit-excludes.txt"); + if (File.Exists(resourcesPath)) + { + return resourcesPath; + } + } + + return string.Empty; + } + } public string BundleIdentifier => "net.dot." + s_MainTestName; diff --git a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/DirectoryInfo/Name.cs b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/DirectoryInfo/Name.cs index db948d4321ad51..2c8c49d4a14379 100644 --- a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/DirectoryInfo/Name.cs +++ b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/DirectoryInfo/Name.cs @@ -14,6 +14,7 @@ public void Ctor_NullArgument_Throws() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/127786", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsNativeAot))] public void CurrentDirectory() { var info = new DirectoryInfo("."); diff --git a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/File/Create.cs b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/File/Create.cs index 2eb894d5881bfc..36d778ef069429 100644 --- a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/File/Create.cs +++ b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/File/Create.cs @@ -34,6 +34,7 @@ public void NonExistentPath() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/127786", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsNativeAot))] public void CreateCurrentDirectory() { Assert.Throws(() => Create(".")); diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DoubleTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DoubleTests.cs index e567324ba71741..946ec2c12cda41 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DoubleTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DoubleTests.cs @@ -536,6 +536,7 @@ internal static string Reverse(string s) } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/127786", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsNativeAot))] public static void ParsePatterns() { string path = Directory.GetCurrentDirectory(); diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Reflection/ModuleTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Reflection/ModuleTests.cs index f3d92ac54d3241..785ef78babb545 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Reflection/ModuleTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Reflection/ModuleTests.cs @@ -82,6 +82,7 @@ public void CustomAttributes() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/123011", typeof(PlatformDetection), nameof(PlatformDetection.IsBrowser), nameof(PlatformDetection.IsCoreCLR))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/127786", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsNativeAot))] public void FullyQualifiedName() { #if SINGLE_FILE_TEST_RUNNER @@ -105,6 +106,7 @@ public void FullyQualifiedName() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/123011", typeof(PlatformDetection), nameof(PlatformDetection.IsBrowser), nameof(PlatformDetection.IsCoreCLR))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/127786", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsNativeAot))] public void Name() { #if SINGLE_FILE_TEST_RUNNER diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 4de29857494251..47049eb3ed6697 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -22,6 +22,11 @@ false false + + true + false @@ -525,6 +530,14 @@ + + + + + + + + @@ -536,7 +549,7 @@ - + @@ -585,7 +598,7 @@ - + @@ -698,6 +711,7 @@ Exclude="@(ProjectExclusions)" Condition="'$(TestAssemblies)' == 'true'" BuildInParallel="$(BuildTestInParallel)" /> + diff --git a/src/mono/msbuild/apple/build/AppleBuild.targets b/src/mono/msbuild/apple/build/AppleBuild.targets index ee15221fca821e..c3ed3e2b04e254 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.targets @@ -21,8 +21,6 @@ - @@ -96,6 +94,7 @@ <_AppleRuntimeConfigFilePath Condition="'$(_AppleRuntimeConfigFilePath)' == ''">$([MSBuild]::NormalizePath($(AppleBuildDir), '$(AssemblyName).runtimeconfig.json')) <_ParsedRuntimeConfigFilePath Condition="'$(_ParsedRuntimeConfigFilePath)' == ''">$([MSBuild]::NormalizePath($(AppleBuildDir), 'runtimeconfig.bin')) true + true diff --git a/src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj b/src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj index 30b9edf0ff4f0e..5070547f11d8c7 100644 --- a/src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj +++ b/src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj @@ -24,12 +24,13 @@ - + $(OriginalPublishDir) static true false + false @@ -47,30 +48,65 @@ + + + + + <_NativeAotLibraryTestOnHelix Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(_UseNativeAOTLibraryModeBundling)' != 'true' and '$(IncludesTestRunner)' != 'false'">true + + + + <_PrebuiltNativeAOTLib>$(OriginalPublishDir)lib$(AssemblyName).a + true + PrepareForAppleBuild;_PublishRuntimePack;_PrepareForAppleBuildAppOnHelix;_RunR2RCompilationOnHelix;_InitializeCommonProperties;_BeforeAppleBuild;_AppleResolveReferences;_StageNativeAotLinkInputsOnHelix;_AppleGenerateAppBundle;_AfterAppleBuild;_AfterAppleBuildOnHelix + + - - + + + + + <_NativeAotLinkInputsDir>$(OriginalPublishDir)nativeaot-link-inputs\ + + + + + + $(_PrebuiltNativeAOTLib) + + + <_NativeAotHelixLinkLibs Include="$(_NativeAotLinkInputsDir)*.a" + Exclude="$(_NativeAotLinkInputsDir)libRuntime.ServerGC.a;$(_NativeAotLinkInputsDir)libRuntime.VxsortEnabled.a;$(_NativeAotLinkInputsDir)libstandalonegc-enabled.a;$(_NativeAotLinkInputsDir)libeventpipe-enabled.a" /> + <_NativeAotHelixLinkLibs Include="$(_NativeAotLinkInputsDir)libbootstrapperdll.o" /> + + + + + + true - AppleTestRunner.dll + AppleTestRunner.dll + $(OriginalPublishDir) $(TestRootDir)AppBundle\ - - + - + <_ExtraFiles Include="$(ExtraFilesPath)**\*" /> @@ -90,6 +126,11 @@ 127.0.0.1:9000,nosuspend,listen + + + + + diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index 89d4f19a4102db..7dfb307c648343 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -277,8 +277,8 @@ public string GenerateCMake( { predefinedExcludes.Add(".dll"); predefinedExcludes.Add(".pdb"); - predefinedExcludes.Add(".json"); - predefinedExcludes.Add(".txt"); + predefinedExcludes.Add(".deps.json"); + predefinedExcludes.Add(".runtimeconfig.json"); predefinedExcludes.Add(".bin"); predefinedExcludes.Add(".dSYM"); }