Merge rust-bitcoin/rust-bitcoin#1545: Add CI script for the `internals` crate

f4e7def72f internals: Add CI test script (Tobin C. Harding)
db6b3f1df5 Fix method names in rustdoc (Tobin C. Harding)
7593f1f334 Use set -ex (Tobin C. Harding)

Pull request description:

  Quick merge this while noone's looking ... we forgot to test the new `internals` crate in CI.

ACKs for top commit:
  Kixunil:
    ACK f4e7def72f
  apoelstra:
    ACK f4e7def72f

Tree-SHA512: c603d2308911210eeed17f128ef684ea161e33f5749d3d5567bb15ac4a01695eb07718873e53824bb21159427b453b04265db6728b9839a13092a6817ac9c4d8
This commit is contained in:
Andrew Poelstra 2023-01-15 20:15:07 +00:00
commit 57098872ae
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
5 changed files with 63 additions and 7 deletions

View File

@ -20,7 +20,7 @@ jobs:
DO_LINT: true DO_LINT: true
AS_DEPENDENCY: false AS_DEPENDENCY: false
DO_NO_STD: true DO_NO_STD: true
DO_FEATURE_MATRIX: true # Currently only used in hashes crate. DO_FEATURE_MATRIX: true
DO_SCHEMARS_TESTS: true # Currently only used in hashes crate. DO_SCHEMARS_TESTS: true # Currently only used in hashes crate.
run: ./contrib/test.sh run: ./contrib/test.sh
@ -70,7 +70,7 @@ jobs:
uses: dtolnay/rust-toolchain@1.41.1 uses: dtolnay/rust-toolchain@1.41.1
- name: Running test script - name: Running test script
env: env:
DO_FEATURE_MATRIX: true # Currently only used in hashes crate. DO_FEATURE_MATRIX: true
run: ./contrib/test.sh run: ./contrib/test.sh
NoStd: NoStd:

View File

@ -2,7 +2,7 @@
set -ex set -ex
CRATES="bitcoin hashes" CRATES="bitcoin hashes internals"
for crate in ${CRATES} for crate in ${CRATES}
do do

View File

@ -1,4 +1,6 @@
#!/bin/sh -ex #!/bin/sh
set -ex
FEATURES="serde serde-std std core2" FEATURES="serde serde-std std core2"

54
internals/contrib/test.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/sh
set -ex
FEATURES="std alloc"
cargo --version
rustc --version
# Work out if we are using a nightly toolchain.
NIGHTLY=false
if cargo --version | grep nightly >/dev/null; then
NIGHTLY=true
fi
# Make all cargo invocations verbose
export CARGO_TERM_VERBOSE=true
# Defaults / sanity checks
cargo build
cargo test
if [ "$DO_LINT" = true ]
then
cargo clippy --all-features --all-targets -- -D warnings
fi
if [ "$DO_FEATURE_MATRIX" = true ]; then
# No features
cargo build --no-default-features
cargo test --no-default-features
# All features
cargo build --no-default-features --features="$FEATURES"
cargo test --no-default-features --features="$FEATURES"
# Single features
for feature in ${FEATURES}
do
cargo build --no-default-features --features="$feature"
cargo test --no-default-features --features="$feature"
done
fi
# Build the docs if told to (this only works with the nightly toolchain)
if [ "$DO_DOCSRS" = true ]; then
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
fi
# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
# above this checks that we feature guarded docs imports correctly.
if [ "$DO_DOCS" = true ]; then
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
fi

View File

@ -112,7 +112,7 @@ impl<'a> DisplayHex for &'a [u8] {
} }
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(feature = "alloc"))] #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<'a> DisplayHex for &'a alloc::vec::Vec<u8> { impl<'a> DisplayHex for &'a alloc::vec::Vec<u8> {
type Display = DisplayByteSlice<'a>; type Display = DisplayByteSlice<'a>;
@ -130,7 +130,7 @@ impl<'a> DisplayHex for &'a alloc::vec::Vec<u8> {
/// Displays byte slice as hex. /// Displays byte slice as hex.
/// ///
/// Created by [`<&[u8] as DisplayHex>::display_hex`](DisplayHex::display_hex). /// Created by [`<&[u8] as DisplayHex>::as_hex`](DisplayHex::as_hex).
pub struct DisplayByteSlice<'a> { pub struct DisplayByteSlice<'a> {
// pub because we want to keep lengths in sync // pub because we want to keep lengths in sync
pub(crate) bytes: &'a [u8], pub(crate) bytes: &'a [u8],
@ -166,7 +166,7 @@ impl<'a> fmt::UpperHex for DisplayByteSlice<'a> {
/// Displays byte array as hex. /// Displays byte array as hex.
/// ///
/// Created by [`<&[u8; LEN] as DisplayHex>::display_hex`](DisplayHex::display_hex). /// Created by [`<&[u8; LEN] as DisplayHex>::as_hex`](DisplayHex::as_hex).
pub struct DisplayArray<A: Clone + IntoIterator, B: FixedLenBuf> where A::Item: Borrow<u8> { pub struct DisplayArray<A: Clone + IntoIterator, B: FixedLenBuf> where A::Item: Borrow<u8> {
array: A, array: A,
_buffer_marker: core::marker::PhantomData<B>, _buffer_marker: core::marker::PhantomData<B>,