diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-10-25 01:37:26 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-10-25 01:37:26 +0000 |
commit | 6efba21342b15d7dc3185462868a606234e064f1 (patch) | |
tree | 5112b5ae484d72fa4bcfb85777073347e2c29a72 /utils/lit/TestRunner.py | |
parent | 07d4964d1fc10a404f9bafd7c30b46322fe9293f (diff) |
lit: Allow use of /dev/null in redirects on Windows (replace by a temporary
file).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit/TestRunner.py')
-rw-r--r-- | utils/lit/TestRunner.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/utils/lit/TestRunner.py b/utils/lit/TestRunner.py index 356632e92f..a2a9e3629c 100644 --- a/utils/lit/TestRunner.py +++ b/utils/lit/TestRunner.py @@ -15,6 +15,10 @@ class InternalShellError(Exception): # Don't use close_fds on Windows. kUseCloseFDs = platform.system() != 'Windows' + +# Use temporary files to replace /dev/null on Windows. +kAvoidDevNull = platform.system() == 'Windows' + def executeCommand(command, cwd=None, env=None): p = subprocess.Popen(command, cwd=cwd, stdin=subprocess.PIPE, @@ -104,7 +108,10 @@ def executeShCmd(cmd, cfg, cwd, results): result = subprocess.PIPE else: if r[2] is None: - r[2] = open(r[0], r[1]) + if kAvoidDevNull and r[0] == '/dev/null': + r[2] = tempfile.TemporaryFile(mode=r[1]) + else: + r[2] = open(r[0], r[1]) result = r[2] final_redirects.append(result) |