11#! /bin/sh
22#
33# CI test script for rust-bech32.
4- #
5- # The "strict" feature is used to configure cargo to deny all warnings, always use it in test runs.
64
75set -eu
86set -x
97
8+ # "arrayvec" feature breaks the MSRV, its added manually in DO_FEATURE_MATRIX loop below.
9+ FEATURES=" std alloc"
10+
1011# Some tests require certain toolchain types.
1112NIGHTLY=false
12- MIN_VERSION =false
13+ MSRV =false
1314if cargo --version | grep nightly; then
1415 NIGHTLY=true
1516fi
16- if cargo --version | grep 1.41 ; then
17- MIN_VERSION =true
17+ if cargo --version | grep " 1\.48 " ; then
18+ MSRV =true
1819fi
1920
21+ build_and_test () {
22+ cargo build --no-default-features --features=" $1 "
23+ cargo test --no-default-features --features=" $1 "
24+ }
25+
2026# Sanity, check tools exist.
2127cargo --version
2228rustc --version
@@ -37,34 +43,21 @@ if [ "${DO_FMT-false}" = true ]; then
3743 cargo fmt --check
3844fi
3945
40- check () {
41- cargo build --no-default-features --features=" strict $1 "
42- cargo test --no-default-features --features=" strict $1 "
43- }
44-
45- # Check without features ("strict" is a CI feature only, see above).
46- check " "
47-
48- # Check "arrayvec" feature alone.
49- if [ " $MIN_VERSION " != true ]; then
50- check " arrayvec"
51- fi
52-
53- # Check "alloc" feature alone.
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"
46+ if [ " ${DO_FEATURE_MATRIX-false} " = true ]; then
47+ # No features
48+ build_and_test " "
49+
50+ # Feature combos
51+ build_and_test " std"
52+ build_and_test " alloc"
53+ build_and_test " std alloc"
54+ # arrayvec breaks the MSRV
55+ if [ $MSRV = false
56+ ]; then
57+ build_and_test " arrayvec"
58+ build_and_test " std arrayvec"
59+ build_and_test " alloc arrayvec"
60+ fi
6861fi
6962
7063exit 0
0 commit comments