2019-01-24 16:37:55 +00:00
|
|
|
#!/bin/sh -ex
|
|
|
|
|
2021-06-09 10:34:44 +00:00
|
|
|
FEATURES="base64 bitcoinconsensus use-serde rand secp-recovery"
|
|
|
|
|
|
|
|
# Use toolchain if explicitly specified
|
|
|
|
if [ -n "$TOOLCHAIN" ]
|
|
|
|
then
|
|
|
|
alias cargo="cargo +$TOOLCHAIN"
|
|
|
|
fi
|
2019-01-24 16:37:55 +00:00
|
|
|
|
2021-01-09 16:43:18 +00:00
|
|
|
pin_common_verions() {
|
2020-12-28 18:57:43 +00:00
|
|
|
cargo generate-lockfile --verbose
|
|
|
|
cargo update -p cc --precise "1.0.41" --verbose
|
|
|
|
cargo update -p serde --precise "1.0.98" --verbose
|
|
|
|
cargo update -p serde_derive --precise "1.0.98" --verbose
|
2021-01-09 16:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Pin `cc` for Rust 1.29
|
2021-06-09 10:34:44 +00:00
|
|
|
if [ "$PIN_VERSIONS" = true ]; then
|
2021-01-09 16:43:18 +00:00
|
|
|
pin_common_verions
|
|
|
|
cargo update -p byteorder --precise "1.3.4"
|
2020-12-28 18:57:43 +00:00
|
|
|
fi
|
|
|
|
|
2019-07-26 19:23:02 +00:00
|
|
|
if [ "$DO_COV" = true ]
|
|
|
|
then
|
|
|
|
export RUSTFLAGS="-C link-dead-code"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-06-09 10:34:44 +00:00
|
|
|
echo "********* Testing std *************"
|
|
|
|
# Test without any features other than std first
|
|
|
|
cargo test --verbose --no-default-features --features="std"
|
2019-01-24 16:37:55 +00:00
|
|
|
|
2021-06-09 10:34:44 +00:00
|
|
|
echo "********* Testing default *************"
|
2020-10-07 15:46:48 +00:00
|
|
|
# Then test with the default features
|
2019-01-24 16:37:55 +00:00
|
|
|
cargo test --verbose
|
|
|
|
|
2021-06-09 10:34:44 +00:00
|
|
|
if [ "$DO_NO_STD" = true ]
|
|
|
|
then
|
|
|
|
echo "********* Testing no-std build *************"
|
|
|
|
# Build no_std, to make sure that cfg(test) doesn't hide any issues
|
|
|
|
cargo build --verbose --features="no-std" --no-default-features
|
|
|
|
|
|
|
|
# Build std + no_std, to make sure they are not incompatible
|
|
|
|
cargo build --verbose --features="no-std"
|
|
|
|
|
|
|
|
# Test no_std
|
|
|
|
cargo test --verbose --features="no-std" --no-default-features
|
|
|
|
|
|
|
|
# Build all features
|
|
|
|
cargo build --verbose --features="no-std $FEATURES" --no-default-features
|
|
|
|
|
|
|
|
# Build specific features
|
|
|
|
for feature in ${FEATURES}
|
|
|
|
do
|
|
|
|
cargo build --verbose --features="no-std $feature"
|
|
|
|
done
|
|
|
|
|
2022-01-09 15:10:57 +00:00
|
|
|
cargo run --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd
|
|
|
|
cargo run --no-default-features --features no-std --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd
|
2021-06-09 10:34:44 +00:00
|
|
|
fi
|
|
|
|
|
2019-01-24 16:37:55 +00:00
|
|
|
# Test each feature
|
|
|
|
for feature in ${FEATURES}
|
|
|
|
do
|
2021-06-09 10:34:44 +00:00
|
|
|
echo "********* Testing "$feature" *************"
|
2019-01-24 16:37:55 +00:00
|
|
|
cargo test --verbose --features="$feature"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Fuzz if told to
|
|
|
|
if [ "$DO_FUZZ" = true ]
|
|
|
|
then
|
|
|
|
(
|
|
|
|
cd fuzz
|
|
|
|
cargo test --verbose
|
|
|
|
./travis-fuzz.sh
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Bench if told to
|
|
|
|
if [ "$DO_BENCH" = true ]
|
|
|
|
then
|
|
|
|
cargo bench --features unstable
|
|
|
|
fi
|
2019-08-18 16:26:52 +00:00
|
|
|
|
|
|
|
# Use as dependency if told to
|
2021-06-09 10:34:44 +00:00
|
|
|
if [ "$AS_DEPENDENCY" = true ]
|
2019-08-18 16:26:52 +00:00
|
|
|
then
|
|
|
|
cargo new dep_test
|
|
|
|
cd dep_test
|
|
|
|
echo 'bitcoin = { path = "..", features = ["use-serde"] }' >> Cargo.toml
|
2020-09-10 17:55:47 +00:00
|
|
|
|
2020-09-10 20:06:10 +00:00
|
|
|
# Pin `cc` for Rust 1.29
|
2021-01-01 20:03:20 +00:00
|
|
|
if [ -n "$PIN_VERSIONS" ]; then
|
2021-01-09 16:43:18 +00:00
|
|
|
pin_common_verions
|
2020-09-10 17:55:47 +00:00
|
|
|
fi
|
|
|
|
|
2019-08-18 16:26:52 +00:00
|
|
|
cargo test --verbose
|
|
|
|
fi
|