reclient_helper: delete directory synchronously

This is for
https://crrev.com/c/4916355/8/reclient_helper.py#177

Let me use synchronous directory deletion as reclient doesn't produce
many log files.

Change-Id: I44f616c9d825bc6b9dbeea329ca1db00a578a9fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4988347
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Michael Savigny <msavigny@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
changes/47/4988347/7
Takuto Ikuta 2 years ago committed by LUCI CQ
parent 9f3b33a275
commit 5388959fd7

@ -164,25 +164,6 @@ def datetime_now():
return datetime.datetime.utcnow()
_test_only_cleanup_logdir_handles = []
def cleanup_logdir(log_dir):
# Run deletetion command without waiting
if sys.platform.startswith('win'):
_test_only_cleanup_logdir_handles.append(
subprocess.Popen(["rmdir", "/s/q", log_dir],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
shell=True,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP))
else:
_test_only_cleanup_logdir_handles.append(
subprocess.Popen(["rm", "-rf", log_dir],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL))
def set_reproxy_path_flags(out_dir, make_dirs=True):
"""Helper to setup the logs and cache directories for reclient.
@ -240,7 +221,8 @@ def set_reproxy_path_flags(out_dir, make_dirs=True):
if len(old_log_dirs) > 5:
old_log_dirs.sort(key=lambda dir: dir.split("_"), reverse=True)
for d in old_log_dirs[5:]:
cleanup_logdir(os.path.join(log_dir, d))
shutil.rmtree(os.path.join(log_dir, d))
os.environ.setdefault("RBE_output_dir", run_log_dir)
os.environ.setdefault("RBE_proxy_log_dir", run_log_dir)
os.environ.setdefault("RBE_log_dir", run_log_dir)

@ -324,8 +324,6 @@ expiry: {
'20170316T200042.000000_SOME_RANDOM_ID_2',
'20170316T200045.000000_SOME_RANDOM_ID_5',
]
for p in reclient_helper._test_only_cleanup_logdir_handles:
p.wait()
self.assertCountEqual(os.listdir(log_dir), want_remaining_dirs)
for d in want_remaining_dirs:
self.assertTrue(

Loading…
Cancel
Save