[LIT] Allow for executeCommand to take the stdin input.
authorEric Fiselier <eric@efcs.ca>
Sun, 19 Jul 2015 00:28:14 +0000 (00:28 +0000)
committerEric Fiselier <eric@efcs.ca>
Sun, 19 Jul 2015 00:28:14 +0000 (00:28 +0000)
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

llvm-svn: 242631

llvm/utils/lit/lit/util.py

index 08f7b71..a4233ba 100644 (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.