From 128b7e5a93d322f8461366c6432c8b98fc56aafa Mon Sep 17 00:00:00 2001 From: CI Bot Date: Sun, 19 Jul 2026 19:47:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E5=A2=9E=E9=87=8F=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=84=9A=E6=9C=AC=E8=BF=87=E6=BB=A4=E5=B7=B2?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除测试文件时,增量测试选择脚本会把已删除的文件加入运行列表, 导致pytest报'file or directory not found'错误并退出。 添加存在性检查,跳过已删除的测试文件。 --- scripts/ci/select_unit_tests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/ci/select_unit_tests.py b/scripts/ci/select_unit_tests.py index edc0bb8a2..90f3d50ee 100644 --- a/scripts/ci/select_unit_tests.py +++ b/scripts/ci/select_unit_tests.py @@ -158,10 +158,13 @@ def select_tests(changed_files): source_file_changes = [] for f in changed_files: - # 测试文件本身改动 + # 测试文件本身改动(仅保留仍存在的文件,删除的测试文件不加入运行列表) if f.startswith("tests/unit/test_") and f.endswith(".py"): - test_file_changes.append(f) - selected.add(f) + if (ROOT / f).exists(): + test_file_changes.append(f) + selected.add(f) + else: + print(f"[skip-deleted] 测试文件已删除,跳过: {f}") # 源码文件改动 elif f.endswith(".py"): source_file_changes.append(f) -- 2.54.0