Skip to content

Commit 4eb8937

Browse files
committed
fix(e2e): 218 的指纹断言不能靠 find|head -1 推目录
自审 + 全量套件抓到的:第 2 部分之后 target/ 下有两个输出目录, `find target -name build.ninja | head -1` 取到的是 find 恰好先走到的那个 —— 单跑绿、进套件红。改成直接问 mcpp 要指纹值(--print-fingerprint), 断言那个值本身,而不是一个目录列举的副作用。 (这正是「指纹目录随版本变,ls|head -1 会自查到旧产物」那条老坑的同一形状, 在一个专门用来抓这类问题的测试里又踩了一次。)
1 parent b50faf5 commit 4eb8937

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

tests/e2e/218_module_extensions_graph_shape.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,21 @@ printf 'export module gshape.helper;\nimport std;\nexport auto helper() -> int {
5454
printf 'export module gshape.face;\nimport std;\nexport auto face() -> int { return 1; }\n' > src/face.ixx
5555
printf 'import std;\nimport gshape.face;\nint main(){ std::println("{}", face()); }\n' > src/main.cpp
5656

57-
fp_dir() { find target -name build.ninja -printf '%h\n' | head -1; }
57+
# Ask mcpp for the fingerprint instead of inferring it from the build tree.
58+
#
59+
# ⚠️ The obvious `find target -name build.ninja | head -1` is WRONG here and was
60+
# flaky in exactly the way this test is meant to catch: after part 2 there are
61+
# TWO output dirs, and `head -1` picks whichever `find` happened to walk first.
62+
# It passed standalone and failed inside the suite. Assert on the value, not on
63+
# a directory listing.
64+
fingerprint() {
65+
"$MCPP" build --print-fingerprint 2>&1 | sed -n 's/^Fingerprint: //p' | head -1
66+
}
5867

5968
# ── 0. First build, then confirm the fast path actually engages ────────────
6069
"$MCPP" build > b0.log 2>&1 || { cat b0.log; echo "FAIL: first build"; exit 1; }
61-
FP_BEFORE="$(fp_dir)"
70+
FP_BEFORE="$(fingerprint)"
71+
[ -n "$FP_BEFORE" ] || { echo "FAIL: could not read the fingerprint"; exit 1; }
6272

6373
"$MCPP" build > b1.log 2>&1 || { cat b1.log; echo "FAIL: no-change build"; exit 1; }
6474
grep -q "Compiling" b1.log && {
@@ -91,14 +101,14 @@ module_extensions = [".ixx", ".ccm"]
91101
EOF
92102

93103
"$MCPP" build > b3.log 2>&1 || { cat b3.log; echo "FAIL: build after key change"; exit 1; }
94-
FP_AFTER="$(fp_dir)"
104+
FP_AFTER="$(fingerprint)"
95105

96106
[[ "$FP_BEFORE" != "$FP_AFTER" ]] || {
97107
echo "FAIL: module_extensions changed but the output dir did not"
98108
echo " before=$FP_BEFORE after=$FP_AFTER"
99109
echo " (the key is missing from the canonical compile-flags string)"
100110
exit 1; }
101-
echo " ok: the key is fingerprinted ($(basename "$FP_BEFORE") -> $(basename "$FP_AFTER"))"
111+
echo " ok: the key is fingerprinted ($FP_BEFORE -> $FP_AFTER)"
102112

103113
# ── 3. A dead entry is reported, not silently ignored ──────────────────────
104114
#

0 commit comments

Comments
 (0)