]> git.lizzy.rs Git - rust.git/blob - ci/integration.sh
Add integration tests against crates in the rust-lang-nursery
[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 is causing the build to fail when rustfmt is found in .cargo/bin
8 # but cargo-fmt is not found.
9 #
10 # `which rustfmt` fails if rustfmt is not found. Since we don't install
11 # `rustfmt` via `rustup`, this is the case unless we manually install it. Once
12 # that happens, `cargo install --force` will be called, which installs
13 # `rustfmt`, `cargo-fmt`, etc to `~/.cargo/bin`. This directory is cached by
14 # travis (see `.travis.yml`'s "cache" key), such that build-bots that arrive
15 # here after the first installation will find `rustfmt` and won't need to build
16 # it again.
17 #
18 # which rustfmt || cargo install --force
19 cargo install --force
20
21 echo "Integration tests for: ${INTEGRATION}"
22
23 function check_fmt {
24     cargo fmt --all -v -- --error-on-unformatted &> rustfmt_output
25     if [[ $? != 0 ]]; then
26         return 1
27     fi
28     cat rustfmt_output
29     ! cat rustfmt_output | grep -q "internal error"
30     if [[ $? != 0 ]]; then
31         return 1
32     fi
33     ! cat rustfmt_output | grep -q "warning"
34     if [[ $? != 0 ]]; then
35         return 1
36     fi
37     ! cat rustfmt_output | grep -q "Warning"
38     if [[ $? != 0 ]]; then
39         return 1
40     fi
41     cargo test --all
42     if [[ $? != 0 ]]; then
43         return $?
44     fi
45 }
46
47 function check {
48     cargo test --all
49     if [[ $? != 0 ]]; then
50         return 1
51     fi
52     check_fmt
53     if [[ $? != 0 ]]; then
54         return 1
55     fi
56 }
57
58 case ${INTEGRATION} in
59     cargo)
60         git clone https://github.com/rust-lang/${INTEGRATION}.git
61         cd ${INTEGRATION}
62         export CFG_DISABLE_CROSS_TESTS=1
63         check
64         cd -
65         ;;
66     failure)
67         git clone https://github.com/rust-lang-nursery/${INTEGRATION}.git
68         cd ${INTEGRATION}/failure-1.X
69         check
70         cd -
71         ;;
72     *)
73         git clone https://github.com/rust-lang-nursery/${INTEGRATION}.git
74         cd ${INTEGRATION}
75         check
76         cd -
77         ;;
78 esac