Skip to content

Conversation

@avodovnik
Copy link
Contributor

No description provided.

@avodovnik avodovnik requested a review from kblok May 24, 2021 16:11
pwProcess.Start();

pwProcess.WaitForExit();
Console.WriteLine(pwProcess.StandardOutput.ReadToEnd());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should inherit stdio streams to get incremental input/output/errors, instead of writing something at the end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need that having RedirectStandardOutput set to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kblok the default is false - so I think we do, if we want to see the input/output

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry. I mean, if we have RedirectStandardOutput = true do we need to write the output to the console. Doesn't RedirectStandardOutput do that for us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I assumed that too, but it didn't. I'll give it another go, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh, look at that, turns out you have to call BeginOutputReadLine, to get anything on the event handlers :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done, now. For now, I'm assuming that what I get is a direct WriteLine, so I don't support some scenarios, like the app clearing the output. But I think this will be fine for v1.


private static string GetFullPath()
{
string envPath = Environment.GetEnvironmentVariable(DriverEnvironmentPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Who sets this env variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would be the user calling the tool. If there's none set, we get a null and do fallback.

README.md Outdated

### Driver Discoverability

By default, the tool will attempt to look at `%USERPROFILE%\.nuget\packages\microsoft.playwright` for the location of the driver. If that behaviour
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the tool pick up Playwright from my project, if I am at src/?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the behaviour and doc now:

  • traverse current folder and find .playwright
  • NuGet cache

pwProcess.BeginOutputReadLine();
pwProcess.BeginErrorReadLine();

pwProcess.WaitForExit();
Copy link
Contributor

Choose a reason for hiding this comment

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

Stackoverflow says this is going to block, and so we won't see live updates. Perhaps we should await for process.Exited event to unblock the thread so it can perform live streaming of the output? I am also not sure what WaitOne(5000) is for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'll block the calling thread, yes, but it launches the process from a different thread and the callbacks happen on other threads:

image

The WaitOne is to ensure that we don't make the same mistake as our tests did initially - disposing stuff before we get all the content. We either wait for null to be sent as the payload, when the stream is done, or 5 seconds after the process exited which likely means there was a problem in the stream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, the Process implementation uses AsyncStreamReader underneath, and that queues the work using this.

So, it's possible that we get a piece of text dispatched when the call to WaitForExit already returns - hence the AutoResetEvent :-).

@pavelfeldman pavelfeldman merged commit fbe7ebb into microsoft:main May 27, 2021
@avodovnik avodovnik deleted the dev/anvod/cli/attempt branch June 11, 2021 12:15
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