1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-07 07:02:53 +03:00

runcmd: do not pipe stdout on a tty

Summary:
Redirecting stdout means that ninja/cmake won't act as if it's invoked
interactively, ie: it will buffer the output, show every single files being
compiled (instead of just a line or progress), etc. This results in a fairly
janky UX when getdeps is used on the command line. By not redirecting stdout,
we get immediate feedback about the tests being run, and the files being
compiled.

Reviewed By: wez

Differential Revision: D22967815

fbshipit-source-id: 872ddbf421065686c384a3a876d0acb8832baf2e
This commit is contained in:
Xavier Deguillard
2020-08-06 13:10:53 -07:00
committed by Facebook GitHub Bot
parent 6743036750
commit 8616ea5f82

View File

@@ -95,9 +95,15 @@ def _run_cmd(cmd, env, cwd, allow_fail, log_fn):
log_fn("+ %s\n" % cmd_str)
isinteractive = os.isatty(sys.stdout.fileno())
if isinteractive:
stdout = None
else:
stdout = subprocess.PIPE
try:
p = subprocess.Popen(
cmd, env=env, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
cmd, env=env, cwd=cwd, stdout=stdout, stderr=subprocess.STDOUT
)
except (TypeError, ValueError, OSError) as exc:
log_fn("error running `%s`: %s" % (cmd_str, exc))
@@ -106,7 +112,8 @@ def _run_cmd(cmd, env, cwd, allow_fail, log_fn):
% (str(exc), cmd_str, env, os.environ)
)
_pipe_output(p, log_fn)
if not isinteractive:
_pipe_output(p, log_fn)
p.wait()
if p.returncode != 0 and not allow_fail: