|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -set -ex |
| 3 | +set -e |
4 | 4 |
|
5 | | -echo Testing num-integer on rustc ${TRAVIS_RUST_VERSION} |
| 5 | +CRATE=num-integer |
| 6 | +MSRV=1.8 |
6 | 7 |
|
7 | | -# num-integer should build and test everywhere. |
8 | | -cargo build --verbose |
9 | | -cargo test --verbose |
| 8 | +get_rust_version() { |
| 9 | + local array=($(rustc --version)); |
| 10 | + echo "${array[1]}"; |
| 11 | + return 0; |
| 12 | +} |
| 13 | +RUST_VERSION=$(get_rust_version) |
10 | 14 |
|
11 | | -# test `no_std` |
12 | | -cargo build --verbose --no-default-features |
13 | | -cargo test --verbose --no-default-features |
| 15 | +check_version() { |
| 16 | + IFS=. read -ra rust <<< "$RUST_VERSION" |
| 17 | + IFS=. read -ra want <<< "$1" |
| 18 | + [[ "${rust[0]}" -gt "${want[0]}" || |
| 19 | + ( "${rust[0]}" -eq "${want[0]}" && |
| 20 | + "${rust[1]}" -ge "${want[1]}" ) |
| 21 | + ]] |
| 22 | +} |
14 | 23 |
|
15 | | -# test `i128` |
16 | | -if [[ "$TRAVIS_RUST_VERSION" =~ ^(nightly|beta|stable)$ ]]; then |
17 | | - cargo build --verbose --features=i128 |
18 | | - cargo test --verbose --features=i128 |
| 24 | +echo "Testing $CRATE on rustc $RUST_VERSION" |
| 25 | +if ! check_version $MSRV ; then |
| 26 | + echo "The minimum for $CRATE is rustc $MSRV" |
| 27 | + exit 1 |
19 | 28 | fi |
20 | 29 |
|
21 | | -if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then |
22 | | - cargo test --verbose --all-features --benches |
| 30 | +FEATURES=() |
| 31 | +check_version 1.26 && FEATURES+=(i128) |
| 32 | +echo "Testing supported features: ${FEATURES[*]}" |
| 33 | + |
| 34 | +set -x |
| 35 | + |
| 36 | +# test the default |
| 37 | +cargo build |
| 38 | +cargo test |
| 39 | + |
| 40 | +# test `no_std` |
| 41 | +cargo build --no-default-features |
| 42 | +cargo test --no-default-features |
| 43 | + |
| 44 | +# test each isolated feature, with and without std |
| 45 | +for feature in ${FEATURES[*]}; do |
| 46 | + cargo build --no-default-features --features="std $feature" |
| 47 | + cargo test --no-default-features --features="std $feature" |
| 48 | + |
| 49 | + cargo build --no-default-features --features="$feature" |
| 50 | + cargo test --no-default-features --features="$feature" |
| 51 | +done |
| 52 | + |
| 53 | +# test all supported features, with and without std |
| 54 | +cargo build --features="std ${FEATURES[*]}" |
| 55 | +cargo test --features="std ${FEATURES[*]}" |
| 56 | + |
| 57 | +cargo build --features="${FEATURES[*]}" |
| 58 | +cargo test --features="${FEATURES[*]}" |
| 59 | + |
| 60 | +if rustc --version | grep -q nightly; then |
| 61 | + cargo test --all-features --benches |
23 | 62 | fi |
0 commit comments