summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-06-12 16:00:10 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-06-12 16:00:10 +0000
commit1befb9b2df7b287872021518cedce4a0aeca3b95 (patch)
tree7eb0bb4e5c1c513fdc11c6611d6c270784d88e6f /utils
parent2a9a8ae0816dc2d6c2c53cce4ad8b033a60058d4 (diff)
downloadllvm-1befb9b2df7b287872021518cedce4a0aeca3b95.tar.gz
llvm-1befb9b2df7b287872021518cedce4a0aeca3b95.tar.bz2
llvm-1befb9b2df7b287872021518cedce4a0aeca3b95.tar.xz
lit: Replace /dev/null in scripts with temporary files on Windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/TestRunner.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index 495badb622..cdf1c938af 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -66,6 +66,7 @@ def executeShCmd(cmd, cfg, cwd, results):
input = subprocess.PIPE
stderrTempFiles = []
opened_files = []
+ named_temp_files = []
# To avoid deadlock, we use a single stderr stream for piped
# output. This is null until we have seen some output using
# stderr.
@@ -148,6 +149,15 @@ def executeShCmd(cmd, cfg, cwd, results):
if not args[0]:
raise InternalShellError(j, '%r: command not found' % j.args[0])
+ # Replace uses of /dev/null with temporary files.
+ if kAvoidDevNull:
+ for i,arg in enumerate(args):
+ if arg == "/dev/null":
+ f = tempfile.NamedTemporaryFile(delete=False)
+ f.close()
+ named_temp_files.append(f.name)
+ args[i] = f.name
+
procs.append(subprocess.Popen(args, cwd=cwd,
stdin = stdin,
stdout = stdout,
@@ -209,6 +219,13 @@ def executeShCmd(cmd, cfg, cwd, results):
for f in opened_files:
f.close()
+ # Remove any named temporary files we created.
+ for f in named_temp_files:
+ try:
+ os.remove(f)
+ except OSError:
+ pass
+
if cmd.negate:
exitCode = not exitCode