Skip to content

CTRL+C does not complete the test run when there is long running test #5345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nohwnd opened this issue Mar 31, 2025 · 1 comment
Open
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

Comments

@nohwnd
Copy link
Member

nohwnd commented Mar 31, 2025

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.

Image

Image

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.

@nohwnd
Copy link
Member Author

nohwnd commented Mar 31, 2025

attempts at roughly fixing this in MTP and mstest here #5267 and here #5288

Work needed is to connect ctrl+c to the test session cancellation for the cancel, and to env failfast for abort.

@nohwnd nohwnd added Area: MTP Belongs to the Microsoft.Testing.Platform core library Area: MSTest Issues with MSTest that are not specific to more refined area (e.g. analyzers or assertions) labels Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant