Make test-checks.sh helpful and cargo-for-all-lock-files.sh useful (#10906)

This commit is contained in:
Ryo Onodera 2020-07-03 18:08:12 +09:00 committed by GitHub
parent 8d951776ab
commit d8106ab552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View File

@ -36,8 +36,9 @@ if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
true
else
check_status=$?
echo "Some Cargo.lock might be outdated; update them (or just be a compilation error?)"
echo "protip: you can use ./scripts/cargo-for-all-lock-files.sh [check|update] ..."
echo "$0: Some Cargo.lock might be outdated; sync them (or just be a compilation error?)" >&2
echo "$0: protip: $ ./scripts/cargo-for-all-lock-files.sh [--ignore-exit-code] ... \\" >&2
echo "$0: [tree (for outdated Cargo.lock sync)|check (for compilation error)|update -p foo --precise x.y.z (for your Cargo.toml update)] ..." >&2
exit "$check_status"
fi
else

View File

@ -8,6 +8,9 @@ while [[ -n $1 ]]; do
escape_marker=found
shift
break
elif [[ $1 = "--ignore-exit-code" ]]; then
ignore=1
shift
else
shifted_args+=("$1")
shift
@ -33,9 +36,17 @@ for lock_file in $files; do
if [[ -n $CI ]]; then
echo "--- [$lock_file]: cargo " "${shifted_args[@]}" "$@"
fi
(
set -x
cd "$(dirname "$lock_file")"
cargo "${shifted_args[@]}" "$@"
)
if (set -x && cd "$(dirname "$lock_file")" && cargo "${shifted_args[@]}" "$@"); then
# noop
true
else
failed_exit_code=$?
if [[ -n $ignore ]]; then
echo "$0: WARN: ignoring last cargo command failed exit code as requested:" $failed_exit_code
true
else
exit $failed_exit_code
fi
fi
done