4
4
#
5
5
# The "strict" feature is used to configure cargo to deny all warnings, always use it in test runs.
6
6
7
- set -ex
8
-
9
- FEATURES=" std alloc"
7
+ set -eu
8
+ set -x
10
9
11
10
# Some tests require certain toolchain types.
12
11
NIGHTLY=false
12
+ MIN_VERSION=false
13
13
if cargo --version | grep nightly; then
14
14
NIGHTLY=true
15
15
fi
16
+ if cargo --version | grep 1.41; then
17
+ MIN_VERSION=true
18
+ fi
16
19
17
20
# Sanity, check tools exist.
18
21
cargo --version
19
22
rustc --version
20
23
21
24
# Run the linter if told to.
22
- if [ " $DO_LINT " = true ]
25
+ if [ " ${ DO_LINT-false} " = true ]
23
26
then
24
27
cargo clippy --all-features --all-targets -- -D warnings
25
28
fi
26
29
27
30
# Run formatter if told to.
28
- if [ " $DO_FMT " = true ]; then
31
+ if [ " ${ DO_FMT-false} " = true ]; then
29
32
if [ " $NIGHTLY " = false ]; then
30
33
echo " DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
31
34
exit 1
@@ -34,16 +37,34 @@ if [ "$DO_FMT" = true ]; then
34
37
cargo fmt --check
35
38
fi
36
39
40
+ check () {
41
+ cargo build --no-default-features --features=" strict $1 "
42
+ cargo test --no-default-features --features=" strict $1 "
43
+ }
44
+
37
45
# 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 " "
40
47
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
44
52
45
53
# 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
48
69
49
70
exit 0
0 commit comments