-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Fix lint errors for src/tools/rustfmt/ci/integration.sh
#143512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
set -ex | ||
|
||
: ${INTEGRATION?"The INTEGRATION environment variable must be set."} | ||
: "${INTEGRATION?'The INTEGRATION environment variable must be set.'}" | ||
|
||
# FIXME: this means we can get a stale cargo-fmt from a previous run. | ||
# | ||
|
@@ -42,8 +42,9 @@ function check_fmt_with_lib_tests { | |
|
||
function check_fmt_base { | ||
local test_args="$1" | ||
local build=$(cargo test $test_args 2>&1) | ||
if [[ "$build" =~ "build failed" ]] || [[ "$build" =~ "test result: FAILED." ]]; then | ||
local build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lint says that we should not run a command while declaring a variable, so instead I declared the variable then assign it a value in the next line. |
||
build=$(cargo test "$test_args" 2>&1) | ||
if [[ "$build" =~ "build failed" ]] || [[ "$build" =~ test\ result\:\ FAILED\. ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two lints here: variables in double quote strings and the most important one is:
|
||
return 0 | ||
fi | ||
touch rustfmt.toml | ||
|
@@ -53,67 +54,72 @@ function check_fmt_base { | |
return 1 | ||
fi | ||
cat rustfmt_output | ||
! cat rustfmt_output | grep -q "internal error" | ||
if [[ $? != 0 ]]; then | ||
grep -q "internal error" < rustfmt_output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lint was complaining about the |
||
cmd_ret=$? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lint was complaining that we were using |
||
if [[ $cmd_ret == 0 ]]; then | ||
return 1 | ||
fi | ||
! cat rustfmt_output | grep -q "warning" | ||
if [[ $? != 0 ]]; then | ||
grep -q "warning" < rustfmt_output | ||
cmd_ret=$? | ||
if [[ $cmd_ret == 0 ]]; then | ||
return 1 | ||
fi | ||
! cat rustfmt_output | grep -q "Warning" | ||
if [[ $? != 0 ]]; then | ||
grep -q "Warning" < rustfmt_output | ||
cmd_ret=$? | ||
if [[ $cmd_ret == 0 ]]; then | ||
return 1 | ||
fi | ||
cargo fmt --all -- --check |& tee rustfmt_check_output | ||
if [[ ${PIPESTATUS[0]} != 0 ]]; then | ||
cat rustfmt_check_output | ||
return 1 | ||
fi | ||
cargo test $test_args | ||
if [[ $? != 0 ]]; then | ||
return $? | ||
cargo test "$test_args" | ||
cargo_ret=$? | ||
if [[ $cargo_ret != 0 ]]; then | ||
return $cargo_ret | ||
fi | ||
} | ||
|
||
function show_head { | ||
local head=$(git rev-parse HEAD) | ||
local head | ||
head=$(git rev-parse HEAD) | ||
echo "Head commit of ${INTEGRATION}: $head" | ||
} | ||
|
||
case ${INTEGRATION} in | ||
cargo) | ||
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git | ||
cd ${INTEGRATION} | ||
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git" | ||
cd "${INTEGRATION}" | ||
show_head | ||
export CFG_DISABLE_CROSS_TESTS=1 | ||
check_fmt_with_all_tests | ||
cd - | ||
;; | ||
crater) | ||
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git | ||
cd ${INTEGRATION} | ||
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git" | ||
cd "${INTEGRATION}" | ||
show_head | ||
check_fmt_with_lib_tests | ||
cd - | ||
;; | ||
bitflags) | ||
git clone --depth=1 https://github.com/bitflags/${INTEGRATION}.git | ||
cd ${INTEGRATION} | ||
git clone --depth=1 "https://github.com/bitflags/${INTEGRATION}.git" | ||
cd "${INTEGRATION}" | ||
show_head | ||
check_fmt_with_all_tests | ||
cd - | ||
;; | ||
tempdir) | ||
git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION}.git | ||
cd ${INTEGRATION} | ||
git clone --depth=1 "https://github.com/rust-lang-deprecated/${INTEGRATION}.git" | ||
cd "${INTEGRATION}" | ||
show_head | ||
check_fmt_with_all_tests | ||
cd - | ||
;; | ||
*) | ||
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git | ||
cd ${INTEGRATION} | ||
git clone --depth=1 "https://github.com/rust-lang/${INTEGRATION}.git" | ||
cd "${INTEGRATION}" | ||
show_head | ||
check_fmt_with_all_tests | ||
cd - | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In shell, simple quote strings are literals, whereas double quote strings are an equivalent of
format!
.So now, variables (
${}
) are interpreted as strings, so if they contain whitespace characters, it might break the script. Hence why we're putting them in double quote strings so they are treated as one string.