44#
55# The "strict" feature is used to configure cargo to deny all warnings, always use it in test runs.
66
7- set -ex
8-
9- FEATURES=" std alloc"
7+ set -eu
8+ set -x
109
1110# Some tests require certain toolchain types.
1211NIGHTLY=false
12+ MIN_VERSION=false
1313if cargo --version | grep nightly; then
1414 NIGHTLY=true
1515fi
16+ if cargo --version | grep 1.41; then
17+ MIN_VERSION=true
18+ fi
1619
1720# Sanity, check tools exist.
1821cargo --version
1922rustc --version
2023
2124# Run the linter if told to.
22- if [ " $DO_LINT " = true ]
25+ if [ " ${ DO_LINT-false} " = true ]
2326then
2427 cargo clippy --all-features --all-targets -- -D warnings
2528fi
2629
2730# Run formatter if told to.
28- if [ " $DO_FMT " = true ]; then
31+ if [ " ${ DO_FMT-false} " = true ]; then
2932 if [ " $NIGHTLY " = false ]; then
3033 echo " DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
3134 exit 1
@@ -34,16 +37,34 @@ if [ "$DO_FMT" = true ]; then
3437 cargo fmt --check
3538fi
3639
40+ check () {
41+ cargo build --no-default-features --features=" strict $1 "
42+ cargo test --no-default-features --features=" strict $1 "
43+ }
44+
3745# Check without features ("strict" is a CI feature only, see above).
38- cargo build --no-default-features --features=" strict"
39- cargo test --no-default-features --features=" strict"
46+ check " "
4047
41- # Check "std" feature (implies "alloc", so this is equivalent to --all-features).
42- cargo build --no-default-features --features=" strict std"
43- cargo test --no-default-features --features=" strict std"
48+ # Check "arrayvec" feature alone.
49+ if [ " $MIN_VERSION " != true ]; then
50+ check " arrayvec"
51+ fi
4452
4553# Check "alloc" feature alone.
46- cargo build --no-default-features --features=" strict alloc"
47- cargo test --no-default-features --features=" strict alloc"
54+ check " alloc"
55+
56+ # Check "alloc" & "arrayvec" features together.
57+ if [ " $MIN_VERSION " != true ]; then
58+ check " alloc arrayvec"
59+ fi
60+
61+ # Check "std" feature (implies "alloc", so this is equivalent to --all-features).
62+ cargo build --no-default-features --features=" std"
63+ cargo test --no-default-features --features=" std"
64+
65+ # Check "std" & "arrayvec" features together.
66+ if [ " $MIN_VERSION " != true ]; then
67+ check " std arrayvec"
68+ fi
4869
4970exit 0
0 commit comments