From 0f6f6284d733f44c9a1186a949b845c40b272ca6 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Wed, 12 Jan 2022 19:06:20 -0800 Subject: [PATCH] [lit] Make sure our test temp directory is actually used by tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All credit to Martin Storsjö (mstorsjo) who describes the issue here: https://github.com/llvm/llvm-project/issues/53167 Differential Revision: https://reviews.llvm.org/D117179 --- llvm/utils/lit/lit/main.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py index 73747360601a..99777eef8ec0 100755 --- a/llvm/utils/lit/lit/main.py +++ b/llvm/utils/lit/lit/main.py @@ -245,13 +245,11 @@ def execute_in_tmp_dir(run, lit_config): 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: