|
2 | 2 |
|
3 | 3 | set -e |
4 | 4 |
|
| 5 | +CRATE=num-rational |
| 6 | +MSRV=1.31 |
| 7 | + |
5 | 8 | get_rust_version() { |
6 | 9 | local array=($(rustc --version)); |
7 | 10 | echo "${array[1]}"; |
8 | 11 | return 0; |
9 | 12 | } |
| 13 | +RUST_VERSION=$(get_rust_version) |
10 | 14 |
|
11 | | -if [ -z ${TRAVIS+x} ] |
12 | | -then RUST_VERSION=$(get_rust_version) # we're not in travis |
13 | | -else RUST_VERSION=$TRAVIS_RUST_VERSION # we're in travis |
14 | | -fi |
| 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 | +} |
15 | 23 |
|
16 | | -if [ -z "${RUST_VERSION}" ] |
17 | | -then echo "WARNING: RUST_VERSION is undefined or empty string" 1>&2 |
18 | | -else echo Testing num-rational on rustc "${RUST_VERSION}" |
| 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 |
|
| 30 | +STD_FEATURES=(bigint-std serde) |
| 31 | +NO_STD_FEATURES=(serde) |
| 32 | +check_version 1.36 && NO_STD_FEATURES+=(bigint) |
| 33 | +echo "Testing supported features: ${STD_FEATURES[*]}" |
| 34 | +echo " no_std supported features: ${NO_STD_FEATURES[*]}" |
| 35 | + |
21 | 36 | set -x |
22 | 37 |
|
23 | | -STD_FEATURES="bigint-std serde" |
| 38 | +# test the default with std |
| 39 | +cargo build |
| 40 | +cargo test |
24 | 41 |
|
25 | | -case "$RUST_VERSION" in |
26 | | - 1.3[1-5].*) NO_STD_FEATURES="serde" ;; |
27 | | - *) NO_STD_FEATURES="bigint serde" ;; |
28 | | -esac |
| 42 | +# test each isolated feature with std |
| 43 | +for feature in ${STD_FEATURES[*]}; do |
| 44 | + cargo build --no-default-features --features="std $feature" |
| 45 | + cargo test --no-default-features --features="std $feature" |
| 46 | +done |
29 | 47 |
|
| 48 | +# test all supported features with std |
| 49 | +cargo build --no-default-features --features="std ${STD_FEATURES[*]}" |
| 50 | +cargo test --no-default-features --features="std ${STD_FEATURES[*]}" |
30 | 51 |
|
31 | | -# num-rational should build and test everywhere. |
32 | | -cargo build --verbose |
33 | | -cargo test --verbose |
34 | 52 |
|
35 | | -# It should build with minimal features too. |
| 53 | +# test minimal `no_std` |
36 | 54 | cargo build --no-default-features |
37 | 55 | cargo test --no-default-features |
38 | 56 |
|
39 | | -# Each isolated feature should also work everywhere. |
40 | | -for feature in $STD_FEATURES; do |
41 | | - cargo build --verbose --no-default-features --features="std $feature" |
42 | | - cargo test --verbose --no-default-features --features="std $feature" |
43 | | -done |
44 | | - |
45 | | -# test all supported features together |
46 | | -cargo build --features="std $STD_FEATURES" |
47 | | -cargo test --features="std $STD_FEATURES" |
48 | | - |
49 | | -# Each no-std isolated feature should also work everywhere. |
50 | | -for feature in $NO_STD_FEATURES; do |
51 | | - cargo build --verbose --no-default-features --features="$feature" |
52 | | - cargo test --verbose --no-default-features --features="$feature" |
| 57 | +# test each isolated feature without std |
| 58 | +for feature in ${NO_STD_FEATURES[*]}; do |
| 59 | + cargo build --no-default-features --features="$feature" |
| 60 | + cargo test --no-default-features --features="$feature" |
53 | 61 | done |
54 | 62 |
|
55 | | -# test all no-std supported features together |
56 | | -cargo build --no-default-features --features="$NO_STD_FEATURES" |
57 | | -cargo test --no-default-features --features="$NO_STD_FEATURES" |
| 63 | +# test all supported features without std |
| 64 | +cargo build --no-default-features --features="${NO_STD_FEATURES[*]}" |
| 65 | +cargo test --no-default-features --features="${NO_STD_FEATURES[*]}" |
0 commit comments