mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
base tests: make sure to fail CI if tests need formatting
This commit is contained in:
parent
bcc309f27d
commit
84ee884cc4
@ -36,22 +36,31 @@ cd ..
|
||||
cargo +nightly fmt --all -- --check
|
||||
|
||||
|
||||
#avoid loop spam
|
||||
set +x
|
||||
|
||||
|
||||
# make sure tests are formatted
|
||||
|
||||
# some lints are sensitive to formatting, exclude some files
|
||||
needs_formatting=false
|
||||
tests_need_reformatting=false
|
||||
# switch to nightly
|
||||
rustup default nightly
|
||||
for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do
|
||||
rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true
|
||||
done
|
||||
# switch back to master
|
||||
rustup default master
|
||||
# avoid loop spam and allow cmds with exit status != 0
|
||||
set +ex
|
||||
|
||||
if [ "${needs_reformatting}" = true ] ; then
|
||||
for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do
|
||||
rustfmt ${file} --check
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "${file} needs reformatting!"
|
||||
tests_need_reformatting=true
|
||||
fi
|
||||
done
|
||||
|
||||
set -ex # reset
|
||||
|
||||
if [ ${tests_need_reformatting} ] ; then
|
||||
echo "Tests need reformatting!"
|
||||
exit 2
|
||||
fi
|
||||
set -x
|
||||
|
||||
# switch back to master
|
||||
rustup default master
|
||||
|
Loading…
Reference in New Issue
Block a user