Skip to content

Commit 1b2d437

Browse files
committed
Merge #482: Remove unstable feature
1a33e67 Remove unstable feature (Tobin C. Harding) Pull request description: Currently it is not possible to run the test suite with `cargo test --all-features`, this is because we use a feature called `unstable` to enable the unstable `test` crate that is used for benchmarking. There is another way to conditionally enable the test crate and guard the benchmark code. We can use a custom configuration option `bench` and then set it using `RUSTFLAGS='--cfg=bench`. ACKs for top commit: apoelstra: ACK 1a33e67 Tree-SHA512: ad250f79f476a137336e5f8a4b3004407f45be9b068ed0782dfde4b2af1ecae9721c5364e2aba69194460abe52cff9785b2121e4e8f4af4520208ab42f4ecb9e
2 parents d3af6d9 + 1a33e67 commit 1b2d437

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ no-std = ["hashbrown", "bitcoin/no-std"]
1717
compiler = []
1818
trace = []
1919

20-
unstable = []
2120
serde = ["actual-serde", "bitcoin/serde"]
2221
rand = ["bitcoin/rand"]
2322
base64 = ["bitcoin/base64"]

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ architectural mismatches. If you have any questions or ideas you want to discuss
5353
please join us in
5454
[##miniscript](https://web.libera.chat/?channels=##miniscript) on Libera.
5555

56+
## Benchmarks
57+
58+
We use a custom Rust compiler configuration conditional to guard the bench mark code. To run the
59+
bench marks use: `RUSTFLAGS='--cfg=bench' cargo +nightly bench`.
60+
5661

5762
## Release Notes
5863

contrib/test.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ FEATURES="compiler serde rand base64"
77
cargo --version
88
rustc --version
99

10+
# Cache the toolchain we are using.
11+
NIGHTLY=false
12+
if cargo --version | grep nightly; then
13+
NIGHTLY=true
14+
fi
15+
1016
# Format if told to
1117
if [ "$DO_FMT" = true ]
1218
then
@@ -77,10 +83,18 @@ then
7783
done
7884
fi
7985

80-
# Bench if told to (this only works with the nightly toolchain)
86+
# Bench if told to, only works with non-stable toolchain (nightly, beta).
8187
if [ "$DO_BENCH" = true ]
8288
then
83-
cargo bench --features="unstable compiler"
89+
if [ "$NIGHTLY" = false ]; then
90+
if [ -n "$RUSTUP_TOOLCHAIN" ]; then
91+
echo "RUSTUP_TOOLCHAIN is set to a non-nightly toolchain but DO_BENCH requires a nightly toolchain"
92+
else
93+
echo "DO_BENCH requires a nightly toolchain"
94+
fi
95+
exit 1
96+
fi
97+
RUSTFLAGS='--cfg=bench' cargo bench
8498
fi
8599

86100
# Build the docs if told to (this only works with the nightly toolchain)

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
//!
7575
7676
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
77-
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
77+
// Experimental features we need.
78+
#![cfg_attr(bench, feature(test))]
7879
// Coding conventions
7980
#![deny(unsafe_code)]
8081
#![deny(non_upper_case_globals)]
@@ -107,7 +108,8 @@ extern crate core;
107108

108109
#[cfg(feature = "serde")]
109110
pub use actual_serde as serde;
110-
#[cfg(all(test, feature = "unstable"))]
111+
112+
#[cfg(bench)]
111113
extern crate test;
112114

113115
#[macro_use]

src/policy/compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ mod tests {
15981598
}
15991599
}
16001600

1601-
#[cfg(all(test, feature = "unstable"))]
1601+
#[cfg(bench)]
16021602
mod benches {
16031603
use std::str::FromStr;
16041604

src/policy/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ mod tests {
541541
}
542542
}
543543

544-
#[cfg(all(test, feature = "compiler", feature = "unstable"))]
544+
#[cfg(all(bench, feature = "compiler"))]
545545
mod benches {
546546
use core::str::FromStr;
547547

0 commit comments

Comments
 (0)