/
test_full.sh
executable file
·58 lines (45 loc) · 1.29 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
#!/bin/bash
set -e
CRATE=num-complex
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
FEATURES=(libm serde)
check_version 1.32 && FEATURES+=(rand)
echo "Testing supported features: ${FEATURES[*]}"
set -x
# test the default
cargo build
cargo test
# test `no_std`
cargo build --no-default-features
cargo test --no-default-features
# test each isolated feature, with and without std
for feature in ${FEATURES[*]}; do
cargo build --no-default-features --features="std $feature"
cargo test --no-default-features --features="std $feature"
cargo build --no-default-features --features="$feature"
cargo test --no-default-features --features="$feature"
done
# test all supported features, with and without std
cargo build --features="std ${FEATURES[*]}"
cargo test --features="std ${FEATURES[*]}"
cargo build --features="${FEATURES[*]}"
cargo test --features="${FEATURES[*]}"