Skip to content

Commit f019980

Browse files
committed
fix(e2e 267): 我选的目标在 macOS 上没有载荷 —— 那是假设不是实测
error: target 'x86_64-linux-musl' cannot be built on this host — no toolchain payload exists that runs here and produces it 我写的注释说「每个宿主都能解析它」,而那是一句假设。 ⇒ 改用**宿主自己的三元组**,而这恰好是更强的那一格:--target <host> 让 MCPP_TARGET 与宿主三元组相等,而 MCPP_TARGET_REQUESTED 非空 —— 因为确实指名了一个 目标。用一个异己三元组的测试,会被一个只是回显 MCPP_TARGET 的变量骗过去。 而且它不需要任何载荷:宿主自己的目标是每个宿主按构造都有的那一个。
1 parent a6a0154 commit f019980

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

‎tests/e2e/267_target_requested_is_empty_for_a_native_build.sh‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,32 @@ echo "$native" | grep -qE 'target=\[[a-z0-9_]+-[a-z0-9-]+\]' || {
8282
}
8383

8484
# ── A build pointed at a target ────────────────────────────────────────────
85-
# x86_64-linux-musl is chosen because every host in this suite can resolve it
86-
# without a payload download beyond what the other cross tests already use.
87-
cross=$("$MCPP" build --target x86_64-linux-musl 2>&1 || true)
85+
#
86+
# ⚠️ THE HOST'S OWN TRIPLE, NAMED EXPLICITLY — which is the case that
87+
# distinguishes the two variables rather than merely one that differs from the
88+
# native run. `--target <host>` produces equal values for `MCPP_TARGET` and the
89+
# host triple, and `MCPP_TARGET_REQUESTED` is non-empty because a target was
90+
# named. A test that used a foreign triple would pass with a variable that
91+
# merely echoed `MCPP_TARGET`.
92+
#
93+
# ⚠️ And it needs no payload. The first version of this test named
94+
# `x86_64-linux-musl` on the grounds that every host could resolve it, which was
95+
# an assumption rather than a measurement:
96+
#
97+
# error: target 'x86_64-linux-musl' cannot be built on this host —
98+
# no toolchain payload exists that runs here and produces it
99+
#
100+
# on the macOS leg. The host's own triple is the one target every host has by
101+
# construction.
102+
host_triple=$(echo "$native" | sed -n 's/.*PROBE target=\[\([^]]*\)\].*/\1/p' | head -1)
103+
[ -n "$host_triple" ] || { echo "could not read the host triple from the probe" >&2; exit 1; }
104+
cross=$("$MCPP" build --target "$host_triple" 2>&1 || true)
88105
echo "$cross" | grep -q 'PROBE ' || {
89106
echo "the build program did not report on the cross build" >&2
90107
echo "$cross" >&2
91108
exit 1
92109
}
93-
echo "$cross" | grep -qE 'requested=\[x86_64-linux-musl\]' || {
110+
echo "$cross" | grep -qE "requested=\[$host_triple\]" || {
94111
echo "MCPP_TARGET_REQUESTED should carry the triple that was named" >&2
95112
echo "$cross" | grep 'PROBE ' >&2
96113
exit 1

0 commit comments

Comments
 (0)