Skip to content

Commit ca0beed

Browse files
Fix shellcheck lint errors
1 parent 0332da0 commit ca0beed

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

ci/integration.sh

Lines changed: 29 additions & 23 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,9 @@ 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+
build=$(cargo test "$test_args" 2>&1)
47+
if [[ "$build" =~ "build failed" ]] || [[ "$build" =~ test\ result\:\ FAILED\. ]]; then
4748
return 0
4849
fi
4950
touch rustfmt.toml
@@ -53,67 +54,72 @@ function check_fmt_base {
5354
return 1
5455
fi
5556
cat rustfmt_output
56-
! cat rustfmt_output | grep -q "internal error"
57-
if [[ $? != 0 ]]; then
57+
grep -q "internal error" < rustfmt_output
58+
cmd_ret=$?
59+
if [[ $cmd_ret == 0 ]]; then
5860
return 1
5961
fi
60-
! cat rustfmt_output | grep -q "warning"
61-
if [[ $? != 0 ]]; then
62+
grep -q "warning" < rustfmt_output
63+
cmd_ret=$?
64+
if [[ $cmd_ret == 0 ]]; then
6265
return 1
6366
fi
64-
! cat rustfmt_output | grep -q "Warning"
65-
if [[ $? != 0 ]]; then
67+
grep -q "Warning" < rustfmt_output
68+
cmd_ret=$?
69+
if [[ $cmd_ret == 0 ]]; then
6670
return 1
6771
fi
6872
cargo fmt --all -- --check |& tee rustfmt_check_output
6973
if [[ ${PIPESTATUS[0]} != 0 ]]; then
7074
cat rustfmt_check_output
7175
return 1
7276
fi
73-
cargo test $test_args
74-
if [[ $? != 0 ]]; then
75-
return $?
77+
cargo test "$test_args"
78+
cargo_ret=$?
79+
if [[ $cargo_ret != 0 ]]; then
80+
return $cargo_ret
7681
fi
7782
}
7883

7984
function show_head {
80-
local head=$(git rev-parse HEAD)
85+
local head
86+
head=$(git rev-parse HEAD)
8187
echo "Head commit of ${INTEGRATION}: $head"
8288
}
8389

8490
case ${INTEGRATION} in
8591
cargo)
86-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
87-
cd ${INTEGRATION}
92+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
93+
cd "${INTEGRATION}"
8894
show_head
8995
export CFG_DISABLE_CROSS_TESTS=1
9096
check_fmt_with_all_tests
9197
cd -
9298
;;
9399
crater)
94-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
95-
cd ${INTEGRATION}
100+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
101+
cd "${INTEGRATION}"
96102
show_head
97103
check_fmt_with_lib_tests
98104
cd -
99105
;;
100106
bitflags)
101-
git clone --depth=1 https://github.com/bitflags/${INTEGRATION}.git
102-
cd ${INTEGRATION}
107+
git clone --depth=1 "https://github.com/bitflags/${INTEGRATION}.git"
108+
cd "${INTEGRATION}"
103109
show_head
104110
check_fmt_with_all_tests
105111
cd -
106112
;;
107113
tempdir)
108-
git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION}.git
109-
cd ${INTEGRATION}
114+
git clone --depth=1 "https://github.com/rust-lang-deprecated/${INTEGRATION}.git"
115+
cd "${INTEGRATION}"
110116
show_head
111117
check_fmt_with_all_tests
112118
cd -
113119
;;
114120
*)
115-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
116-
cd ${INTEGRATION}
121+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
122+
cd "${INTEGRATION}"
117123
show_head
118124
check_fmt_with_all_tests
119125
cd -

0 commit comments

Comments
 (0)