|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -set -ex |
4 | | - |
5 | | -echo Testing num-complex on rustc ${TRAVIS_RUST_VERSION} |
6 | | - |
7 | | -case "$TRAVIS_RUST_VERSION" in |
8 | | - 1.31.*) FEATURES="libm serde" ;; |
9 | | - *) FEATURES="libm serde rand" ;; |
10 | | -esac |
11 | | - |
12 | | -# num-complex should build and test everywhere. |
13 | | -cargo build --verbose |
14 | | -cargo test --verbose |
15 | | - |
16 | | -# It should build with minimal features too. |
| 3 | +set -e |
| 4 | + |
| 5 | +CRATE=num-complex |
| 6 | +MSRV=1.31 |
| 7 | + |
| 8 | +get_rust_version() { |
| 9 | + local array=($(rustc --version)); |
| 10 | + echo "${array[1]}"; |
| 11 | + return 0; |
| 12 | +} |
| 13 | +RUST_VERSION=$(get_rust_version) |
| 14 | + |
| 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 | +} |
| 23 | + |
| 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 |
| 28 | +fi |
| 29 | + |
| 30 | +FEATURES=(libm serde) |
| 31 | +check_version 1.32 && FEATURES+=(rand) |
| 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` |
17 | 41 | cargo build --no-default-features |
18 | 42 | cargo test --no-default-features |
19 | 43 |
|
20 | | -# Each isolated feature should also work everywhere. |
21 | | -for feature in $FEATURES; do |
22 | | - cargo build --verbose --no-default-features --features="$feature" |
23 | | - cargo test --verbose --no-default-features --features="$feature" |
| 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" |
24 | 51 | done |
25 | 52 |
|
26 | | -# test all supported features together |
27 | | -cargo build --features="$FEATURES" |
28 | | -cargo test --features="$FEATURES" |
| 53 | +# test all supported features, with and without std |
| 54 | +cargo build --features="std ${FEATURES[*]}" |
| 55 | +cargo test --features="std ${FEATURES[*]}" |
29 | 56 |
|
30 | | -# test all supported features together with std |
31 | | -cargo build --features="std $FEATURES" |
32 | | -cargo test --features="std $FEATURES" |
| 57 | +cargo build --features="${FEATURES[*]}" |
| 58 | +cargo test --features="${FEATURES[*]}" |
0 commit comments