summaryrefslogtreecommitdiff
path: root/utils/lit/lit
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-09-29 15:59:37 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-09-29 15:59:37 +0000
commit69c4cbe9e878e49aa87d322c63afd809588f4cd7 (patch)
treea1dffe28928af9214f36378cd40f2862aff42448 /utils/lit/lit
parent38e0b4689c2425ce3f1fdac15189f2c1234bc1cc (diff)
downloadllvm-69c4cbe9e878e49aa87d322c63afd809588f4cd7.tar.gz
llvm-69c4cbe9e878e49aa87d322c63afd809588f4cd7.tar.bz2
llvm-69c4cbe9e878e49aa87d322c63afd809588f4cd7.tar.xz
lit: Fix a subtle resource usage bug when executing tests using the internal
shell runner. We would inadvertently end up holding on to handles to the temporary files longer than we should have been. On Win32, where open handles lock some file operations, this caused problems in tests which would try to move temporary files around (as Clang does by default now). Many thanks to Francois Pichet for the excellent detective work on this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit/lit')
-rw-r--r--utils/lit/lit/TestRunner.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index 0eb51a8294..a2f97cdb5e 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -178,6 +178,13 @@ def executeShCmd(cmd, cfg, cwd, results):
else:
input = subprocess.PIPE
+ # Explicitly close any redirected files. We need to do this now because we
+ # need to release any handles we may have on the temporary files (important
+ # on Win32, for example). Since we have already spawned the subprocess, our
+ # handles have already been transferred so we do not need them anymore.
+ for f in opened_files:
+ f.close()
+
# FIXME: There is probably still deadlock potential here. Yawn.
procData = [None] * len(procs)
procData[-1] = procs[-1].communicate()
@@ -215,10 +222,6 @@ def executeShCmd(cmd, cfg, cwd, results):
else:
exitCode = res
- # Explicitly close any redirected files.
- for f in opened_files:
- f.close()
-
# Remove any named temporary files we created.
for f in named_temp_files:
try: