From 6efba21342b15d7dc3185462868a606234e064f1 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 25 Oct 2009 01:37:26 +0000 Subject: [PATCH] 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 --- utils/lit/TestRunner.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/lit/TestRunner.py b/utils/lit/TestRunner.py index 356632e92f3..a2a9e3629ca 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) -- 2.34.1