# 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 == ';':
# 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.
import sys
import lit.Test
-import lit.TestRunner
import lit.util
class FileBasedTest(object):
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():
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:
import itertools
import math
import os
+import platform
+import signal
import subprocess
import sys
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