<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJy9Vdtu5DYM_RrPCzGGR56bH_yw6TbAAilQFFv0MZAl2lYiS4Ykz3T-vqQm0yTYS7coUMCwLUs8PCQP6c7rS_t5NBHokhBwCBij8Q6icQqhVgd9PDSi3wi93zVHlHqv6r7b9ZtK7-S2w6ZCvVVQiKOi-7a6WFeIpiyqj0X14Xr_YzQWIY0IymsE434cNiJOEWIK0gxj6n04y6AL8ROjBSzEgVnHpUuWcRMGqRKzT6NMMMlnjPRKoTmf4OzDM8iYzzmNGuiItLaoP7wni2SOMcEcvKJkEIQMCPgnqiXhzfkFvLOXvDNLOqRzfOhOJng3oUtwksHIzpJ5xMRBF_tKedeboXxzjD6W8MnB5MljXAx5Zg_02ZpUqn4o5wstKHOzIaivO-iDn9jExxs0m1Cc_ptOi_ru6tP3zHyCLhg38PHPv_zK1tLpvPr5ZWm9G5gZlkMJY0pz5MSJe7oGk8alK5WfaGHt6fZYUwafUCVadtZ39PjRur_icCV49ZoMUT9sN-uHbZ0p_u9MfnfmS0LisH6oxTvR3yGpFa_qU6N0A74o56W2j2maHzmz2gRi5sMFzvKtVt4Uc3dHSue6iEOx-8hG3RV9liFy2Rg2a_aqoC_kw645W5Qd0n-CgdphNuqZZLvMLPQZg72UcLdQS_TURl_j7fD8be7ak9uByKuA8qVNOkIjZ7xFM-GQ8j47kwMf-QeBEkD0f0cWCeYKQh2-WGo9Bsssb33wLv2fYFioeeHMQ0IDGh4YMMoTwfk8GW61CIt7zB4ejcuBUVAcW7-46ywxjqXDxyNCb9Dq-H3qYHqYPY1RIkUxTDj6M6zBB3haqEYBTxjS2wzn2pA777Rhl5LjuybyJQHTzLm-lZ1KACnwPCAW2pP5hdBIB9eJVq50W-umbuRKLmn0oZ0iFSk--dUSbPuvW8bEuPBYut_Vm_1hNba636Cs-q7f6qZSlUSt93jsOiVEL3aH48rKDm1ss3AF6yZD0DvJd_XfGZhWVEJUm42ge7U5ll2zr3Z7sesasVXHvaT_EE7S2JJxSh-GVWgzZLcMkTatoXq_btIAN4NDzISJYTL0P2l_W5zLzZXlxz-4EdXzmq0AE02GhgtBzcKb96QcOFMkYLFPnipMUqHZvMrU28z7Lym7eGk>53167</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Running tests (check-llvm etc) litters /tmp with leftover files
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mstorsjo
      </td>
    </tr>
</table>

<pre>
    This is a regression since 3c7d8792f12d6598ead6c3fb5f10d5a4be90ed4c (cc @yln).

While the code in 3c7d8792f12d6598ead6c3fb5f10d5a4be90ed4c seems straightforward, there's a subtle interaction that makes this not work as intended at all:

When test processes are executed, they only are passed the environment variables set in `config.environment`. In most suites, `lit.cfg.py` copies environment variables from `os.environ` into `config.environment`; most of them bring `TMP` and `TEMP` along, e.g. https://github.com/llvm/llvm-project/blob/3c7d8792f12d6598ead6c3fb5f10d5a4be90ed4c/llvm/test/lit.cfg.py#L41-L43 and https://github.com/llvm/llvm-project/blob/3c7d8792f12d6598ead6c3fb5f10d5a4be90ed4c/llvm/test/Unit/lit.cfg.py#L27-L32.

Before this change, the `lit_tmp_` directory was set in `os.environ['TMP']` before parsing the test suites `lit.cfg.py`, and thus it got picked up properly. But after this change, the new `lit_tmp_` directory does get created, but it doesn't get propagated into `config.environment`, so the tests don't actully get this variable.

I guess we'd either have to make the `run_tests_in_tmp_dir` function inject these fields into `config.environment` if possible somehow - or just revert this change and unconditionally create the temp dir before lit tries to do anything at all.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VcFu2zgQ_Rr5QliQKUuyDjo0bQMUyAKLosUeA4ocSUwoUiApu_77ztD2JkHb3e5lAUMWTfLNmzdvxr1T5-7LpAPDj2AeRg8haGdZ0FYC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