Skip to content

Commit 05a23ef

Browse files
committed
fix(build-gpu-test-binary): surface cargo stderr on compile failure
Run cargo separately from the jq pipeline. Piped under set -o pipefail, a compile failure aborted the script at the pipeline before the diagnostic block could print stderr, so genuine candle/CUDA build errors surfaced only as an opaque 'exit 101'. Capture cargo's status explicitly and always dump stderr on failure.
1 parent 0771f6b commit 05a23ef

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

build-gpu-test-binary/scripts/build.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,26 @@ if [[ -n "$features" ]]; then
1818
fi
1919
cargo_args+=(--test "$test_name" --no-run --message-format=json)
2020

21+
json_log=$(mktemp)
2122
stderr_log=$(mktemp)
2223
binary_path_file=$(mktemp)
23-
trap 'rm -f "$stderr_log" "$binary_path_file"' EXIT
24+
trap 'rm -f "$json_log" "$stderr_log" "$binary_path_file"' EXIT
25+
26+
# Run cargo separately from the jq parse. Piped directly under `set -o pipefail`,
27+
# a compile failure aborts the script at the pipeline before the diagnostic block
28+
# below can print stderr, so every real error surfaced only as a bare "exit 101".
29+
set +e
30+
cargo "${cargo_args[@]}" >"$json_log" 2>"$stderr_log"
31+
cargo_status=$?
32+
set -e
33+
34+
if [[ "$cargo_status" -ne 0 ]]; then
35+
echo "::error::cargo ${cargo_args[*]} failed (exit ${cargo_status}); stderr below:" >&2
36+
cat "$stderr_log" >&2
37+
exit "$cargo_status"
38+
fi
2439

25-
cargo "${cargo_args[@]}" 2>"$stderr_log" |
26-
jq -r 'select(.executable != null) | .executable' |
40+
jq -r 'select(.executable != null) | .executable' <"$json_log" |
2741
head -1 >"$binary_path_file"
2842

2943
if [[ ! -s "$binary_path_file" ]]; then

0 commit comments

Comments
 (0)