Skip to content

Commit 745b0c4

Browse files
Fix shellcheck lint errors
1 parent 0332da0 commit 745b0c4

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

ci/integration.sh

Lines changed: 24 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,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,61 @@ 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
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
57+
grep -q "internal error" < rustfmt_output && return 1
58+
grep -q "warning" < rustfmt_output && return 1
59+
grep -q "Warning" < rustfmt_output && return 1
60+
6861
cargo fmt --all -- --check |& tee rustfmt_check_output
6962
if [[ ${PIPESTATUS[0]} != 0 ]]; then
7063
cat rustfmt_check_output
7164
return 1
7265
fi
73-
cargo test $test_args
74-
if [[ $? != 0 ]]; then
75-
return $?
66+
cargo test "$test_args"
67+
cargo_ret=$?
68+
if [[ $cargo_ret != 0 ]]; then
69+
return $cargo_ret
7670
fi
7771
}
7872

7973
function show_head {
80-
local head=$(git rev-parse HEAD)
74+
local head
75+
head=$(git rev-parse HEAD)
8176
echo "Head commit of ${INTEGRATION}: $head"
8277
}
8378

8479
case ${INTEGRATION} in
8580
cargo)
86-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
87-
cd ${INTEGRATION}
81+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
82+
cd "${INTEGRATION}"
8883
show_head
8984
export CFG_DISABLE_CROSS_TESTS=1
9085
check_fmt_with_all_tests
9186
cd -
9287
;;
9388
crater)
94-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
95-
cd ${INTEGRATION}
89+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
90+
cd "${INTEGRATION}"
9691
show_head
9792
check_fmt_with_lib_tests
9893
cd -
9994
;;
10095
bitflags)
101-
git clone --depth=1 https://github.com/bitflags/${INTEGRATION}.git
102-
cd ${INTEGRATION}
96+
git clone --depth=1 "https://github.com/bitflags/${INTEGRATION}.git"
97+
cd "${INTEGRATION}"
10398
show_head
10499
check_fmt_with_all_tests
105100
cd -
106101
;;
107102
tempdir)
108-
git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION}.git
109-
cd ${INTEGRATION}
103+
git clone --depth=1 "https://github.com/rust-lang-deprecated/${INTEGRATION}.git"
104+
cd "${INTEGRATION}"
110105
show_head
111106
check_fmt_with_all_tests
112107
cd -
113108
;;
114109
*)
115-
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
116-
cd ${INTEGRATION}
110+
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git"
111+
cd "${INTEGRATION}"
117112
show_head
118113
check_fmt_with_all_tests
119114
cd -

0 commit comments

Comments
 (0)