From 0a4ba7c91dbf3517fdd3ef78d8157e5c7eb7869f Mon Sep 17 00:00:00 2001 From: yuxuan-ms Date: Thu, 27 Jun 2024 16:13:18 +0800 Subject: [PATCH] Exclude scratch folder when clean multitest runpath. --- testplan/common/utils/helper.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/testplan/common/utils/helper.py b/testplan/common/utils/helper.py index 24cb1df09..eb279a9c6 100644 --- a/testplan/common/utils/helper.py +++ b/testplan/common/utils/helper.py @@ -222,7 +222,16 @@ def clean_runpath_if_passed( """ multitest = env.parent if multitest.report.passed: - shutil.rmtree(multitest.runpath, ignore_errors=True) + for subfile in os.listdir(multitest.runpath): + # TODO: Define scratch as a constant + if subfile != "scratch": + path = os.path.join( + os.path.abspath(multitest.runpath), subfile + ) + if os.path.isfile(path) or os.path.islink(path): + os.remove(path) + elif os.path.isdir(path): + shutil.rmtree(path, ignore_errors=True) @testsuite