Skip to content

Commit 84ee884

Browse files
committed
base tests: make sure to fail CI if tests need formatting
1 parent bcc309f commit 84ee884

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

ci/base-tests.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,31 @@ cd ..
3636
cargo +nightly fmt --all -- --check
3737

3838

39-
#avoid loop spam
40-
set +x
39+
40+
4141
# make sure tests are formatted
4242

4343
# some lints are sensitive to formatting, exclude some files
44-
needs_formatting=false
44+
tests_need_reformatting=false
4545
# switch to nightly
4646
rustup default nightly
47+
# avoid loop spam and allow cmds with exit status != 0
48+
set +ex
49+
4750
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
48-
rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true
51+
rustfmt ${file} --check
52+
if [ $? -ne 0 ]; then
53+
echo "${file} needs reformatting!"
54+
tests_need_reformatting=true
55+
fi
4956
done
50-
# switch back to master
51-
rustup default master
5257

53-
if [ "${needs_reformatting}" = true ] ; then
58+
set -ex # reset
59+
60+
if [ ${tests_need_reformatting} ] ; then
5461
echo "Tests need reformatting!"
5562
exit 2
5663
fi
57-
set -x
64+
65+
# switch back to master
66+
rustup default master

0 commit comments

Comments
 (0)