Repository navigation
Closed
Labels
state/in-prA PR is open for this issue.
Description
Happening in 1.4.0-preview.24422.11.
Stacktrace:
Error: Unhandled exception. System.ObjectDisposedException: The CancellationTokenSource has been disposed.
at System.Threading.CancellationTokenSource.Cancel()
at Microsoft.Testing.Platform.OutputDevice.Terminal.TestProgressStateAwareTerminal.StopShowingProgress() in /_/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestProgressStateAwareTerminal.cs:line 108
at Microsoft.Testing.Platform.OutputDevice.Terminal.TerminalTestReporter.TestExecutionCompleted(DateTimeOffset endTime) in /_/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs:line 178
at Microsoft.Testing.Platform.OutputDevice.TerminalOutputDevice.DisplayAfterSessionEndRunAsync() in /_/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs:line 293
at Microsoft.Testing.Platform.Hosts.CommonTestHost.DisplayAfterSessionEndRunAsync(IPlatformOutputDevice outputDevice, ITestSessionContext sessionInfo, CancellationToken cancellationToken) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 151
at Microsoft.Testing.Platform.Hosts.CommonTestHost.ExecuteRequestAsync(IPlatformOutputDevice outputDevice, ITestSessionContext testSessionInfo, ServiceProvider serviceProvider, BaseMessageBus baseMessageBus, ITestFramework testFramework, ClientInfo client) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 132
at Microsoft.Testing.Platform.Hosts.ConsoleTestHost.InternalRunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/ConsoleTestHost.cs:line 88
at Microsoft.Testing.Platform.Hosts.ConsoleTestHost.InternalRunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/ConsoleTestHost.cs:line 120
at Microsoft.Testing.Platform.Hosts.CommonTestHost.RunTestAppAsync(CancellationToken testApplicationCancellationToken) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 76
at Microsoft.Testing.Platform.Hosts.CommonTestHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 38
at Microsoft.Testing.Platform.Hosts.CommonTestHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 59
at Microsoft.Testing.Platform.Builder.TestApplication.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs:line 240
at TestingPlatformEntryPoint.Main(String[] args) in /_/tools/tunit-nuget-tester/TUnit.NugetTester/TUnit.NugetTester/obj/Debug/net8.0/TestPlatformEntryPoint.cs:line 16
at TestingPlatformEntryPoint.<Main>(String[] args)
Metadata
Metadata
Assignees
Labels
state/in-prA PR is open for this issue.
Activity
nohwnd commentedon Aug 26, 2024
Is this during abort? Or it just randomly happens?
thomhurst commentedon Aug 26, 2024
Seems to be just random.
nohwnd commentedon Aug 27, 2024
I can't reproduce, I've run big test projects, small test projects, test projects with 0 tests. each I ran for 100 times and never seen the erro. I also tried aborting. Can your reproduce this regularly? Is the project public so I can try?
And what is the tfm? I tried net framework and net8
thomhurst commentedon Aug 27, 2024
Weird - I'm getting it every time.
The repro is using my framework - Hope it's still useful though.
dotnet runNuGet packages are attached here: TUnit.zip
Should be able to put them in a local folder and add that as a nuget source
nohwnd commentedon Aug 27, 2024
You are registering our output device in AddFromFrameworkServiceProvider and you are disposing the service provider (along with all disposable registered services), in TUnitTestFramework.ExecuteRequestAsync -> serviceProvider.DisposeAsync();
This will dispose the output device before we are done completing the run, and hence the crash.
Please don't dispose our service, or wrap it in a dummy object that will not call the Dispose.
thomhurst commentedon Aug 27, 2024
Ah my bad. Thanks for spotting that! An oversight on my part that if they're registered in my service provider it'll try and dispose them. I'll tidy this up! Sorry for the issue
nohwnd commentedon Aug 27, 2024
No problem!