Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 an option to put WinAppDriver output in a file #151
Add an option to put WinAppDriver output in a file #151
Changes from 1 commit
ae76c1e
411f9df
5279f86
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion for more compact
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not set these handles to
INVALID_HANDLE_VALUE
becauseINVALID_HANDLE_VALUE
(= -1 = 0xfff...) is not actually invalid but is the current process handle. So here, we use the current process input/output handles as a fallback, which makes theredirectStdHandle
logic more complex than it should be.GetStdHandle()
will returnNULL
if the standard input/output devices have been closed, which is also a valid value to set thestdoutHandle
option to if you don't want the child process to write anything, for instance. IIUCNULL HANDLE
(=0) is a different value from Swiftnil
, since thestdoutHandle
in theProcessLaunchOptions
struct is an optional.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this preserve the old behavior if we only set some of the handles? Should we force callers to either override all handles, or none?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep the stdin write handle until here if just to close it? And since we have it, we could send
\n
for nicer termination since WinAppDriver awaits one:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we close the handle, this closes
stdin
for theWinAppDriver
process, which causes the process to shut down. That's why we need to keep it open until the process shuts down. While we could use that as a proxy to shut downWinAppDriver
in a cleaner manner, we only havechildStdinHandle
set up if we redirect the output to a file. I'm not opposed to changing the logic but then we have no way of redirecting the output to the spawned terminal to preserve API compatibility.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does WinAppDriver write as utf-16 when redirected to a file? That's unusual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It writes UTF-16 either way. It's usually not noticeable because Windows Terminal handles either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terminals are supposed to decode stdout according to the
GetConsoleOutputCP()
of the console, so outputting UTF-16 would result in garbled contents. 🤔🤔🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably witchcraft involved:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if that's a valid test but it is puzzling!