Skip to content

Commit 72ca2cf

Browse files
authored
[test] Only cleanup temp directory when running CI (#26567)
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 33c924e commit 72ca2cf

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/runner.py

Lines changed: 10 additions & 7 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)
@@ -716,10 +716,13 @@ def set_env(name, option_value):
716716

717717
check_js_engines()
718718

719-
# Remove any old test files before starting the run. Skip cleanup when we're running in debug mode
720-
# 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()
719+
# Remove any old test files before starting the run. Skip cleanup when we're
720+
# running in debug mode where we want to preserve any files created (e.g.
721+
# emscripten.lock from shared.py).
722+
# Note: We only do this in the CI environment, since it prevents multiple
723+
# emscripten checkouts from running tests at the same time.
724+
if os.getenv('CI') and not (shared.DEBUG or common.EMTEST_SAVE_DIR):
725+
cleanup_temp_directory()
723726
utils.delete_file(common.flaky_tests_log_filename)
724727

725728
browser_common.init(options.force_browser_process_termination)

0 commit comments

Comments
 (0)