diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-31 18:48:43 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-31 18:48:43 +0000 |
commit | c3681d334af978e066c4fdbfcadda492585ef338 (patch) | |
tree | b0821a7d03923a5029d78a1d89197105478db4db /utils/lit | |
parent | 5e1b55d67288874f8669621b9176814ce449f8f5 (diff) | |
download | external_llvm-c3681d334af978e066c4fdbfcadda492585ef338.zip external_llvm-c3681d334af978e066c4fdbfcadda492585ef338.tar.gz external_llvm-c3681d334af978e066c4fdbfcadda492585ef338.tar.bz2 |
lit: Make sure to close any files we open as part of redirection.
PR6753.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rw-r--r-- | utils/lit/lit/TestRunner.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py index 29adff2..5d008de 100644 --- a/utils/lit/lit/TestRunner.py +++ b/utils/lit/lit/TestRunner.py @@ -63,6 +63,7 @@ def executeShCmd(cmd, cfg, cwd, results): procs = [] input = subprocess.PIPE stderrTempFiles = [] + opened_files = [] # To avoid deadlock, we use a single stderr stream for piped # output. This is null until we have seen some output using # stderr. @@ -115,6 +116,7 @@ def executeShCmd(cmd, cfg, cwd, results): # Workaround a Win32 and/or subprocess bug when appending. if r[1] == 'a': r[2].seek(0, 2) + opened_files.append(r[2]) result = r[2] final_redirects.append(result) @@ -176,7 +178,7 @@ def executeShCmd(cmd, cfg, cwd, results): else: err = '' procData[i] = (out,err) - + # Read stderr out of the temp files. for i,f in stderrTempFiles: f.seek(0, 0) @@ -199,6 +201,10 @@ def executeShCmd(cmd, cfg, cwd, results): else: exitCode = res + # Explicitly close any redirected files. + for f in opened_files: + f.close() + if cmd.negate: exitCode = not exitCode |