[PATCH] D117179: [lit] Make sure our test temp directory is actually used by tests

Julian Lettner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 12 19:13:40 PST 2022


yln created this revision.
yln added a reviewer: mstorsjo.
Herald added a subscriber: delcypher.
yln requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

All credit to Martin Storsjö (mstorsjo) who describes the issue here:
https://github.com/llvm/llvm-project/issues/53167


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117179

Files:
  llvm/utils/lit/lit/main.py


Index: llvm/utils/lit/lit/main.py
===================================================================
--- llvm/utils/lit/lit/main.py
+++ llvm/utils/lit/lit/main.py
@@ -245,13 +245,11 @@
     tmp_dir = None
     if 'LIT_PRESERVES_TMP' not in os.environ:
         import tempfile
-        tmp_dir = tempfile.mkdtemp(prefix="lit_tmp_")
-        os.environ.update({
-                'TMPDIR': tmp_dir,
-                'TMP': tmp_dir,
-                'TEMP': tmp_dir,
-                'TEMPDIR': tmp_dir,
-                })
+        tmp_dir = tempfile.mkdtemp(prefix='lit_tmp_')
+        tmp_dir_envs = {k: tmp_dir for k in ['TMP', 'TMPDIR', 'TEMP', 'TEMPDIR']}
+        os.environ.update(tmp_dir_envs)
+        for cfg in {t.config for t in run.tests}:
+            cfg.environment.update(tmp_dir_envs)
     try:
         run.execute()
     finally:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117179.399530.patch
Type: text/x-patch
Size: 849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/ca14b74a/attachment.bin>


More information about the llvm-commits mailing list