Skip to content

Commit 53a690e

Browse files
committed
test(matrix): timeout is GNU coreutils, and macOS has neither it nor gtimeout
macos-14, the first run that reached this script: all 20 cells came back `mismatch / query-failed`. `mcpp toolchain list`, which the script does not wrap, worked — which is how the wrapper was identified as the difference. ⭐ `tests/e2e/run_all.sh` has had `timeout` → `gtimeout` → none detection since it shipped. The defect was not that the problem is hard; it is that a second copy of a decision was written without looking at the first. No timeout command is a legitimate state here: the workflow's `timeout-minutes` is the backstop and running unwrapped beats not running. ⚠️ AND THE EVIDENCE WAS BEING THROWN AWAY. The query ran under `2>/dev/null`, so `query-failed` was the right classification with nothing to say why — twenty identical cells and no cause anywhere in the log. stderr now goes to a file and the first two lines are printed beside the failing cell. That redirect is the same shape as the classification it defeats: a cell that cannot be explained and a cell that is unsupported were being written the same way.
1 parent 0f6217d commit 53a690e

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

tests/matrix/scan.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,29 @@ command -v jq >/dev/null 2>&1 || {
4242
exit 2
4343
}
4444

45+
# ⚠️⚠️ `timeout` IS GNU coreutils AND macOS HAS NEITHER IT NOR `gtimeout`.
46+
#
47+
# Measured on macos-14, the first run that reached this script: every cell came
48+
# back `mismatch / query-failed` — all 20 of them — because the wrapper was not
49+
# a command. `mcpp toolchain list`, which this script does NOT wrap, worked
50+
# fine, which is how the two were told apart.
51+
#
52+
# ⭐ `tests/e2e/run_all.sh` has had this exact detection since it shipped. The
53+
# defect was not that the problem is hard; it is that a second copy of a
54+
# decision was written without looking at the first.
55+
#
56+
# No timeout command is a legitimate state: the step-level `timeout-minutes` in
57+
# the workflow is the backstop, and running unwrapped beats not running.
58+
TIMEOUT=""
59+
if command -v timeout >/dev/null 2>&1; then TIMEOUT=timeout
60+
elif command -v gtimeout >/dev/null 2>&1; then TIMEOUT=gtimeout
61+
fi
62+
[ -n "$TIMEOUT" ] || echo "scan: no timeout/gtimeout here — running unwrapped" >&2
63+
run_limited() { # seconds cmd… → run with a limit if one is available
64+
local secs="$1"; shift
65+
if [ -n "$TIMEOUT" ]; then "$TIMEOUT" "$secs" "$@"; else "$@"; fi
66+
}
67+
4568
work="$(mktemp -d)"; trap 'rm -rf "$work"' EXIT
4669
mkdir -p "$work/src"; cd "$work"
4770

@@ -123,11 +146,16 @@ for tc in $(compilers); do
123146
fi
124147

125148
# ── 第一问:这一格会解析成什么 ────────────────────────────────────
126-
q="$(timeout "${MATRIX_QUERY_TIMEOUT:-300}" \
127-
"$MCPP" why toolchain --target "$t" --toolchain "$tc" --format json 2>/dev/null)"
149+
# ⚠️ stderr 留到一个文件里,不丢。前一版写的是 `2>/dev/null`,于是
150+
# `query-failed` 是对的分类而**没有任何证据**说明为什么 —— macOS 上 20 格
151+
# 全红,原因(`timeout` 不存在)被这个重定向吞掉了。
152+
q="$(run_limited "${MATRIX_QUERY_TIMEOUT:-300}" \
153+
"$MCPP" why toolchain --target "$t" --toolchain "$tc" --format json \
154+
2>"$work/q.err")"
128155
if [ -z "$q" ]; then
129156
# ⚠️ 查询本身没跑起来。这不是「这一格不支持」,而是「不知道」—— 两者必须
130157
# 分开,否则一次环境故障会被整片读成「不支持」。
158+
echo "scan: $t × $tc 查询无输出: $(head -2 "$work/q.err" | tr '\n' ' ')" >&2
131159
emit "$MODE" "$HOST" "$t" "$tc" - - - - - mismatch query-failed
132160
continue
133161
fi
@@ -158,7 +186,7 @@ for tc in $(compilers); do
158186
# 读任何一行输出。
159187
printf '\n[toolchain]\ndefault = "%s"\n' "$tc" >> mcpp.toml
160188
rm -rf target
161-
if timeout "${MATRIX_TIMEOUT:-600}" "$MCPP" build --target "$t" >/dev/null 2>&1; then
189+
if run_limited "${MATRIX_TIMEOUT:-600}" "$MCPP" build --target "$t" >/dev/null 2>&1; then
162190
emit "$MODE" "$HOST" "$t" "$tc" "$tri" "$clib" "$cabi" "$cxxabi" "$okpkg" ok none
163191
else
164192
emit "$MODE" "$HOST" "$t" "$tc" "$tri" "$clib" "$cabi" "$cxxabi" "$okpkg" \

0 commit comments

Comments
 (0)