resume proptest

Signed-off-by: ekexium <ekexium@gmail.com>
This commit is contained in:
ekexium 2020-09-11 15:04:55 +08:00
parent ca017b1bb7
commit ee999c50a6
5 changed files with 14 additions and 16 deletions

View File

@ -1,9 +1,4 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
/*
* FIXME: temporarily disable proptest because proptest-derive doesn't work in Rust 1.48.0 nightly.
* Resume them when the issue is fixed.
use super::{arb_batch, pd_addrs};
use crate::{raw::Client, Config, KvPair, Value};
use futures::executor::block_on;
@ -63,5 +58,3 @@ proptest! {
}
}
}
*/

View File

@ -13,8 +13,6 @@ regex = "1"
serde = "1.0"
serde_derive = "1.0"
log = "0.4"
proptest = "0.9"
proptest-derive = "0.1.0"
derive-new = "0.5"
kvproto = { git = "https://github.com/pingcap/kvproto.git", rev = "1e28226154c374788f38d3a542fc505cd74720f3", features = [ "prost-codec" ], default-features = false }

View File

@ -3,6 +3,8 @@
use super::Key;
use crate::{Error, Result};
use kvproto::kvrpcpb;
#[cfg(test)]
use proptest_derive::Arbitrary;
use std::{
borrow::Borrow,
cmp::{Eq, PartialEq},
@ -53,7 +55,7 @@ use std::{
/// on ranges will accept any types which implement `Into<BoundRange>`.
/// which means all of the above types can be passed directly to those functions.
#[derive(Clone, Debug, Eq, PartialEq)]
// #[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(test, derive(Arbitrary))]
pub struct BoundRange {
from: Bound<Key>,
to: Bound<Key>,

View File

@ -3,7 +3,10 @@
use super::HexRepr;
use kvproto::kvrpcpb;
#[allow(unused_imports)]
#[cfg(test)]
use proptest::{arbitrary::any_with, collection::size_range};
#[cfg(test)]
use proptest_derive::Arbitrary;
use std::{fmt, ops::Bound, u8};
const _PROPTEST_KEY_MAX: usize = 1024 * 2; // 2 KB
@ -50,13 +53,13 @@ const _PROPTEST_KEY_MAX: usize = 1024 * 2; // 2 KB
/// Many functions which accept a `Key` accept an `Into<Key>`, which means all of the above types
/// can be passed directly to those functions.
#[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
// #[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(test, derive(Arbitrary))]
#[repr(transparent)]
pub struct Key(
// #[cfg_attr(
// test,
// proptest(strategy = "any_with::<Vec<u8>>((size_range(_PROPTEST_KEY_MAX), ()))")
// )]
#[cfg_attr(
test,
proptest(strategy = "any_with::<Vec<u8>>((size_range(_PROPTEST_KEY_MAX), ()))")
)]
pub(super) Vec<u8>,
);

View File

@ -2,6 +2,8 @@
use super::{HexRepr, Key, Value};
use kvproto::kvrpcpb;
#[cfg(test)]
use proptest_derive::Arbitrary;
use std::{fmt, str};
/// A key/value pair.
@ -18,7 +20,7 @@ use std::{fmt, str};
/// Many functions which accept a `KvPair` accept an `Into<KvPair>`, which means all of the above
/// types (Like a `(Key, Value)`) can be passed directly to those functions.
#[derive(Default, Clone, Eq, PartialEq)]
// #[cfg(test, derive(Arbitrary))]
#[cfg_attr(test, derive(Arbitrary))]
pub struct KvPair(pub Key, pub Value);
impl KvPair {