diff --git a/SequentialRegressionTest.py b/SequentialRegressionTest.py index ca10b68..4e99759 100644 --- a/SequentialRegressionTest.py +++ b/SequentialRegressionTest.py @@ -109,7 +109,11 @@ def build_compile_cmd(args): """ suffix = " --rebuild-includes" if args.rebuild_includes else "" if args.exe: - return f'"{args.exe}" --project {{project}} --clean{suffix}' + # 必须绝对化:每个项目都在自己的目录里执行(cwd=项目目录),相对 --exe 会按各自 + # 层级解析到不同位置——根级 escape 项目只深一层能命中,Test/NewTest 深两层就报 + # "The system cannot find the path specified."(实测踩过)。 + exe_abs = os.path.abspath(args.exe) + return f'"{exe_abs}" --project {{project}} --clean{suffix}' if args.compiler: return args.compiler return f'D:\\Python312\\python.exe -u "{PROJECTRANS}" --project {{project}} --clean{suffix}' @@ -225,6 +229,9 @@ def main(): parser.add_argument("--only", default=None, help="只跑指定项目(逗号分隔,名字即目录名),忽略 README 顺序") args = parser.parse_args() + if args.exe and not os.path.isfile(os.path.abspath(args.exe)): + print(f"错误: --exe 不存在: {os.path.abspath(args.exe)}") + return 1 compile_cmd = build_compile_cmd(args) print("=" * 70) diff --git a/run_lifetime_negative_tests.py b/run_lifetime_negative_tests.py index f390361..21e07eb 100644 --- a/run_lifetime_negative_tests.py +++ b/run_lifetime_negative_tests.py @@ -63,6 +63,11 @@ def main() -> int: help="每次编译追加 --rebuild-includes(全量重编 includes)") args = ap.parse_args() + # --exe 绝对化 + 存在性校验:编译以 cwd=项目目录 执行,相对路径会随项目层级错位 + exe_abs = os.path.abspath(args.exe) + if not os.path.isfile(exe_abs): + print(f"错误: --exe 不存在: {exe_abs}") + return 1 names = [n.strip() for n in args.only.split(",") if n.strip()] if args.only else NEGATIVE_PROJECTS suffix = " --rebuild-includes" if args.rebuild_includes else "" @@ -76,7 +81,7 @@ def main() -> int: skipped.append((name, "找不到 project.json / project.vpj")) print(f"[SKIP] {name}: 找不到 project.json / project.vpj") continue - cmd = f'"{args.exe}" --project "{proj_file}" --clean{suffix}' + cmd = f'"{exe_abs}" --project "{proj_file}" --clean{suffix}' try: r = subprocess.run(cmd, shell=True, capture_output=True, text=True, encoding='utf-8', errors='replace',