Skip to content

Commit

Permalink
Update various bash scripts to pipe errors to stderr (bazelbuild#1999)
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre authored and Silcet committed Jul 10, 2023
1 parent 68e18cd commit d8a6a42
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/test_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ bazel clean \
&& chmod 0644 *.md

if [ -n "$(git status --porcelain)" ]; then
git status
echo '/docs is out of date. Please run `./docs/update_docs.sh` from the root of rules_rust and push the results' >&2
>&2 git status
>&2 echo '/docs is out of date. Please run `./docs/update_docs.sh` from the root of rules_rust and push the results' >&2
exit 1
fi

Expand Down
12 changes: 6 additions & 6 deletions test/clippy/clippy_failure_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
set -euo pipefail

if [[ -z "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
echo "This script should be run under Bazel"
>&2 echo "This script should be run under Bazel"
exit 1
fi

Expand All @@ -30,8 +30,8 @@ function check_build_result() {
echo -n "Testing ${2}... "
(bazel build ${@:3} //test/clippy:"${2}" &> /dev/null) || ret="$?" && true
if [[ "${ret}" -ne "${1}" ]]; then
echo "FAIL: Unexpected return code [saw: ${ret}, want: ${1}] building target //test/clippy:${2}"
echo " Run \"bazel build //test/clippy:${2}\" to see the output"
>&2 echo "FAIL: Unexpected return code [saw: ${ret}, want: ${1}] building target //test/clippy:${2}"
>&2 echo " Run \"bazel build //test/clippy:${2}\" to see the output"
exit 1
elif [[ $# -ge 3 ]] && [[ "${@:3}" == *"capture_clippy_output"* ]]; then
# Make sure that content was written to the output file
Expand All @@ -41,9 +41,9 @@ function check_build_result() {
STATOPTS=(-c%s)
fi
if [[ $(stat ${STATOPTS[@]} "${NEW_WORKSPACE}/bazel-bin/test/clippy/${2%_clippy}.clippy.out") == 0 ]]; then
echo "FAIL: Output wasn't written to out file building target //test/clippy:${2}"
echo " Output file: ${NEW_WORKSPACE}/bazel-bin/test/clippy/${2%_clippy}.clippy.out"
echo " Run \"bazel build //test/clippy:${2}\" to see the output"
>&2 echo "FAIL: Output wasn't written to out file building target //test/clippy:${2}"
>&2 echo " Output file: ${NEW_WORKSPACE}/bazel-bin/test/clippy/${2%_clippy}.clippy.out"
>&2 echo " Run \"bazel build //test/clippy:${2}\" to see the output"
exit 1
else
echo "OK"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ if [[ "${OPTION}" == "files" ]]; then
exit 0
fi

echo "Unexpected option: ${OPTION}"
>&2 echo "Unexpected option: ${OPTION}"
exit 1
6 changes: 3 additions & 3 deletions test/portable_link_flags_darwin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
set -e

if otool -L $1 | grep -q libtest; then
echo "error: rust_binary is dynamically linked against libtest!"
>&2 echo "error: rust_binary is dynamically linked against libtest!"
exit 1
fi

if otool -L $1 | grep -q libstd; then
echo "error: rust_binary is dynamically linked against libstd!"
>&2 echo "error: rust_binary is dynamically linked against libstd!"
exit 1
fi
fi
4 changes: 2 additions & 2 deletions test/rust_analyzer/rust_analyzer_test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
set -euo pipefail

if [[ -z "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
echo "This script should be run under Bazel"
>&2 echo "This script should be run under Bazel"
exit 1
fi

PACKAGE_NAME="$1"
if [[ -z "${PACKAGE_NAME:-}" ]]; then
echo "The first argument should be the package name of the test target"
>&2 echo "The first argument should be the package name of the test target"
exit 1
fi

Expand Down
4 changes: 2 additions & 2 deletions test/rustfmt/rustfmt_failure_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function check_build_result() {
echo -n "Testing ${2}... "
(bazel test //test/rustfmt:"${2}") || ret="$?" && true
if [[ "${ret}" -ne "${1}" ]]; then
echo "FAIL: Unexpected return code [saw: ${ret}, want: ${1}] building target //test/rustfmt:${2}"
echo " Run \"bazel test //test/rustfmt:${2}\" to see the output"
>&2 echo "FAIL: Unexpected return code [saw: ${ret}, want: ${1}] building target //test/rustfmt:${2}"
>&2 echo " Run \"bazel test //test/rustfmt:${2}\" to see the output"
exit 1
else
echo "OK"
Expand Down

0 comments on commit d8a6a42

Please sign in to comment.