CTRL+C does not complete the test run when there is long running test #5345
Labels
Area: MSTest
Issues with MSTest that are not specific to more refined area (e.g. analyzers or assertions)
Area: MTP
Belongs to the Microsoft.Testing.Platform core library
Describe the bug
Running a project with test that takes long time or infinite time will not return control to the user in timely manner when they press Ctrl+C.
MTP does cooperative cancellation, and leaves the details to the test framework, and MSTest (and NUnit) do block the returning on main method, until the currently running test completes.
Steps To Reproduce
Have single test that sleeps for 10s.
Run tests as exe and cancel by pressing Ctrl+C.
Cancelling test session message is shown, but we still wait 10s for the test to finish.
Expected behavior
Run is cancelled / aborted.
Actual behavior
Described above.
Additional context
To solve this we agreed to implement a 2 stage approach. When user presses CTRL+C we will start cancelling the session. This is up to the test framework to handle. MTP will only cooperatively cancel the framework, and if the framework does not return control we cannot do anything.
The framework is free to abandon the test work, and continue to cleanup. To ensure fast cancellation. And cleanup.
We will also output message to Press Ctrl+C again to abort.
When user does that we will kill the process, to ensure timely return of control. But we won't guarantee any cleanup.
The text was updated successfully, but these errors were encountered: