Skip to content

Commit 6e6f1a2

Browse files
Fix shellcheck lint errors
1 parent 0332da0 commit 6e6f1a2

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

ci/integration.sh

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ex
44

5-
: ${INTEGRATION?"The INTEGRATION environment variable must be set."}
5+
: "${INTEGRATION?'The INTEGRATION environment variable must be set.'}"
66

77
# FIXME: this means we can get a stale cargo-fmt from a previous run.
88
#
@@ -42,8 +42,12 @@ function check_fmt_with_lib_tests {
4242

4343
function check_fmt_base {
4444
local test_args="$1"
45-
local build=$(cargo test $test_args 2>&1)
46-
if [[ "$build" =~ "build failed" ]] || [[ "$build" =~ "test result: FAILED." ]]; then
45+
local build
46+
# shellcheck is complaining that `$test_args` can be interpreted as multiple arguments
47+
# in case it contains whitespace characters... which is exactly what we want.
48+
# shellcheck disable=SC2086
49+
build=$(cargo test $test_args 2>&1)
50+
if [[ "$build" =~ "build failed" ]] || [[ "$build" =~ test\ result\:\ FAILED\. ]]; then
4751
return 0
4852
fi
4953
touch rustfmt.toml
@@ -53,67 +57,61 @@ function check_fmt_base {
5357
return 1
5458
fi
5559
cat rustfmt_output
56-
! cat rustfmt_output | grep -q "internal error"
57-
if [[ $? != 0 ]]; then
58-
return 1
59-
fi
60-
! cat rustfmt_output | grep -q "warning"
61-
if [[ $? != 0 ]]; then
62-
return 1
63-
fi
64-
! cat rustfmt_output | grep -q "Warning"
65-
if [[ $? != 0 ]]; then
66-
return 1
67-
fi
60+
grep -q "internal error" < rustfmt_output && return 1
61+
grep -q "warning" < rustfmt_output && return 1
62+
grep -q "Warning" < rustfmt_output && return 1
63+
6864
cargo fmt --all -- --check |& tee rustfmt_check_output
6965
if [[ ${PIPESTATUS[0]} != 0 ]]; then
7066
cat rustfmt_check_output
7167
return 1
7268
fi
73-
cargo test $test_args
74-
if [[ $? != 0 ]]; then
75-
return $?
69+
cargo test "$test_args"
70+
cargo_ret=$?
71+
if [[ $cargo_ret != 0 ]]; then
72+
return $cargo_ret
7673
fi
7774
}
7875

7976
function show_head {
80-
local head=$(git rev-parse HEAD)
77+
local head
78+
head=$(git rev-parse HEAD)
8179
echo "Head commit of ${INTEGRATION}: $head"
8280
}
8381

8482
case ${INTEGRATION} in
8583
cargo)
86-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
87-
cd ${INTEGRATION}
84+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
85+
cd "${INTEGRATION}"
8886
show_head
8987
export CFG_DISABLE_CROSS_TESTS=1
9088
check_fmt_with_all_tests
9189
cd -
9290
;;
9391
crater)
94-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
95-
cd ${INTEGRATION}
92+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
93+
cd "${INTEGRATION}"
9694
show_head
9795
check_fmt_with_lib_tests
9896
cd -
9997
;;
10098
bitflags)
101-
git clone --depth=1 https://github.com/bitflags/${INTEGRATION}.git
102-
cd ${INTEGRATION}
99+
git clone --depth=1 "https://github.com/bitflags/${INTEGRATION}.git"
100+
cd "${INTEGRATION}"
103101
show_head
104102
check_fmt_with_all_tests
105103
cd -
106104
;;
107105
tempdir)
108-
git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION}.git
109-
cd ${INTEGRATION}
106+
git clone --depth=1 "https://github.com/rust-lang-deprecated/${INTEGRATION}.git"
107+
cd "${INTEGRATION}"
110108
show_head
111109
check_fmt_with_all_tests
112110
cd -
113111
;;
114112
*)
115-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
116-
cd ${INTEGRATION}
113+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
114+
cd "${INTEGRATION}"
117115
show_head
118116
check_fmt_with_all_tests
119117
cd -

0 commit comments

Comments
 (0)