-
-
Notifications
You must be signed in to change notification settings - Fork 222
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 .all
property with interleaved stdout and stderr
#171
Conversation
Added test cases for result.all intermixed output. Added fixtures/noop-132 which should output the sequence '123' but due to the unpredictable nature of the stdout/stderr it outputs '132' as the most common cases I've tried, as listed on noop-132, a different number of technique to make it predictable. On execa.sync, as it's using spawnSync internally, I couldn't get the stream and merge them. As such the output of result.all is just a concatenation of stdout + stderr. This makes the result.all in different use case (ex. async vs. sync) unreliable for string comparison, but at least useful for logging or checking on the output.
@ehmicky Would you be able to help review this? |
@@ -0,0 +1,14 @@ | |||
#!/usr/bin/env node |
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.
This does not test interleaving because stderr
is not in-between two stdout
calls.
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 was my mistake, I should have left it in-between and let the test fail. As I said in the comments I was testing various way to implement the test to be correct but I couldn't find one for all (more on this on the next conversation).
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.
Also I think it might be a good idea to do a more complex interleaving like stdout > stderr > stderr > stdout > stderr > stdout
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 think it needs to be more complex, if it works just once we should expect to interleave the rest of the outputs. Otherwise we know it's just concatenating the output strings.
From what I understand by the tests I'm doing is that we cannot guarantee the order of the interleaving.
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.
What do you think @sindresorhus?
Done! Also I think documentation would need to be added in the |
… nothing - execa.sync() cannot provide a true interleaved `all` stream because of the implementation of child_process.spawnSync, which does not expose `stdout` and `stderr` streams until termination. We could only concatenate the streams in the end. - Does not create the mixed stream if both streams do not exist.
The delay 6000ms is approximate, it may not work on every machine.
Can you fix the merge conflict? |
Ok, now I fixed it. I thought it was enough to fix them locally and then commit to remote. |
…132 (1000ms) Testing with test.serial and a delay of only 1000ms seems to pass multiple test runs consistently. Let's see if it passes on CI testing as well.
Shall I add an |
@tomsotte this seems like a good idea :) Thanks for your work on this, it's a very useful feature! |
Should errors have the |
Yes nice catch 👍 |
.all
result property with interleaved stdout/stderr
.all
result property with interleaved stdout/stderr.all
result property with interleaved stdout and stderr
.all
result property with interleaved stdout and stderr.all
property with interleaved stdout and stderr
Thanks for contributing, @tomsotte :) |
@tomsotte You need to submit the PR URL to IssueHunt to claim the bounty. |
Thanks to you both @sindresorhus and @ehmicky for patience and guiding me through the review :) |
@tomsotte thanks for this nice addition! |
Added test cases for
result.all
intermixed output.Added the fixture
noop-132
which should output the sequence123
(where13
comes from stdout and3
comes from stderr). Due to the unpredictable nature of the stdout/stderr it outputs132
as the most probable case.I've tried, as listed on
noop-132
, a different number of technique to make it predictable.On
execa.sync
, as it's usingspawnSync
internally, I couldn't get the stream and merge them.As such the output of result.all is just a concatenation of stdout + stderr.
This makes the result.all in different use case (ex. async vs. sync) unreliable for string comparison, but at least useful for logging or checking on the output.
Edit: Removed
result.all
onexeca.sync
, as it's just a concatenated stdout and stderr output, not very useful. Addedexeca.all()
similar toexeca.stdout()
. Addedall
in errors (only for async). Added documentation.Closes #1