From 1befb9b2df7b287872021518cedce4a0aeca3b95 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 12 Jun 2010 16:00:10 +0000 Subject: 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 --- utils/lit/lit/TestRunner.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 -- cgit v1.2.3