[llvm] r188356 - [lit] Move executeCommand() into lit.util.

Daniel Dunbar daniel at zuster.org
Tue Aug 13 22:07:01 PDT 2013


Author: ddunbar
Date: Wed Aug 14 00:07:01 2013
New Revision: 188356

URL: http://llvm.org/viewvc/llvm-project?rev=188356&view=rev
Log:
[lit] Move executeCommand() into lit.util.

Modified:
    llvm/trunk/utils/lit/lit/TestRunner.py
    llvm/trunk/utils/lit/lit/formats/base.py
    llvm/trunk/utils/lit/lit/formats/googletest.py
    llvm/trunk/utils/lit/lit/util.py

Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=188356&r1=188355&r2=188356&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Wed Aug 14 00:07:01 2013
@@ -25,25 +25,6 @@ kUseCloseFDs = not kIsWindows
 # Use temporary files to replace /dev/null on Windows.
 kAvoidDevNull = kIsWindows
 
-def executeCommand(command, cwd=None, env=None):
-    # Close extra file handles on UNIX (on Windows this cannot be done while
-    # also redirecting input).
-    close_fds = not kIsWindows
-
-    p = subprocess.Popen(command, cwd=cwd,
-                         stdin=subprocess.PIPE,
-                         stdout=subprocess.PIPE,
-                         stderr=subprocess.PIPE,
-                         env=env, close_fds=close_fds)
-    out,err = p.communicate()
-    exitCode = p.wait()
-
-    # Detect Ctrl-C in subprocess.
-    if exitCode == -signal.SIGINT:
-        raise KeyboardInterrupt
-
-    return out, err, exitCode
-
 def executeShCmd(cmd, cfg, cwd, results):
     if isinstance(cmd, ShUtil.Seq):
         if cmd.op == ';':
@@ -308,7 +289,8 @@ def executeScript(test, litConfig, tmpBa
             # run on clang with no real loss.
             command = litConfig.valgrindArgs + command
 
-    return executeCommand(command, cwd=cwd, env=test.config.environment)
+    return lit.util.executeCommand(command, cwd=cwd,
+                                   env=test.config.environment)
 
 def isExpectedFail(test, xfails):
     # Check if any of the xfails match an available feature or the target.

Modified: llvm/trunk/utils/lit/lit/formats/base.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/formats/base.py?rev=188356&r1=188355&r2=188356&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/formats/base.py (original)
+++ llvm/trunk/utils/lit/lit/formats/base.py Wed Aug 14 00:07:01 2013
@@ -3,7 +3,6 @@ import os
 import sys
 
 import lit.Test
-import lit.TestRunner
 import lit.util
 
 class FileBasedTest(object):
@@ -97,7 +96,7 @@ class OneCommandPerFileTest:
         else:
             cmd.append(test.getSourcePath())
 
-        out, err, exitCode = lit.TestRunner.executeCommand(cmd)
+        out, err, exitCode = lit.util.executeCommand(cmd)
 
         diags = out + err
         if not exitCode and not diags.strip():

Modified: llvm/trunk/utils/lit/lit/formats/googletest.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/formats/googletest.py?rev=188356&r1=188355&r2=188356&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/formats/googletest.py (original)
+++ llvm/trunk/utils/lit/lit/formats/googletest.py Wed Aug 14 00:07:01 2013
@@ -104,7 +104,7 @@ class GoogleTest(object):
         if litConfig.noExecute:
             return lit.Test.PASS, ''
 
-        out, err, exitCode = lit.TestRunner.executeCommand(
+        out, err, exitCode = lit.util.executeCommand(
             cmd, env=test.config.environment)
 
         if not exitCode:

Modified: llvm/trunk/utils/lit/lit/util.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/util.py?rev=188356&r1=188355&r2=188356&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/util.py (original)
+++ llvm/trunk/utils/lit/lit/util.py Wed Aug 14 00:07:01 2013
@@ -2,6 +2,8 @@ import errno
 import itertools
 import math
 import os
+import platform
+import signal
 import subprocess
 import sys
 
@@ -138,3 +140,20 @@ def printHistogram(items, title = 'Items
             pDigits, pfDigits, i*barH, pDigits, pfDigits, (i+1)*barH,
             '*'*w, ' '*(barW-w), cDigits, len(row), cDigits, len(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):
+    p = subprocess.Popen(command, cwd=cwd,
+                         stdin=subprocess.PIPE,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.PIPE,
+                         env=env, close_fds=kUseCloseFDs)
+    out,err = p.communicate()
+    exitCode = p.wait()
+
+    # Detect Ctrl-C in subprocess.
+    if exitCode == -signal.SIGINT:
+        raise KeyboardInterrupt
+
+    return out, err, exitCode





More information about the llvm-commits mailing list