Skip to content

Commit 945231d

Browse files
committed
[test] Only cleanup temp directory when running CI
This causes all kind of issues if you have more than one emscripten checkout active at a given time (which I often do these days thanks the git worktrees and AI agents). The tests themselves should never leak temp files. We even have `EMTEST_DETECT_TEMPFILE_LEAKS` (which we set during CI) that ensure this is the case. I think the parallel test runner can leak temp directories if its killed at the wrong time, but #25615 should help with that. See #25614 and #26110
1 parent 4b2ae12 commit 945231d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

test/runner.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ def configure():
570570
browser_common.configure_test_browser()
571571

572572

573-
def cleanup_emscripten_temp():
574-
"""Deletes all files and directories under Emscripten
575-
that look like they might have been created by Emscripten."""
573+
def cleanup_temp_directory():
574+
"""Deletes all files and directories in TEMP_DIR that look like they
575+
might have been created by Emscripten."""
576576
for entry in os.listdir(shared.TEMP_DIR):
577577
if entry.startswith(('emtest_', 'emscripten_')):
578578
entry = os.path.join(shared.TEMP_DIR, entry)
@@ -718,8 +718,10 @@ def set_env(name, option_value):
718718

719719
# Remove any old test files before starting the run. Skip cleanup when we're running in debug mode
720720
# where we want to preserve any files created (e.g. emscripten.lock from shared.py).
721-
if not (shared.DEBUG or common.EMTEST_SAVE_DIR):
722-
cleanup_emscripten_temp()
721+
# Note: We don't do this except in the CI environment, since it prevents multiple
722+
# emscirpten checkout from running tests at the same time.
723+
if os.getenv('CI') and not (shared.DEBUG or common.EMTEST_SAVE_DIR):
724+
cleanup_temp_directory()
723725
utils.delete_file(common.flaky_tests_log_filename)
724726

725727
browser_common.init(options.force_browser_process_termination)

0 commit comments

Comments
 (0)