Skip to content

When using TCP transport, StopRun is never received #1187

@CharliePoole

Description

@CharliePoole

NOTE: I'm calling this a bug, because it is one, but some of the fallout may lead to major changes to our basic runner interfaces. So I'm looking for comments from @nunit/engine-team before I actually do anything.

Up to now, we have been dealing with the problem of cancelling a run using StopRun(true) as it relates to .NET Core not supporting killing threads. However, I just discovered an additional problem: when we use the TCP transport, the StopRun command can't be received while the test is running.

The reason for this is that the command loop, which receives and executes commands, runs those commands synchronously. So the command to stop the run won't be seen until the run has already completed. One fix for this - maybe the easiest - would be for the command-loop to create a task to run the tests when the Run command is received.

Thinking about it a bit more, I wondered what would happen if we used RunAsync instead of Run, so I did an experiment. It didn't work and I still saw synchronous Run commands being issued. I realized (or reminded myself) that MasterTestRunner translates RunAsync into a task, which basically calls Run. None of the lower-level runners RunAsync methods are ever actually used.

I'm sure we (or I) had a good reason for this back in the day, but right now it doesn't make much sense. We should either not have lower-level RunAsync methods or we should actually use them. That's one of the big decisions I think we should make as a team.

Of course, this also gets into the interfaces we use in 4.0, which we have never finalized. I'm currently thinking that we should eliminate RunAsync from ITestRunner and make Run an async method. The calling runner could then decide whether or not to await the call.
That gets beyond the scope of a bug, of course, but we should keep in mind what we ultimately want to have as we work this issue.

@rprouse @jnm2 @mikkelbu @manfred-brands What do you think? Where should we go with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugHigh PriorityV4All issues related to V4 or later - use -label:V4 to get V3 issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions