microsoft / testfx

MSTest framework and adapter
MIT License
736 stars 254 forks source link

--info argument for native AoT tests throws an exception #3096

Closed martincostello closed 4 months ago

martincostello commented 4 months ago

Describe the bug

A KeyNotFoundException occurs when running a native AoT test program when passed the --info argument.

Steps To Reproduce

  1. Clone https://github.com/martincostello/alexa-london-travel/commit/e01e8824970437d9fc767a6db40e4e6701bdeb29
  2. Open the test/LondonTravel.Skill.NativeAotTests directory in the terminal
  3. Run dotnet run -- --info

Expected behavior

No exception is shown and the process exits with an exit code of 0.

Actual behavior

The process exits with an exit code of -532462766 and prints the following at the end of the console output:

<SNIP - Lots of other output before this>

Registered tools:
  TrxCompareTool
    Command: ms-trxcompare
    Name: TRX comparer tool
    Version: 1.2.1
    Description: This tool allows to compare and highights differences between 2 TRX reports
    Tool command line providers:
Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'ms-trxcompare' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Microsoft.Testing.Platform.CommandLine.CommandLineHandler.<PrintInfoAsync>g__DisplayRegisteredToolsInfoAsync|36_5(ITool[] availableTools, List`1 toolExtensions) in /_/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineHandler.cs:line 572
   at Microsoft.Testing.Platform.CommandLine.CommandLineHandler.PrintInfoAsync(ITool[] availableTools) in /_/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineHandler.cs:line 440
   at Microsoft.Testing.Platform.Hosts.TestHostBuilder.BuildAsync(String[] args, ApplicationLoggingState loggingState, TestApplicationOptions testApplicationOptions, IUnhandledExceptionsHandler unhandledExceptionsHandler, DateTimeOffset createBuilderStart) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs:line 296
   at Microsoft.Testing.Platform.Builder.TestApplicationBuilder.BuildAsync() in /_/src/Platform/Microsoft.Testing.Platform/Builder/TestApplicationBuilder.cs:line 113
   at TestingPlatformEntryPoint.Main(String[] args) in C:\Coding\martincostello\alexa-london-travel\artifacts\obj\LondonTravel.Skill.NativeAotTests\debug\TestPlatformEntryPoint.cs:line 17
   at TestingPlatformEntryPoint.<Main>(String[] args)

Additional context

Found while trying to work out how to get tests to either timeout or blame hangs before opening #3095.

MarcoRossignoli commented 4 months ago

Thanks for reporting it

Evangelink commented 4 months ago

I can repro even in non NAOT mode. This repros only when using MSTest.Sdk and not when using metapackage or regular packages.