Allow for custom stdout/stderr/stdin streams when instantiating a Command.
Review Request #12242 — Created April 20, 2022 and submitted
Command
now takesstdout
,stderr
, andstdin
arguments. These are
expected, in the case of custom streams, to beio.TextIOWrapper
instances, wrapping aio.BytesIO
.The standard and JSON output wrappers on
Command
instances will wrap
these instead of assuming the versions onsys
. The log stream will
wrapstderr
as well (it normally defaults tosys.stderr
), ensuring
that all logs are, by default, outputted to that stream. This can, as
always, be overridden with a more explicit logging setup if automating
RBTools.There's also
*_is_atty
attributes computed for each of these streams
when instantiating. These replace the previous.isatty()
checks, and
are more robust, handling the case where this attribute is missing.This will be used for unit tests that need to capture command output or
simulate input.
Tested running RBTools commands on Python 2, 3.6, and 3.10. Checked
default stdout, stderr, and stdin functionality.Made use of this in upcoming unit test support. Verified that I could
override the streams successfully on all supported versions of Python
and grab the resulting output (or supply the resulting input).
Summary | ID |
---|---|
1891eb211adc0b85e90840c1e890dcc133ddee54 |