forked from rust-num/num-bigint
/
test_full.sh
executable file
·83 lines (66 loc) · 2.21 KB
/
test_full.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
set -e
CRATE=num-bigint
MSRV=1.31
get_rust_version() {
local array=($(rustc --version));
echo "${array[1]}";
return 0;
}
RUST_VERSION=$(get_rust_version)
check_version() {
IFS=. read -ra rust <<< "$RUST_VERSION"
IFS=. read -ra want <<< "$1"
[[ "${rust[0]}" -gt "${want[0]}" ||
( "${rust[0]}" -eq "${want[0]}" &&
"${rust[1]}" -ge "${want[1]}" )
]]
}
echo "Testing $CRATE on rustc $RUST_VERSION"
if ! check_version $MSRV ; then
echo "The minimum for $CRATE is rustc $MSRV"
exit 1
fi
STD_FEATURES=(serde)
check_version 1.36 && STD_FEATURES+=(rand)
check_version 1.36 && NO_STD_FEATURES=(serde rand)
check_version 1.40 && STD_FEATURES+=(arbitrary)
check_version 1.46 && STD_FEATURES+=(quickcheck)
echo "Testing supported features: ${STD_FEATURES[*]}"
if [ -n "${NO_STD_FEATURES[*]}" ]; then
echo " no_std supported features: ${NO_STD_FEATURES[*]}"
fi
set -x
# test the default with std
cargo build
cargo test
# test each isolated feature with std
for feature in ${STD_FEATURES[*]}; do
cargo build --no-default-features --features="std $feature"
cargo test --no-default-features --features="std $feature"
done
# test all supported features with std
cargo build --no-default-features --features="std ${STD_FEATURES[*]}"
cargo test --no-default-features --features="std ${STD_FEATURES[*]}"
if [ -n "${NO_STD_FEATURES[*]}" ]; then
# test minimal `no_std`
cargo build --no-default-features
cargo test --no-default-features
# test each isolated feature without std
for feature in ${NO_STD_FEATURES[*]}; do
cargo build --no-default-features --features="$feature"
cargo test --no-default-features --features="$feature"
done
# test all supported features without std
cargo build --no-default-features --features="${NO_STD_FEATURES[*]}"
cargo test --no-default-features --features="${NO_STD_FEATURES[*]}"
fi
# make sure benchmarks can be built and sanity-tested
if rustc --version | grep -q nightly; then
cargo test --all-features --benches
fi
case "${STD_FEATURES[*]}" in
*serde*) cargo test --manifest-path ci/big_serde/Cargo.toml ;;&
*rand*) cargo test --manifest-path ci/big_rand/Cargo.toml ;;&
*quickcheck*) cargo test --manifest-path ci/big_quickcheck/Cargo.toml ;;&
esac