Skip to content
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

Add exit call back to custom test host process #1358

Merged
merged 5 commits into from
Jan 5, 2018

Conversation

smadala
Copy link
Contributor

@smadala smadala commented Jan 4, 2018

Description

  • TcpClient.Poll() not throwing the exception on testhost process exit if testhost process have child process like geckodriver.exe(Which do some socket operations), but normal processes ( notepad.exe, etc..).
  • Don't just relay on TcpClient.Poll(), Have process exit call back for custom testhost.

Related issue

@smadala smadala requested a review from codito January 4, 2018 12:29
@codito
Copy link
Contributor

codito commented Jan 4, 2018 via email

@smadala
Copy link
Contributor Author

smadala commented Jan 4, 2018

In normal debug stop scenario, TcpClient.Poll() throwing IOException(remote host closed the connection...). Because there was no exitcall back we wait for 10 sec(Which causes #1183) to avoid race condition between communication break and exit callback.

dependent on child process or the debugger attached?

Indefinite time on child process case, 10s on debugger attached.

Why the additional arg in exit callback?

Sometimes call back depends on exit code of process. I choose one method rather than adding overload method.

@@ -90,7 +90,7 @@ public interface IProcessHelper
/// <param name="callbackAction">
/// Callback on process exit.
/// </param>
void SetExitCallback(int processId, Action callbackAction);
void SetExitCallback(int processId, Action<object> callbackAction);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object [](start = 51, length = 6)

explicitly as Process or have an eventArgs..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Process API's are not available in UWP, using it explicitly here would mean we cannot built uwp platform abstraction.

{
var process = Process.GetProcessById(processId);
process.EnableRaisingEvents = true;
process.Exited += (sender, args) => callbackAction.Invoke(process);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callbackAction.Invoke(process); [](start = 52, length = 31)

if there's a process crash before the hookup.. call the handler..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@cltshivash cltshivash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

{
var process = Process.GetProcessById(processId);
process.EnableRaisingEvents = true;
process.Exited += (sender, args) => callbackAction.Invoke(process);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codito
Copy link
Contributor

codito commented Jan 4, 2018

Looks good. Please cover LUT, UWP scenarios explicitly. These may listen to testhost process exit as well. So depending on which event callback is called, good to validate there are no race/premature cleanup conditions possible.

Also good to cover cases where the debugged testhost produces bunch of stdout/stderr messages.

@smadala smadala merged commit 8d8d744 into microsoft:master Jan 5, 2018
@smadala smadala deleted the testhost-crash-while-debug branch January 5, 2018 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants