Skip to content

Commit 14470a8

Browse files
committed
test(e2e): normalize Windows CDB include paths
1 parent c35f1b4 commit 14470a8

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

tests/e2e/202_configure_only_cdb.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,23 @@ grep -q 'tests[\/][\/]*test_smoke.cpp' compile_commands.json || {
6666
exit 1
6767
}
6868
if command -v python3 >/dev/null 2>&1; then
69-
python3 - compile_commands.json "$TMP/devkit/include" <<'PY'
70-
import json, os, sys
69+
python3 - compile_commands.json <<'PY'
70+
import json, sys
7171
entries = json.load(open(sys.argv[1], encoding="utf-8"))
72-
normal = lambda p: p.replace("\\", "/")
72+
normal = lambda p: p.replace("\\", "/").rstrip("/")
7373
test = next(e for e in entries if normal(e["file"]).endswith("/tests/test_smoke.cpp"))
7474
main = next(e for e in entries if normal(e["file"]).endswith("/src/main.cpp"))
7575
args = test["arguments"]
76-
assert any(os.path.normpath(sys.argv[2]) in os.path.normpath(a) for a in args), args
76+
# Windows 原生进程与 MSYS 可能用不同根路径表示同一临时目录,
77+
# 因此从 CDB 的 directory 字段推导相邻 devkit 路径。
78+
fixture = normal(test["directory"]).rsplit("/", 1)[0]
79+
expected_include = f"{fixture}/devkit/include".casefold()
80+
include_args = {
81+
normal(a[2:]).casefold()
82+
for a in args
83+
if a[:2].casefold() == "-i"
84+
}
85+
assert expected_include in include_args, args
7786
assert any("MCPP_CONFIGURE_ONLY_TEST_FLAG=1" in a for a in args), args
7887
assert not any("MCPP_CONFIGURE_ONLY_TEST_FLAG=1" in a for a in main["arguments"]), main
7988
PY

0 commit comments

Comments
 (0)