[PATCH] D20549: [lit] Use os.devnull instead of named temp files
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon May 23 18:22:08 PDT 2016
vsk created this revision.
vsk added reviewers: delcypher, ygao.
vsk added a subscriber: llvm-commits.
Use os.devnull instead of tempfiles when substituting '/dev/null' on Windows machines. This should make the bots just a bit speedier.
I'd appreciate it if someone could test this patch on Windows -- I don't have access to it.
http://reviews.llvm.org/D20549
Files:
utils/lit/lit/TestRunner.py
Index: utils/lit/lit/TestRunner.py
===================================================================
--- utils/lit/lit/TestRunner.py
+++ utils/lit/lit/TestRunner.py
@@ -20,9 +20,6 @@
# Don't use close_fds on Windows.
kUseCloseFDs = not kIsWindows
-# Use temporary files to replace /dev/null on Windows.
-kAvoidDevNull = kIsWindows
-
class ShellEnvironment(object):
"""Mutable shell environment containing things like CWD and env vars.
@@ -180,7 +177,6 @@
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.
@@ -243,8 +239,8 @@
result = subprocess.PIPE
else:
if r[2] is None:
- if kAvoidDevNull and r[0] == '/dev/null':
- r[2] = tempfile.TemporaryFile(mode=r[1])
+ if kIsWindows and r[0] == '/dev/null':
+ r[2] = open(os.devnull, r[1])
elif kIsWindows and r[0] == '/dev/tty':
# Simulate /dev/tty on Windows.
# "CON" is a special filename for the console.
@@ -293,14 +289,11 @@
if not executable:
raise InternalShellError(j, '%r: command not found' % j.args[0])
- # Replace uses of /dev/null with temporary files.
- if kAvoidDevNull:
+ # Replace uses of /dev/null with the Windows equivalent.
+ if kIsWindows:
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
+ args[i] = os.devnull
try:
procs.append(subprocess.Popen(args, cwd=cmd_shenv.cwd,
@@ -389,13 +382,6 @@
else:
exitCode = res
- # 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20549.58179.patch
Type: text/x-patch
Size: 2263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160524/75a8bdd5/attachment.bin>
More information about the llvm-commits
mailing list