]> git.lizzy.rs Git - rust.git/blob - ci/integration.sh
do not fix chalk
[rust.git] / ci / integration.sh
1 #!/usr/bin/env bash
2
3 set -ex
4
5 : ${INTEGRATION?"The INTEGRATION environment variable must be set."}
6
7 # FIXME: this means we can get a stale cargo-fmt from a previous run.
8 #
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
15 # it again.
16 #
17 #which cargo-fmt || cargo install --force
18 cargo install --force
19
20 echo "Integration tests for: ${INTEGRATION}"
21 cargo fmt -- --version
22
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)
28 function check_fmt {
29     touch rustfmt.toml
30     cargo fmt --all -v |& tee rustfmt_output
31     if [[ ${PIPESTATUS[0]} != 0 ]]; then
32         cat rustfmt_output
33         return 1
34     fi
35     cat rustfmt_output
36     ! cat rustfmt_output | grep -q "internal error"
37     if [[ $? != 0 ]]; then
38         return 1
39     fi
40     ! cat rustfmt_output | grep -q "warning"
41     if [[ $? != 0 ]]; then
42         return 1
43     fi
44     ! cat rustfmt_output | grep -q "Warning"
45     if [[ $? != 0 ]]; then
46         return 1
47     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
53     cargo test --all
54     if [[ $? != 0 ]]; then
55         return $?
56     fi
57 }
58
59 case ${INTEGRATION} in
60     cargo)
61         git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
62         cd ${INTEGRATION}
63         export CFG_DISABLE_CROSS_TESTS=1
64         check_fmt
65         cd -
66         ;;
67     failure)
68         git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
69         cd ${INTEGRATION}/failure-1.X
70         check_fmt
71         cd -
72         ;;
73     *)
74         git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
75         cd ${INTEGRATION}
76         check_fmt
77         cd -
78         ;;
79 esac