From 6c12cbcf9d1396ec8028ea3f17430e3d20c3c89f Mon Sep 17 00:00:00 2001 From: Wiktor Kwapisiewicz Date: Fri, 18 Sep 2020 10:47:48 +0200 Subject: openpgp: Remove `quickcheck` feature. - Adjust code to test for `cfg(test)` only, - Remove `quickcheck` and `rand` from dependencies so that they stay only in dev-dependencies, - Remove mention of `x-quickcheck` feature from the documentation, - Fixes #545. --- openpgp/Cargo.toml | 10 ---------- openpgp/README.md | 9 --------- openpgp/src/armor.rs | 4 ++-- openpgp/src/crypto/mpi.rs | 14 +++++++------- openpgp/src/crypto/s2k.rs | 6 +++--- openpgp/src/fingerprint.rs | 4 ++-- openpgp/src/keyid.rs | 4 ++-- openpgp/src/packet/compressed_data.rs | 4 ++-- openpgp/src/packet/key.rs | 8 ++++---- openpgp/src/packet/literal.rs | 4 ++-- openpgp/src/packet/marker.rs | 4 ++-- openpgp/src/packet/mod.rs | 6 +++--- openpgp/src/packet/one_pass_sig.rs | 6 +++--- openpgp/src/packet/pkesk.rs | 6 +++--- openpgp/src/packet/signature/mod.rs | 20 ++++++++++---------- openpgp/src/packet/signature/subpacket.rs | 26 +++++++++++++------------- openpgp/src/packet/skesk.rs | 8 ++++---- openpgp/src/packet/tag.rs | 4 ++-- openpgp/src/packet/trust.rs | 4 ++-- openpgp/src/packet/user_attribute.rs | 10 +++++----- openpgp/src/packet/userid.rs | 4 ++-- openpgp/src/types/features.rs | 4 ++-- openpgp/src/types/key_flags.rs | 4 ++-- openpgp/src/types/mod.rs | 22 +++++++++++----------- openpgp/src/types/revocation_key.rs | 4 ++-- openpgp/src/types/server_preferences.rs | 4 ++-- openpgp/src/types/timestamp.rs | 6 +++--- 27 files changed, 95 insertions(+), 114 deletions(-) (limited to 'openpgp') diff --git a/openpgp/Cargo.toml b/openpgp/Cargo.toml index b88eb0ab..13e0a67a 100644 --- a/openpgp/Cargo.toml +++ b/openpgp/Cargo.toml @@ -38,8 +38,6 @@ lazy_static = "1.3" libc = "0.2" memsec = "0.5.6" nettle = { version = "7", optional = true } -quickcheck = { version = "0.9", default-features = false, optional = true } -rand = { version = "0.7", default-features = false, optional = true } regex = "1" thiserror = "1" backtrace = "0.3.46" @@ -75,14 +73,6 @@ compression-bzip2 = ["bzip2", "buffered-reader/compression-bzip2"] vendored = ["vendored-nettle"] vendored-nettle = ["nettle/vendored"] -# Testing, debugging, and fuzzing. - -# XXX: This feature should just be called 'quickcheck'. However, this -# currently collides with the implicitly created feature for the -# optional dependency 'quickcheck'. Blocker: -# https://github.com/rust-lang/cargo/issues/5565 -x-quickcheck = ["quickcheck", "rand"] - [[example]] name = "pad" required-features = ["compression-deflate"] diff --git a/openpgp/README.md b/openpgp/README.md index 14a846eb..6fc50577 100644 --- a/openpgp/README.md +++ b/openpgp/README.md @@ -81,15 +81,6 @@ algorithms, `compression-deflate` to enable *DEFLATE* and *zlib* compression support, and `compression-bzip2` to enable *bzip2* support. -## Testing, debugging, and fuzzing - -Sequoia uses [`quickcheck`] in tests. To use it as a downstream user, -enable the `x-quickcheck` feature (this feature will be called just -`quickcheck` once [this feature] is implemented). - -[`quickcheck`]: https://docs.rs/quickcheck -[this feature]: https://github.com/rust-lang/cargo/issues/5565 - # Minimum Supported Rust Version (MSRV) `sequoia-openpgp` requires Rust 1.46.0. diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index 0cd071d7..68a1a8bc 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -35,7 +35,7 @@ use std::cmp; use std::str; use std::borrow::Cow; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::vec_truncate; @@ -70,7 +70,7 @@ pub enum Kind { File, } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Kind { fn arbitrary(g: &mut G) -> Self { use self::Kind::*; diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index 2cddbb05..5088e9f3 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -18,9 +18,9 @@ use std::fmt; use std::cmp::Ordering; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use rand::Rng; use crate::types::{ @@ -245,7 +245,7 @@ impl Hash for MPI { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for MPI { fn arbitrary(g: &mut G) -> Self { loop { @@ -555,7 +555,7 @@ impl Hash for PublicKey { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for PublicKey { fn arbitrary(g: &mut G) -> Self { use self::PublicKey::*; @@ -822,7 +822,7 @@ impl Hash for SecretKeyMaterial { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for SecretKeyMaterial { fn arbitrary(g: &mut G) -> Self { match g.gen_range(0, 6) { @@ -929,7 +929,7 @@ impl Hash for Ciphertext { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Ciphertext { fn arbitrary(g: &mut G) -> Self { match g.gen_range(0, 3) { @@ -1023,7 +1023,7 @@ impl Hash for Signature { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Signature { fn arbitrary(g: &mut G) -> Self { match g.gen_range(0, 4) { diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs index 84b75b02..f403589c 100644 --- a/openpgp/src/crypto/s2k.rs +++ b/openpgp/src/crypto/s2k.rs @@ -14,9 +14,9 @@ use crate::crypto::SessionKey; use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use rand::Rng; /// String-to-Key (S2K) specifiers. @@ -370,7 +370,7 @@ impl fmt::Display for S2K { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for S2K { fn arbitrary(g: &mut G) -> Self { #[allow(deprecated)] diff --git a/openpgp/src/fingerprint.rs b/openpgp/src/fingerprint.rs index 5cc5907e..07559d7c 100644 --- a/openpgp/src/fingerprint.rs +++ b/openpgp/src/fingerprint.rs @@ -1,6 +1,6 @@ use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; /// A long identifier for certificates and keys. @@ -216,7 +216,7 @@ impl Fingerprint { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Fingerprint { fn arbitrary(g: &mut G) -> Self { use rand::Rng; diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs index 1d0410df..e5bd9bcb 100644 --- a/openpgp/src/keyid.rs +++ b/openpgp/src/keyid.rs @@ -1,6 +1,6 @@ use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::Error; @@ -262,7 +262,7 @@ impl KeyID { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for KeyID { fn arbitrary(g: &mut G) -> Self { KeyID::new(u64::arbitrary(g)) diff --git a/openpgp/src/packet/compressed_data.rs b/openpgp/src/packet/compressed_data.rs index 4f379496..bc673890 100644 --- a/openpgp/src/packet/compressed_data.rs +++ b/openpgp/src/packet/compressed_data.rs @@ -1,6 +1,6 @@ use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::packet; @@ -96,7 +96,7 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for CompressedData { fn arbitrary(g: &mut G) -> Self { use rand::Rng; diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index 462c5396..728075e2 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -91,7 +91,7 @@ use std::cmp::Ordering; use std::convert::TryInto; use std::time; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::Error; @@ -1506,7 +1506,7 @@ impl Encrypted { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for super::Key where P: KeyParts, P: Clone, R: KeyRole, R: Clone, @@ -1517,7 +1517,7 @@ impl Arbitrary for super::Key } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Key4 { fn arbitrary(g: &mut G) -> Self { let mpis = mpi::PublicKey::arbitrary(g); @@ -1534,7 +1534,7 @@ impl Arbitrary for Key4 { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Key4 { fn arbitrary(g: &mut G) -> Self { use rand::Rng; diff --git a/openpgp/src/packet/literal.rs b/openpgp/src/packet/literal.rs index 7eb4082b..f9865fbc 100644 --- a/openpgp/src/packet/literal.rs +++ b/openpgp/src/packet/literal.rs @@ -3,7 +3,7 @@ use std::cmp; use std::convert::TryInto; use std::time; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::types::{DataFormat, Timestamp}; @@ -174,7 +174,7 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Literal { fn arbitrary(g: &mut G) -> Self { let mut l = Literal::new(DataFormat::arbitrary(g)); diff --git a/openpgp/src/packet/marker.rs b/openpgp/src/packet/marker.rs index 728f115b..ecd50dbe 100644 --- a/openpgp/src/packet/marker.rs +++ b/openpgp/src/packet/marker.rs @@ -1,4 +1,4 @@ -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::packet; @@ -35,7 +35,7 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Marker { fn arbitrary(_: &mut G) -> Self { Self::default() diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index b0d1dcdb..f18a9d6d 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -161,7 +161,7 @@ use std::ops::{Deref, DerefMut}; use std::slice; use std::iter::IntoIterator; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::Error; @@ -439,7 +439,7 @@ impl<'a> DerefMut for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Packet { fn arbitrary(g: &mut G) -> Self { use rand::Rng; @@ -485,7 +485,7 @@ pub struct Common { dummy: std::marker::PhantomData<()>, } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Common { fn arbitrary(_: &mut G) -> Self { // XXX: Change if this gets interesting fields. diff --git a/openpgp/src/packet/one_pass_sig.rs b/openpgp/src/packet/one_pass_sig.rs index d0524c21..281747e1 100644 --- a/openpgp/src/packet/one_pass_sig.rs +++ b/openpgp/src/packet/one_pass_sig.rs @@ -6,7 +6,7 @@ use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::Error; @@ -168,14 +168,14 @@ impl<'a> std::convert::TryFrom<&'a Signature> for OnePassSig3 { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for super::OnePassSig { fn arbitrary(g: &mut G) -> Self { OnePassSig3::arbitrary(g).into() } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for OnePassSig3 { fn arbitrary(g: &mut G) -> Self { let mut ops = OnePassSig3::new(SignatureType::arbitrary(g)); diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs index 8b914194..5ea6ff66 100644 --- a/openpgp/src/packet/pkesk.rs +++ b/openpgp/src/packet/pkesk.rs @@ -5,7 +5,7 @@ //! //! [Section 5.1 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.1 -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::Error; @@ -190,14 +190,14 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for super::PKESK { fn arbitrary(g: &mut G) -> Self { PKESK3::arbitrary(g).into() } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for PKESK3 { fn arbitrary(g: &mut G) -> Self { let (ciphertext, pk_algo) = loop { diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index ec2cc35d..f7eec3f8 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -118,7 +118,7 @@ use std::fmt; use std::ops::{Deref, DerefMut}; use std::time::SystemTime; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::Error; @@ -146,7 +146,7 @@ use crate::packet::signature::subpacket::{ SubpacketTag, }; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] /// Like quickcheck::Arbitrary, but bounded. trait ArbitraryBounded { /// Generates an arbitrary value, but only recurses if `depth > @@ -154,11 +154,11 @@ trait ArbitraryBounded { fn arbitrary_bounded(g: &mut G, depth: usize) -> Self; } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] /// Default depth when implementing Arbitrary using ArbitraryBounded. const DEFAULT_ARBITRARY_DEPTH: usize = 2; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] macro_rules! impl_arbitrary_with_bound { ($typ:path) => { impl Arbitrary for $typ { @@ -220,7 +220,7 @@ pub struct SignatureFields { subpackets: SubpacketAreas, } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl ArbitraryBounded for SignatureFields { fn arbitrary_bounded(g: &mut G, depth: usize) -> Self { SignatureFields { @@ -235,7 +235,7 @@ impl ArbitraryBounded for SignatureFields { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl_arbitrary_with_bound!(SignatureFields); impl Deref for SignatureFields { @@ -2479,17 +2479,17 @@ impl From for super::Signature { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl ArbitraryBounded for super::Signature { fn arbitrary_bounded(g: &mut G, depth: usize) -> Self { Signature4::arbitrary_bounded(g, depth).into() } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl_arbitrary_with_bound!(super::Signature); -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl ArbitraryBounded for Signature4 { fn arbitrary_bounded(g: &mut G, depth: usize) -> Self { use mpi::MPI; @@ -2532,7 +2532,7 @@ impl ArbitraryBounded for Signature4 { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl_arbitrary_with_bound!(Signature4); #[cfg(test)] diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 5146202e..afab45bd 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -63,9 +63,9 @@ use std::fmt; use std::cmp; use std::time; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use crate::packet::signature::ArbitraryBounded; use crate::{ @@ -408,7 +408,7 @@ impl From for u8 { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for SubpacketTag { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() @@ -504,7 +504,7 @@ pub struct SubpacketArea { parsed: Mutex>>>, } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl ArbitraryBounded for SubpacketArea { fn arbitrary_bounded(g: &mut G, depth: usize) -> Self { use rand::Rng; @@ -518,7 +518,7 @@ impl ArbitraryBounded for SubpacketArea { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl_arbitrary_with_bound!(SubpacketArea); impl Default for SubpacketArea { @@ -976,7 +976,7 @@ pub struct NotationData { value: Vec, } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for NotationData { fn arbitrary(g: &mut G) -> Self { NotationData { @@ -1021,7 +1021,7 @@ impl NotationData { #[derive(Clone, PartialEq, Eq, Hash)] pub struct NotationDataFlags(crate::types::Bitfield); -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for NotationDataFlags { fn arbitrary(g: &mut G) -> Self { NotationDataFlags(vec![u8::arbitrary(g), u8::arbitrary(g), @@ -1419,7 +1419,7 @@ pub enum SubpacketValue { #[doc(hidden)] __Nonexhaustive, } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl ArbitraryBounded for SubpacketValue { fn arbitrary_bounded(g: &mut G, depth: usize) -> Self { use rand::Rng; @@ -1470,7 +1470,7 @@ impl ArbitraryBounded for SubpacketValue { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl_arbitrary_with_bound!(SubpacketValue); impl SubpacketValue { @@ -1575,7 +1575,7 @@ pub struct Subpacket { value: SubpacketValue, } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl ArbitraryBounded for Subpacket { fn arbitrary_bounded(g: &mut G, depth: usize) -> Self { use rand::Rng; @@ -1620,7 +1620,7 @@ impl ArbitraryBounded for Subpacket { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl_arbitrary_with_bound!(Subpacket); impl fmt::Debug for Subpacket { @@ -1756,7 +1756,7 @@ pub struct SubpacketAreas { unhashed_area: SubpacketArea, } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl ArbitraryBounded for SubpacketAreas { fn arbitrary_bounded(g: &mut G, depth: usize) -> Self { SubpacketAreas::new(ArbitraryBounded::arbitrary_bounded(g, depth), @@ -1764,7 +1764,7 @@ impl ArbitraryBounded for SubpacketAreas { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl_arbitrary_with_bound!(SubpacketAreas); impl SubpacketAreas { diff --git a/openpgp/src/packet/skesk.rs b/openpgp/src/packet/skesk.rs index d5ea7d91..be63e968 100644 --- a/openpgp/src/packet/skesk.rs +++ b/openpgp/src/packet/skesk.rs @@ -8,7 +8,7 @@ use std::ops::{Deref, DerefMut}; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::Result; @@ -39,7 +39,7 @@ impl SKESK { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for SKESK { fn arbitrary(g: &mut G) -> Self { if bool::arbitrary(g) { @@ -299,7 +299,7 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for SKESK4 { fn arbitrary(g: &mut G) -> Self { SKESK4::new(SymmetricAlgorithm::arbitrary(g), @@ -578,7 +578,7 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for SKESK5 { fn arbitrary(g: &mut G) -> Self { let algo = AEADAlgorithm::EAX; // The only one we dig. diff --git a/openpgp/src/packet/tag.rs b/openpgp/src/packet/tag.rs index c7c8ddcf..7ea8c2c0 100644 --- a/openpgp/src/packet/tag.rs +++ b/openpgp/src/packet/tag.rs @@ -2,7 +2,7 @@ use std::fmt; use std::cmp::Ordering; use std::hash::{Hash, Hasher}; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::packet::Packet; @@ -216,7 +216,7 @@ impl fmt::Display for Tag { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Tag { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() diff --git a/openpgp/src/packet/trust.rs b/openpgp/src/packet/trust.rs index af876131..08ab6fe8 100644 --- a/openpgp/src/packet/trust.rs +++ b/openpgp/src/packet/trust.rs @@ -1,6 +1,6 @@ use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::packet; @@ -60,7 +60,7 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Trust { fn arbitrary(g: &mut G) -> Self { Vec::::arbitrary(g).into() diff --git a/openpgp/src/packet/user_attribute.rs b/openpgp/src/packet/user_attribute.rs index 03703c8c..246c1be6 100644 --- a/openpgp/src/packet/user_attribute.rs +++ b/openpgp/src/packet/user_attribute.rs @@ -6,9 +6,9 @@ use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use rand::Rng; use buffered_reader::BufferedReader; @@ -103,7 +103,7 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for UserAttribute { fn arbitrary(g: &mut G) -> Self { UserAttribute::new( @@ -192,7 +192,7 @@ pub enum Subpacket { Unknown(u8, Box<[u8]>), } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Subpacket { fn arbitrary(g: &mut G) -> Self { match g.gen_range(0, 3) { @@ -225,7 +225,7 @@ pub enum Image { Unknown(u8, Box<[u8]>), } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Image { fn arbitrary(g: &mut G) -> Self { match g.gen_range(0, 5) { diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs index 6b9c1eb6..63426e22 100644 --- a/openpgp/src/packet/userid.rs +++ b/openpgp/src/packet/userid.rs @@ -5,7 +5,7 @@ use std::cell::RefCell; use std::cmp::Ordering; use std::sync::Mutex; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use anyhow::Context; @@ -895,7 +895,7 @@ impl From for Packet { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for UserID { fn arbitrary(g: &mut G) -> Self { Vec::::arbitrary(g).into() diff --git a/openpgp/src/types/features.rs b/openpgp/src/types/features.rs index 7e7e4240..828d76fb 100644 --- a/openpgp/src/types/features.rs +++ b/openpgp/src/types/features.rs @@ -1,6 +1,6 @@ use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::types::Bitfield; @@ -355,7 +355,7 @@ const FEATURE_FLAG_MDC: usize = 0; /// Encrypted Session Key Packets (packet 3). const FEATURE_FLAG_AEAD: usize = 1; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Features { fn arbitrary(g: &mut G) -> Self { Self::new(Vec::arbitrary(g)) diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs index c6d0890f..f100768f 100644 --- a/openpgp/src/types/key_flags.rs +++ b/openpgp/src/types/key_flags.rs @@ -1,7 +1,7 @@ use std::fmt; use std::ops::{BitAnd, BitOr}; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::types::Bitfield; @@ -392,7 +392,7 @@ const KEY_FLAG_AUTHENTICATE: usize = 5; /// than one person. const KEY_FLAG_GROUP_KEY: usize = 7; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for KeyFlags { fn arbitrary(g: &mut G) -> Self { Self::new(Vec::arbitrary(g)) diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index dedc5af7..dc98dfe4 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -49,7 +49,7 @@ use std::fmt; use std::str::FromStr; use std::result; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::Error; @@ -267,14 +267,14 @@ impl fmt::Display for PublicKeyAlgorithm { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for PublicKeyAlgorithm { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl PublicKeyAlgorithm { pub(crate) fn arbitrary_for_signing(g: &mut G) -> Self { use rand::Rng; @@ -508,7 +508,7 @@ impl Curve { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Curve { fn arbitrary(g: &mut G) -> Self { match u8::arbitrary(g) % 8 { @@ -681,7 +681,7 @@ impl fmt::Display for SymmetricAlgorithm { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for SymmetricAlgorithm { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() @@ -801,7 +801,7 @@ impl fmt::Display for AEADAlgorithm { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for AEADAlgorithm { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() @@ -948,7 +948,7 @@ impl fmt::Display for CompressionAlgorithm { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for CompressionAlgorithm { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() @@ -1086,7 +1086,7 @@ impl fmt::Display for HashAlgorithm { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for HashAlgorithm { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() @@ -1247,7 +1247,7 @@ impl fmt::Display for SignatureType { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for SignatureType { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() @@ -1395,7 +1395,7 @@ impl fmt::Display for ReasonForRevocation { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for ReasonForRevocation { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() @@ -1646,7 +1646,7 @@ impl fmt::Display for DataFormat { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for DataFormat { fn arbitrary(g: &mut G) -> Self { u8::arbitrary(g).into() diff --git a/openpgp/src/types/revocation_key.rs b/openpgp/src/types/revocation_key.rs index 8064a148..e2b36042 100644 --- a/openpgp/src/types/revocation_key.rs +++ b/openpgp/src/types/revocation_key.rs @@ -1,4 +1,4 @@ -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::{ @@ -149,7 +149,7 @@ const REVOCATION_KEY_FLAG_SENSITIVE: u8 = 0x40; const REVOCATION_KEY_MASK_UNKNOWN: u8 = ! (REVOCATION_KEY_FLAG_MUST_BE_SET | REVOCATION_KEY_FLAG_SENSITIVE); -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for RevocationKey { fn arbitrary(g: &mut G) -> Self { RevocationKey { diff --git a/openpgp/src/types/server_preferences.rs b/openpgp/src/types/server_preferences.rs index 42425d47..ec58d9b2 100644 --- a/openpgp/src/types/server_preferences.rs +++ b/openpgp/src/types/server_preferences.rs @@ -1,6 +1,6 @@ use std::fmt; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::types::Bitfield; @@ -273,7 +273,7 @@ impl KeyServerPreferences { /// by the key holder or an administrator of the key server. const KEYSERVER_PREFERENCE_NO_MODIFY: usize = 7; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for KeyServerPreferences { fn arbitrary(g: &mut G) -> Self { Self::new(Vec::arbitrary(g)) diff --git a/openpgp/src/types/timestamp.rs b/openpgp/src/types/timestamp.rs index 8114df53..33518df7 100644 --- a/openpgp/src/types/timestamp.rs +++ b/openpgp/src/types/timestamp.rs @@ -4,7 +4,7 @@ use std::fmt; use std::time::{SystemTime, Duration as SystemDuration, UNIX_EPOCH}; use std::u32; -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use crate::{ @@ -244,7 +244,7 @@ impl Timestamp { } } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Timestamp { fn arbitrary(g: &mut G) -> Self { Timestamp(u32::arbitrary(g)) @@ -565,7 +565,7 @@ impl Timestamp { pub(crate) const Y2106 : Timestamp = Timestamp(4291747200); } -#[cfg(any(test, feature = "quickcheck"))] +#[cfg(test)] impl Arbitrary for Duration { fn arbitrary(g: &mut G) -> Self { Duration(u32::arbitrary(g)) -- cgit v1.2.3