bitcoin: Add DO_FEATURE_MATRIX

Add a feature matrix section to the `bitcoin` CI script as we do in
`hashes`. This means:

- test with no default features
- test with all individual features
- test with all combinations of two features

Note, with this applied all features and optional dependencies are
included in `FEATURES` (excluding `secp-lowmemory`).

The feature matrix test gets run for stable and MSRV toolchains.
This commit is contained in:
Tobin C. Harding 2023-12-06 10:03:13 +11:00
parent 48879e7ad9
commit b72f1d70e5
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 26 additions and 14 deletions

View File

@ -2,7 +2,7 @@
set -ex set -ex
FEATURES="base64 bitcoinconsensus serde rand secp-recovery" FEATURES="std rand-std rand serde secp-recovery bitcoinconsensus-std base64 bitcoinconsensus"
if [ "$DO_COV" = true ] if [ "$DO_COV" = true ]
then then
@ -23,6 +23,13 @@ if cargo --version | grep beta; then
STABLE=false STABLE=false
fi fi
# Make all cargo invocations verbose
export CARGO_TERM_VERBOSE=true
# Defaults / sanity checks
cargo build
cargo test
if [ "$DO_LINT" = true ] if [ "$DO_LINT" = true ]
then then
cargo clippy --locked --all-features --all-targets -- -D warnings cargo clippy --locked --all-features --all-targets -- -D warnings
@ -53,20 +60,25 @@ then
fi fi
fi fi
echo "********* Testing std *************" if [ "$DO_FEATURE_MATRIX" = true ]; then
# Test without any features other than std first cargo build --locked --no-default-features
cargo test --locked --verbose --no-default-features --features="std" cargo test --locked --no-default-features
echo "********* Testing default *************" # All features
# Then test with the default features cargo build --locked --no-default-features --features="$FEATURES"
cargo test --verbose cargo test --locked --no-default-features --features="$FEATURES"
# Single features
# Test each feature
for feature in ${FEATURES} for feature in ${FEATURES}
do do
echo "********* Testing $feature *************" cargo build --locked --no-default-features --features="$feature"
cargo test --locked --verbose --features="$feature" cargo test --locked --no-default-features --features="$feature"
# All combos of two features
for featuretwo in ${FEATURES}; do
cargo build --locked --no-default-features --features="$feature $featuretwo"
cargo test --locked --no-default-features --features="$feature $featuretwo"
done done
done
fi
cargo run --locked --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd cargo run --locked --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd
cargo run --locked --no-default-features --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd cargo run --locked --no-default-features --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd