]> git.lizzy.rs Git - rust.git/blob - ci/integration.sh
Fix and tweak integration tests
[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 function check_fmt {
24     touch rustfmt.toml
25     cargo fmt --all -v 2>&1 | tee rustfmt_output
26     if [[ $? != 0 ]]; then
27         cat rustfmt_output
28         return 1
29     fi
30     cat rustfmt_output
31     ! cat rustfmt_output | grep -q "internal error"
32     if [[ $? != 0 ]]; then
33         return 1
34     fi
35     ! cat rustfmt_output | grep -q "warning"
36     if [[ $? != 0 ]]; then
37         return 1
38     fi
39     ! cat rustfmt_output | grep -q "Warning"
40     if [[ $? != 0 ]]; then
41         return 1
42     fi
43     cargo test --all
44     if [[ $? != 0 ]]; then
45         return $?
46     fi
47 }
48
49 case ${INTEGRATION} in
50     cargo)
51         git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
52         cd ${INTEGRATION}
53         export CFG_DISABLE_CROSS_TESTS=1
54         check_fmt
55         cd -
56         ;;
57     failure)
58         git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
59         cd ${INTEGRATION}/failure-1.X
60         check_fmt
61         cd -
62         ;;
63     *)
64         git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
65         cd ${INTEGRATION}
66         check_fmt
67         cd -
68         ;;
69 esac