about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2018-12-27 12:40:07 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2018-12-27 16:56:08 +0100
commit84ee884cc4146f60c5a66a3d670b0f6cc0c0aab9 (patch)
tree4799bac0fe303f40a3a835e9690816aca0cae210
parentbcc309f27d8c619877bb9083031627b3fde29349 (diff)
downloadrust-84ee884cc4146f60c5a66a3d670b0f6cc0c0aab9.tar.gz
rust-84ee884cc4146f60c5a66a3d670b0f6cc0c0aab9.zip
base tests: make sure to fail CI if tests need formatting
-rwxr-xr-xci/base-tests.sh25
1 files changed, 17 insertions, 8 deletions
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
+# avoid loop spam and allow cmds with exit status != 0
+set +ex
+
 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
+  rustfmt ${file} --check
+  if [ $? -ne 0 ]; then
+    echo "${file} needs reformatting!"
+    tests_need_reformatting=true
+  fi
 done
-# switch back to master
-rustup default master
 
-if [ "${needs_reformatting}" = true ] ; then
+set -ex # reset
+
+if [ ${tests_need_reformatting} ] ; then
     echo "Tests need reformatting!"
     exit 2
 fi
-set -x
+
+# switch back to master
+rustup default master