Skip to content

Commit 75d46b1

Browse files
authored
Merge pull request #2788 from gnzlbg/test_check_fmt
test cargo fmt --all -- --check returns success after formatting
2 parents fc057c2 + cf1164e commit 75d46b1

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,18 @@ matrix:
3131
- env: INTEGRATION=rand
3232
- env: INTEGRATION=rust-clippy
3333
- env: INTEGRATION=rust-semverver
34-
- env: INTEGRATION=stdsimd
3534
- env: INTEGRATION=tempdir
3635
allow_failures:
37-
# Need to run an lalrpop build step before testing?
36+
# See: https://github.com/rust-lang-nursery/rustfmt/issues/2789
3837
- env: INTEGRATION=chalk
3938
# PR sent
4039
- env: INTEGRATION=crater
4140
# #2721
4241
- env: INTEGRATION=rand
4342
# Doesn't build
4443
- env: INTEGRATION=rust-clippy
45-
# Doesn't build
46-
- env: INTEGRATION=rust-semverver
44+
# See: https://github.com/rust-lang-nursery/rustfmt/issues/2787
45+
- env: INTEGRATION=stdsimd
4746

4847
before_script:
4948
- |

ci/integration.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ cargo install --force
2020
echo "Integration tests for: ${INTEGRATION}"
2121
cargo fmt -- --version
2222

23+
# Checks that:
24+
#
25+
# * `cargo fmt --all` succeeds without any warnings or errors
26+
# * `cargo fmt --all -- --check` after formatting returns success
27+
# * `cargo test -all` still passes (formatting did not break the build)
2328
function check_fmt {
2429
touch rustfmt.toml
25-
cargo fmt --all -v 2>&1 | tee rustfmt_output
26-
if [[ $? != 0 ]]; then
30+
cargo fmt --all -v |& tee rustfmt_output
31+
if [[ ${PIPESTATUS[0]} != 0 ]]; then
2732
cat rustfmt_output
2833
return 1
2934
fi
@@ -40,6 +45,11 @@ function check_fmt {
4045
if [[ $? != 0 ]]; then
4146
return 1
4247
fi
48+
cargo fmt --all -- --check |& tee rustfmt_check_output
49+
if [[ ${PIPESTATUS[0]} != 0 ]]; then
50+
cat rustfmt_check_output
51+
return 1
52+
fi
4353
cargo test --all
4454
if [[ $? != 0 ]]; then
4555
return $?

0 commit comments

Comments
 (0)