Skip to content

Commit

Permalink
Merge pull request #2788 from gnzlbg/test_check_fmt
Browse files Browse the repository at this point in the history
test cargo fmt --all -- --check returns success after formatting
  • Loading branch information
nrc committed Jun 18, 2018
2 parents fc057c2 + cf1164e commit 75d46b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,18 @@ matrix:
- env: INTEGRATION=rand
- env: INTEGRATION=rust-clippy
- env: INTEGRATION=rust-semverver
- env: INTEGRATION=stdsimd
- env: INTEGRATION=tempdir
allow_failures:
# Need to run an lalrpop build step before testing?
# See: https://github.com/rust-lang-nursery/rustfmt/issues/2789
- env: INTEGRATION=chalk
# PR sent
- env: INTEGRATION=crater
# #2721
- env: INTEGRATION=rand
# Doesn't build
- env: INTEGRATION=rust-clippy
# Doesn't build
- env: INTEGRATION=rust-semverver
# See: https://github.com/rust-lang-nursery/rustfmt/issues/2787
- env: INTEGRATION=stdsimd

before_script:
- |
Expand Down
14 changes: 12 additions & 2 deletions ci/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ cargo install --force
echo "Integration tests for: ${INTEGRATION}"
cargo fmt -- --version

# Checks that:
#
# * `cargo fmt --all` succeeds without any warnings or errors
# * `cargo fmt --all -- --check` after formatting returns success
# * `cargo test -all` still passes (formatting did not break the build)
function check_fmt {
touch rustfmt.toml
cargo fmt --all -v 2>&1 | tee rustfmt_output
if [[ $? != 0 ]]; then
cargo fmt --all -v |& tee rustfmt_output
if [[ ${PIPESTATUS[0]} != 0 ]]; then
cat rustfmt_output
return 1
fi
Expand All @@ -40,6 +45,11 @@ function check_fmt {
if [[ $? != 0 ]]; then
return 1
fi
cargo fmt --all -- --check |& tee rustfmt_check_output
if [[ ${PIPESTATUS[0]} != 0 ]]; then
cat rustfmt_check_output
return 1
fi
cargo test --all
if [[ $? != 0 ]]; then
return $?
Expand Down

0 comments on commit 75d46b1

Please sign in to comment.