[LIT] Allow for executeCommand to take the stdin input.

Summary: This patch allows executeCommand to pass a string to the processes stdin.

Reviewers: ddunbar, jroelofs

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D11332

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242631 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier 2015-07-19 00:28:14 +00:00
parent 9549a0c0bc
commit 4ec433f504

View File

@ -48,7 +48,7 @@ def mkdir_p(path):
if not path or os.path.exists(path):
return
parent = os.path.dirname(path)
parent = os.path.dirname(path)
if parent != path:
mkdir_p(parent)
@ -158,13 +158,13 @@ def printHistogram(items, title = 'Items'):
# Close extra file handles on UNIX (on Windows this cannot be done while
# also redirecting input).
kUseCloseFDs = not (platform.system() == 'Windows')
def executeCommand(command, cwd=None, env=None):
def executeCommand(command, cwd=None, env=None, input=None):
p = subprocess.Popen(command, cwd=cwd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env, close_fds=kUseCloseFDs)
out,err = p.communicate()
out,err = p.communicate(input=input)
exitCode = p.wait()
# Detect Ctrl-C in subprocess.