From c9742b32bae35fd546f6ed844d48ccf195626ba7 Mon Sep 17 00:00:00 2001 From: Lakshan Fernando Date: Tue, 31 May 2022 03:47:41 -0700 Subject: [PATCH] CI fix for native aot tests (#69571) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CI fix for native aot tests * parse notrait commandline args * try a different platform * FB * Remove unnecessary whitespace change These make `git blame` harder to follow. Plus the consistent thing in this file is no extra newline here. Co-authored-by: Michal Strehovský --- docs/workflow/building/coreclr/nativeaot.md | 2 +- .../TypeInfos/RuntimeTypeInfo.GetMember.cs | 2 +- .../SingleFileTestRunner.cs | 22 ++++++++++++++++++- src/libraries/tests.proj | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/workflow/building/coreclr/nativeaot.md b/docs/workflow/building/coreclr/nativeaot.md index 4c9646a76d6d8..6dd0c196ede10 100644 --- a/docs/workflow/building/coreclr/nativeaot.md +++ b/docs/workflow/building/coreclr/nativeaot.md @@ -78,7 +78,7 @@ Sometimes it's handy to be able to rebuild the managed test manually or run the For more advanced scenarios, look for at [Building Test Subsets](../../testing/coreclr/windows-test-instructions.md#building-test-subsets) and [Generating Core_Root](../../testing/coreclr/windows-test-instructions.md#generating-core_root) ### Running library tests -Build library tests by passing the `libs.tests` subset together with the `/p:TestNativeAot=true` to build the libraries, i.e. `clr.alljits+clr.tools+clr.nativeaotlibs+clr.nativeaotruntime+libs+libs.tests /p:TestNativeAot=true` together with the full arguments as specified [above](#building). Then, to run a specific library, go to the tests directory of the library and run the usual command to run tests for the library (see [Running tests for a single library](../../testing/libraries/testing.md#running-tests-for-a-single-library)) but add the `/p:TestNativeAot=true`, i.e. `dotnet.cmd build /t:Test /p:TestNativeAot=true`. +Build library tests by passing the `libs.tests` subset together with the `/p:TestNativeAot=true` to build the libraries, i.e. `clr.alljits+clr.tools+clr.nativeaotlibs+clr.nativeaotruntime+libs+libs.tests /p:TestNativeAot=true` together with the full arguments as specified [above](#building). Then, to run a specific library, go to the tests directory of the library and run the usual command to run tests for the library (see [Running tests for a single library](../../testing/libraries/testing.md#running-tests-for-a-single-library)) but add the `/p:TestNativeAot=true` and the build configuration that was used, i.e. `dotnet.cmd build /t:Test /p:TestNativeAot=true -c Release`. ## Design Documentation diff --git a/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs b/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs index e79e6c0b7092c..439343d33027b 100644 --- a/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs +++ b/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs @@ -124,7 +124,7 @@ public sealed override MemberInfo GetMemberWithSameMetadataDefinitionAs(MemberIn throw new ArgumentNullException(nameof(member)); // Need to walk up the inheritance chain if member is not found - // Leverage the existing cache mechanism of per type to store members + // Leverage the existing cache mechanism on per type to store members RuntimeTypeInfo? runtimeType = this; while (runtimeType != null) { diff --git a/src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs b/src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs index 7b67a1338e5a6..06ef4237f4d4e 100644 --- a/src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs +++ b/src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs @@ -51,8 +51,28 @@ public static int Main(string[] args) var discoverer = xunitTestFx.CreateDiscoverer(asmInfo); discoverer.Find(false, discoverySink, TestFrameworkOptions.ForDiscovery()); discoverySink.Finished.WaitOne(); + XunitFilters filters = new XunitFilters(); - filters.ExcludedTraits.Add("category", new List { "failing" }); + // Quick hack wo much validation to get no traits passed + Dictionary> noTraits = new Dictionary>(); + for (int i = 0; i < args.Length; i++) + { + if (args[i].Equals("-notrait", StringComparison.OrdinalIgnoreCase)) + { + var traitKeyValue=args[i + 1].Split("=", StringSplitOptions.TrimEntries); + if (!noTraits.TryGetValue(traitKeyValue[0], out List values)) + { + noTraits.Add(traitKeyValue[0], values = new List()); + } + values.Add(traitKeyValue[1]); + } + } + + foreach (KeyValuePair> kvp in noTraits) + { + filters.ExcludedTraits.Add(kvp.Key, kvp.Value); + } + var filteredTestCases = discoverySink.TestCases.Where(filters.Filter).ToList(); var executor = xunitTestFx.CreateExecutor(asmName); executor.RunTests(filteredTestCases, resultsSink, TestFrameworkOptions.ForExecution()); diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 9f8e863593a1b..f13616534e897 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -392,6 +392,8 @@ +