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

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
This commit is contained in:
Julian Lettner 2022-01-12 19:06:20 -08:00
parent efb8d4cff3
commit 0f6f6284d7
1 changed files with 5 additions and 7 deletions

View File

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