Skip to content

Commit 788c52a

Browse files
authored
Merge pull request #2693 from gnzlbg/integration
Add integration tests against crates in the rust-lang-nursery
2 parents eca7796 + c79f39a commit 788c52a

File tree

2 files changed

+134
-25
lines changed

2 files changed

+134
-25
lines changed

.travis.yml

+56-25
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,78 @@
11
sudo: false
22
language: rust
3-
rust:
4-
# - stable
5-
# - beta
6-
- nightly
7-
os:
8-
- linux
9-
- osx
3+
rust: nightly
4+
os: linux
105
cache:
116
directories:
127
- $HOME/.cargo
138

14-
matrix:
15-
include:
16-
# Make sure tests will pass on beta
17-
- env: CFG_RELEASE_CHANNEL=beta
18-
199
addons:
2010
apt:
2111
packages:
2212
- libcurl4-openssl-dev
2313
- libelf-dev
2414
- libdw-dev
2515

16+
matrix:
17+
include:
18+
- env: DEPLOY=LINUX
19+
- env: CFG_RELEASE_CHANNEL=beta
20+
- os: osx
21+
- env: INTEGRATION=cargo
22+
- env: INTEGRATION=rust-clippy
23+
- env: INTEGRATION=mdbook
24+
- env: INTEGRATION=stdsimd
25+
- env: INTEGRATION=rust-semverver
26+
- env: INTEGRATION=chalk
27+
- env: INTEGRATION=crater
28+
- env: INTEGRATION=futures-rs
29+
- env: INTEGRATION=rand
30+
- env: INTEGRATION=failure
31+
- env: INTEGRATION=glob
32+
- env: INTEGRATION=error-chain
33+
- env: INTEGRATION=tempdir
34+
- env: INTEGRATION=bitflags
35+
- env: INTEGRATION=log
36+
allow_failures:
37+
- env: INTEGRATION=cargo
38+
- env: INTEGRATION=stdsimd
39+
- env: INTEGRATION=mdbook
40+
- env: INTEGRATION=crater
41+
- env: INTEGRATION=rust-semverver
42+
- env: INTEGRATION=rust-clippy
43+
- env: INTEGRATION=chalk
44+
- env: INTEGRATION=bitflags
45+
- env: INTEGRATION=error-chain
46+
- env: INTEGRATION=failure
47+
- env: INTEGRATION=futures-rs
48+
- env: INTEGRATION=log
49+
- env: INTEGRATION=rand
50+
2651
before_script:
2752
- |
28-
if [ $TRAVIS_OS_NAME = 'osx' ]; then
29-
virtualenv env &&
30-
source env/bin/activate &&
31-
python --version &&
32-
pip install 'travis-cargo<0.2'
33-
else
34-
pip install 'travis-cargo<0.2' --user &&
35-
export PATH="$(python -m site --user-base)/bin:$PATH"
53+
if [ -z ${INTEGRATION} ]; then
54+
if [ $TRAVIS_OS_NAME = 'osx' ]; then
55+
virtualenv env &&
56+
source env/bin/activate &&
57+
python --version &&
58+
pip install 'travis-cargo<0.2'
59+
else
60+
pip install 'travis-cargo<0.2' --user &&
61+
export PATH="$(python -m site --user-base)/bin:$PATH"
62+
fi
3663
fi
3764
3865
script:
39-
- |
40-
cargo build &&
41-
cargo test
66+
- |
67+
if [ -z ${INTEGRATION} ]; then
68+
cargo build
69+
cargo test
70+
else
71+
./ci/integration.sh
72+
fi
4273
4374
after_success:
44-
- travis-cargo coveralls --no-sudo
75+
- if [ -z ${INTEGRATION} ]; then travis-cargo coveralls --no-sudo; fi
4576

4677
before_deploy:
4778
# TODO: cross build
@@ -57,5 +88,5 @@ deploy:
5788
on:
5889
repo: nrc/rustfmt
5990
tags: true
60-
condition: "$TRAVIS_OS_NAME = linux"
91+
condition: "$DEPLOY = LINUX"
6192
skip_cleanup: true

ci/integration.sh

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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

0 commit comments

Comments
 (0)