Commit bdf5690a authored by Xavier Deguillard's avatar Xavier Deguillard Committed by Facebook GitHub Bot

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
parent cbe8ef9d
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment