From fb23a94b930654affcd43ad1959d7d9d483f9e6d Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Sat, 24 Dec 2022 09:50:41 +1100 Subject: [PATCH] Improve test coverage for docs build Currently the docs build commands in `hashes` and `bitcoin` differ, they should be the same. Add a command `cargo doc` to improve coverage e.g., recently we botched the feature guarding but since CI only runs `cargo rustdoc` with custom compiler conditional set we didn't catch it. --- bitcoin/contrib/test.sh | 9 ++++++++- hashes/contrib/test.sh | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bitcoin/contrib/test.sh b/bitcoin/contrib/test.sh index 0dd15588cf..14698f4fcd 100755 --- a/bitcoin/contrib/test.sh +++ b/bitcoin/contrib/test.sh @@ -80,10 +80,17 @@ cargo run --example ecdsa-psbt --features=bitcoinconsensus cargo run --example taproot-psbt --features=rand-std,bitcoinconsensus # Build the docs if told to (this only works with the nightly toolchain) -if [ "$DO_DOCS" = true ]; then +if [ "$DO_DOCSRS" = true ]; then + # We use rustdoc so that we can check for broken links. RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --all-features -- -D rustdoc::broken-intra-doc-links -D warnings 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 + cargo +stable doc --all-features +fi + # Fuzz if told to if [ "$DO_FUZZ" = true ] then diff --git a/hashes/contrib/test.sh b/hashes/contrib/test.sh index bdd3462f5d..6a340f0062 100755 --- a/hashes/contrib/test.sh +++ b/hashes/contrib/test.sh @@ -55,8 +55,15 @@ if [ "$DO_SCHEMARS_TESTS" = true ]; then fi # Build the docs if told to (this only works with the nightly toolchain) +if [ "$DO_DOCSRS" = true ]; then + # We use rustdoc so that we can check for broken links. + RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --all-features -- -D rustdoc::broken-intra-doc-links -D warnings +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="--cfg docsrs" cargo doc --features="$FEATURES" + cargo +stable doc --all-features fi # Webassembly stuff