diff --git a/ci/base-tests.sh b/ci/base-tests.sh index d4da158a35f..377f6957746 100755 --- a/ci/base-tests.sh +++ b/ci/base-tests.sh @@ -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