-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Test suite: If the deprecation_exec
test fails, print the subcommand's stdout
and stderr
to the log
#46059
base: master
Are you sure you want to change the base?
Conversation
…d's `stdout` and `stderr` to the log
flags = Cmd(filter(a->!occursin("depwarn", a), collect(test_exeflags))) | ||
cmd = `$test_exename $flags --depwarn=yes deprecation_exec.jl` | ||
io = IOBuffer() | ||
pipln = pipeline(cmd; stdout=io, stderr=io) |
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'm away from computer and can't check myself: can you have stdout and stderr writing to the same buffer? It's nice if that just works, I guess it'd be similar to &>
redirection in shell.
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.
From a quick test, it seems to work fine.
julia> println(read("foo.jl", String))
println(stdout, "out1")
println(stderr, "err1")
println(stdout, "out2")
println(stderr, "err2")
println(stdout, "out3")
println(stderr, "err3")
julia> cmd = `julia foo.jl`;
julia> io = IOBuffer();
julia> run(pipeline(cmd; stdout=io, stderr=io));
julia> println(String(take!(io)))
out1
err1
out2
err2
out3
err3
julia>
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.
You are not allowed to use an IOBuffer as output, as such types are not stream-oriented, so they lack the required EOF capabilities. Use a BufferStream instead
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've switched this PR to use Base.BufferStream()
.
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.
@vtjnash Is it legal for me to send both stdout and stderr to the same BufferStream
? E.g.
io = Base.BufferStream()
run(pipeline(cmd; stdout=io, stderr=io))
close(io)
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.
Not really. It will result in the program getting 2 different streams, while you probably wanted it to get only one file description
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.
Hmmm. What's the correct way to capture the stdout
and stderr
from a command into a single string?
This should help a little bit when trying to diagnose failures in the
deprecation_exec
test set (e.g. the failures seen in #46039).