Skip to content

Commit

Permalink
CI fix for native aot tests (dotnet#69571)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
LakshanF and MichalStrehovsky committed May 31, 2022
1 parent 726f5e8 commit c9742b3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/workflow/building/coreclr/nativeaot.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<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());
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@
<!-- 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>

Expand Down

0 comments on commit c9742b3

Please sign in to comment.