Skip to content

Commit 50e4e05

Browse files
committed
test(e2e 328): 两处只在 Windows 上才成立的问题
⚠️ **`cfg(all(unix, …))` 在 Windows 上正确地为假**,于是 fixture 的 #error 触发, Windows e2e 1/2 变红。这条腿要证明的是「三元组键与层键**组合**」,那么它的三元组 那一半就必须在测试会跑的每个平台上为真。改成 `any(unix, windows)`。 「恰好一次」那条腿同理:三元组腿为假的地方,只有一条路能匹配,这个守卫就不再守任何 东西 —— 它存在的理由正是第一趟会经三元组腿匹配而第二趟经层腿匹配。 ⚠️ **注释里的反引号落在**未加引号**的 heredoc 里,变成了命令替换。** fixture 要 插值 $CABI 所以 heredoc 不能加引号;套件因此打印 `syntax error: unexpected end of file` 而**测试照样通过**。注释移到 heredoc 之外。 顺带:`-DPROBE_ONCE=1` 的计数改为同时接受 `/D`(Windows 自举可能驱动 MSVC)。 本机全量:355 passed / 3 failed —— 三条(62、168、208)在已发布的 2026.8.30.2 上以 相同消息失败,是本机 musl/glibc 载荷的缺口,对照已跑。
1 parent 5f7128f commit 50e4e05

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

tests/e2e/328_layer_predicates_apply_and_unknown_ones_say_so.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ echo " .. this host resolves c-abi = '$CABI'"
5151
NOTCABI="not-${CABI}"
5252

5353
# ── (1) + (2) a matching layer predicate applies; a non-matching one does not ──
54+
#
55+
# ⚠️ THE TRIPLE HALF OF THE COMBINED PREDICATE IS any(unix, windows), NOT unix.
56+
# The point of that leg is that a triple key and a layer key COMBINE, so its
57+
# triple half has to be true everywhere this test runs. Written as bare unix it
58+
# was true on Linux and macOS and false on Windows, where all(...) then
59+
# correctly evaluated false and the fixture's #error fired. CI caught it; the
60+
# feature was right and the test was not.
61+
#
62+
# ⚠️ AND THESE NOTES LIVE OUTSIDE THE HEREDOCS. The fixtures below interpolate
63+
# $CABI, so their heredocs are unquoted — which makes backticks in a comment
64+
# command substitution. The first version of this note sat inside one and the
65+
# suite printed `syntax error: unexpected end of file` while still passing.
5466
mkdir -p layers/src
5567
cat > layers/mcpp.toml <<EOF
5668
[package]
@@ -63,7 +75,7 @@ defines = ["PROBE_MATCHED=1"]
6375
[target.'cfg(c-abi = "$NOTCABI")'.build]
6476
defines = ["PROBE_MUST_NOT_APPLY=1"]
6577
66-
[target.'cfg(all(unix, c-abi = "$CABI"))'.build]
78+
[target.'cfg(all(any(unix, windows), c-abi = "$CABI"))'.build]
6779
defines = ["PROBE_COMBINED=1"]
6880
EOF
6981
cat > layers/src/main.cpp <<'EOF'
@@ -93,13 +105,14 @@ cat > once/mcpp.toml <<EOF
93105
name = "once"
94106
version = "0.1.0"
95107
96-
[target.'cfg(any(unix, c-abi = "$CABI"))'.build]
108+
[target.'cfg(any(unix, windows, c-abi = "$CABI"))'.build]
97109
defines = ["PROBE_ONCE=1"]
98110
EOF
99111
echo 'int main() { return 0; }' > once/src/main.cpp
100112
( cd once && "$MCPP" build > b.log 2>&1 ) || {
101113
cat once/b.log; echo "FAIL: the mixed-predicate build errored"; exit 1; }
102-
n=$(grep -o '\-DPROBE_ONCE=1' once/compile_commands.json | wc -l | tr -d ' ')
114+
# Both spellings: a Windows self-host may drive MSVC, which takes `/D`.
115+
n=$(grep -oE '[-/]DPROBE_ONCE=1' once/compile_commands.json | wc -l | tr -d ' ')
103116
[ "$n" -eq 1 ] || {
104117
echo "FAIL: a predicate with both a triple leg and a layer leg contributed $n times, expected 1"
105118
grep -o '\-DPROBE_ONCE=1' once/compile_commands.json

0 commit comments

Comments
 (0)