5 : ${INTEGRATION?"The INTEGRATION environment variable must be set."}
7 # FIXME: this means we can get a stale cargo-fmt from a previous run.
9 # `which rustfmt` fails if rustfmt is not found. Since we don't install
10 # `rustfmt` via `rustup`, this is the case unless we manually install it. Once
11 # that happens, `cargo install --force` will be called, which installs
12 # `rustfmt`, `cargo-fmt`, etc to `~/.cargo/bin`. This directory is cached by
13 # travis (see `.travis.yml`'s "cache" key), such that build-bots that arrive
14 # here after the first installation will find `rustfmt` and won't need to build
17 #which cargo-fmt || cargo install --force
18 CFG_RELEASE=nightly CFG_RELEASE_CHANNEL=nightly cargo install --path . --force
20 echo "Integration tests for: ${INTEGRATION}"
21 cargo fmt -- --version
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)
28 function check_fmt_with_all_tests {
29 check_fmt_base "--all"
35 # * `cargo fmt --all` succeeds without any warnings or errors
36 # * `cargo fmt --all -- --check` after formatting returns success
37 # * `cargo test --lib` still passes (formatting did not break the build)
38 function check_fmt_with_lib_tests {
39 check_fmt_base "--lib"
43 function check_fmt_base {
45 local build=$(cargo test $test_args 2>&1)
46 if [[ "$build" =~ "build failed" ]] || [[ "$build" =~ "test result: FAILED." ]]; then
50 cargo fmt --all -v |& tee rustfmt_output
51 if [[ ${PIPESTATUS[0]} != 0 ]]; then
56 ! cat rustfmt_output | grep -q "internal error"
57 if [[ $? != 0 ]]; then
60 ! cat rustfmt_output | grep -q "warning"
61 if [[ $? != 0 ]]; then
64 ! cat rustfmt_output | grep -q "Warning"
65 if [[ $? != 0 ]]; then
68 cargo fmt --all -- --check |& tee rustfmt_check_output
69 if [[ ${PIPESTATUS[0]} != 0 ]]; then
70 cat rustfmt_check_output
74 if [[ $? != 0 ]]; then
80 local head=$(git rev-parse HEAD)
81 echo "Head commit of ${INTEGRATION}: $head"
84 case ${INTEGRATION} in
86 git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
89 export CFG_DISABLE_CROSS_TESTS=1
90 check_fmt_with_all_tests
94 git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
97 check_fmt_with_lib_tests
101 git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
104 check_fmt_with_all_tests