fix(test): --exe 绝对化并校验存在性,修 Test/NewTest 报 cannot find the path specified
编译以 cwd=项目目录 执行,--exe 若是相对路径会按各项目层级解析:根级 escape 项目只深一层能命中,Test/NewTest 深两层就启动失败(耗时 0.0s 且无任何产物)。 SequentialRegressionTest.build_compile_cmd 与 run_lifetime_negative_tests.py 都改为 os.path.abspath(--exe),并在文件不存在时立即报错退出(避免静默跑到最后一个项目才暴露)。
This commit is contained in:
1 parent
73846979f1
commit
12c96d3039
2 files changed
+14
-2
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user