CI fix for native aot tests (#69571)
authorLakshan Fernando <lakshanf@hotmail.com>
Tue, 31 May 2022 10:47:41 +0000 (03:47 -0700)
committerGitHub <noreply@github.com>
Tue, 31 May 2022 10:47:41 +0000 (03:47 -0700)
* 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ý <MichalStrehovsky@users.noreply.github.com>
docs/workflow/building/coreclr/nativeaot.md
src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.GetMember.cs
src/libraries/Common/tests/SingleFileTestRunner/SingleFileTestRunner.cs
src/libraries/tests.proj

index 4c9646a..6dd0c19 100644 (file)
@@ -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
 
index e79e6c0..439343d 100644 (file)
@@ -124,7 +124,7 @@ namespace System.Reflection.Runtime.TypeInfos
                 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)
             {
index 7b67a13..06ef423 100644 (file)
@@ -51,8 +51,28 @@ public class SingleFileTestRunner : XunitTestFramework
         var discoverer = xunitTestFx.CreateDiscoverer(asmInfo);
         discoverer.Find(false, discoverySink, TestFrameworkOptions.ForDiscovery());
         discoverySink.Finished.WaitOne();
+
         XunitFilters filters = new XunitFilters();
-        filters.ExcludedTraits.Add("category", new List<string> { "failing" });
+        // Quick hack wo much validation to get no traits passed
+        Dictionary<string, List<string>> noTraits = new Dictionary<string, List<string>>();
+        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<string> values))
+                {
+                    noTraits.Add(traitKeyValue[0], values = new List<string>());
+                }
+                values.Add(traitKeyValue[1]);
+            }
+        }
+
+        foreach (KeyValuePair<string, List<string>> 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());
index 9f8e863..f136165 100644 (file)
     <!-- Run only a small randomly chosen set of passing test suites -->
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)*\tests\**\*.Tests.csproj" />
     <ProjectExclusions Remove="$(MSBuildThisFileDirectory)System.Collections\tests\System.Collections.Tests.csproj" />
+    <ProjectExclusions Remove="$(MSBuildThisFileDirectory)System.Reflection\tests\System.Reflection.Tests.csproj" 
+                       Condition="'$(TargetOS)' == 'windows'" />
     <ProjectExclusions Remove="$(MSBuildThisFileDirectory)System.Runtime\tests\System.Runtime.Tests.csproj" />
   </ItemGroup>