mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
Fix quickcheck update breakages
Summary: D31115820 (ae87b82eaf
) updated quickcheck, but there's some stuff we need to fix forward. This diff fixes the remaining failures I could find.
Reviewed By: farnz
Differential Revision: D31305392
fbshipit-source-id: a6684d47833bc0fd933751c13cdd71392cb1833b
This commit is contained in:
parent
b09728399c
commit
da13975a4f
@ -12,7 +12,6 @@ anyhow = "1.0"
|
|||||||
ascii = "1.0"
|
ascii = "1.0"
|
||||||
ascii_ext = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
ascii_ext = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||||
quickcheck = "1.0"
|
quickcheck = "1.0"
|
||||||
rand = { version = "0.8", features = ["small_rng"] }
|
|
||||||
sql = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
sql = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
@ -35,7 +35,7 @@ impl Arbitrary for Freshness {
|
|||||||
fn arbitrary(g: &mut Gen) -> Self {
|
fn arbitrary(g: &mut Gen) -> Self {
|
||||||
use Freshness::*;
|
use Freshness::*;
|
||||||
|
|
||||||
match u32::arbitrary(g) & 2 {
|
match u32::arbitrary(g) % 2 {
|
||||||
0 => MostRecent,
|
0 => MostRecent,
|
||||||
1 => MaybeStale,
|
1 => MaybeStale,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -38,7 +38,6 @@ futures-old = { package = "futures", version = "0.1.31" }
|
|||||||
maplit = "1.0"
|
maplit = "1.0"
|
||||||
mononoke_types-mocks = { version = "0.1.0", path = "../../mononoke_types/mocks" }
|
mononoke_types-mocks = { version = "0.1.0", path = "../../mononoke_types/mocks" }
|
||||||
quickcheck = "1.0"
|
quickcheck = "1.0"
|
||||||
quickcheck_derive = "0.3"
|
|
||||||
tokio = { version = "1.10", features = ["full", "test-util", "tracing"] }
|
tokio = { version = "1.10", features = ["full", "test-util", "tracing"] }
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
@ -223,7 +223,7 @@ mod test {
|
|||||||
Some(name) => BookmarkPagination::After(name),
|
Some(name) => BookmarkPagination::After(name),
|
||||||
None => BookmarkPagination::FromStart,
|
None => BookmarkPagination::FromStart,
|
||||||
};
|
};
|
||||||
let have = insert_then_query(
|
let mut have = insert_then_query(
|
||||||
fb,
|
fb,
|
||||||
&bookmarks,
|
&bookmarks,
|
||||||
freshness,
|
freshness,
|
||||||
@ -232,13 +232,15 @@ mod test {
|
|||||||
&pagination,
|
&pagination,
|
||||||
limit,
|
limit,
|
||||||
);
|
);
|
||||||
let want = mock_bookmarks_response(
|
let mut want = mock_bookmarks_response(
|
||||||
&bookmarks,
|
&bookmarks,
|
||||||
&prefix,
|
&prefix,
|
||||||
kinds.as_slice(),
|
kinds.as_slice(),
|
||||||
&pagination,
|
&pagination,
|
||||||
limit,
|
limit,
|
||||||
);
|
);
|
||||||
|
have.sort_by_key(|(_, csid)| *csid);
|
||||||
|
want.sort_by_key(|(_, csid)| *csid);
|
||||||
have == want
|
have == want
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ use mononoke_types_mocks::changesetid::{
|
|||||||
FIVES_CSID, FOURS_CSID, ONES_CSID, SIXES_CSID, THREES_CSID, TWOS_CSID,
|
FIVES_CSID, FOURS_CSID, ONES_CSID, SIXES_CSID, THREES_CSID, TWOS_CSID,
|
||||||
};
|
};
|
||||||
use mononoke_types_mocks::repo::{REPO_ONE, REPO_TWO, REPO_ZERO};
|
use mononoke_types_mocks::repo::{REPO_ONE, REPO_TWO, REPO_ZERO};
|
||||||
use quickcheck_derive::Arbitrary;
|
use quickcheck::{Arbitrary, Gen};
|
||||||
use sql::mysql_async::{prelude::ConvIr, Value};
|
use sql::mysql_async::{prelude::ConvIr, Value};
|
||||||
use sql_construct::SqlConstruct;
|
use sql_construct::SqlConstruct;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -1433,13 +1433,23 @@ async fn bookmark_subscription_updates(fb: FacebookInit) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Arbitrary, Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
enum TestBookmark {
|
enum TestBookmark {
|
||||||
Book1,
|
Book1,
|
||||||
Book2,
|
Book2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Arbitrary, Clone, Copy, Debug)]
|
impl Arbitrary for TestBookmark {
|
||||||
|
fn arbitrary(g: &mut Gen) -> Self {
|
||||||
|
if bool::arbitrary(g) {
|
||||||
|
Self::Book1
|
||||||
|
} else {
|
||||||
|
Self::Book2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug)]
|
||||||
enum BookmarkOp {
|
enum BookmarkOp {
|
||||||
/// Set this bookmark.
|
/// Set this bookmark.
|
||||||
Set(ChangesetId),
|
Set(ChangesetId),
|
||||||
@ -1449,8 +1459,19 @@ enum BookmarkOp {
|
|||||||
Delete,
|
Delete,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Arbitrary for BookmarkOp {
|
||||||
|
fn arbitrary(g: &mut Gen) -> Self {
|
||||||
|
match u32::arbitrary(g) % 3 {
|
||||||
|
0 => Self::Set(Arbitrary::arbitrary(g)),
|
||||||
|
1 => Self::ForceSet(Arbitrary::arbitrary(g)),
|
||||||
|
2 => Self::Delete,
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Use Quickcheck to produce a test scenario of bookmark updates.
|
/// Use Quickcheck to produce a test scenario of bookmark updates.
|
||||||
#[derive(Arbitrary, Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
enum TestOp {
|
enum TestOp {
|
||||||
/// Update one of our test bookmarks
|
/// Update one of our test bookmarks
|
||||||
Bookmark(TestBookmark, BookmarkOp),
|
Bookmark(TestBookmark, BookmarkOp),
|
||||||
@ -1460,6 +1481,17 @@ enum TestOp {
|
|||||||
Refresh,
|
Refresh,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Arbitrary for TestOp {
|
||||||
|
fn arbitrary(g: &mut Gen) -> Self {
|
||||||
|
match u32::arbitrary(g) % 3 {
|
||||||
|
0 => Self::Bookmark(Arbitrary::arbitrary(g), Arbitrary::arbitrary(g)),
|
||||||
|
1 => Self::Noop,
|
||||||
|
2 => Self::Refresh,
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Verify bookmark subscriptions using Quickcheck. We create a test scenario and verify that the
|
/// Verify bookmark subscriptions using Quickcheck. We create a test scenario and verify that the
|
||||||
/// bookmark subscriptions returns the same data it would return if it was freshly created now (we
|
/// bookmark subscriptions returns the same data it would return if it was freshly created now (we
|
||||||
/// test that this satisfies our assumptions in separate tests for the bookmarks subscription).
|
/// test that this satisfies our assumptions in separate tests for the bookmarks subscription).
|
||||||
|
@ -431,8 +431,8 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
quickcheck! {
|
quickcheck! {
|
||||||
fn check_chunk_stream(in_chunks: Vec<Vec<u8>>, size: usize) -> bool {
|
fn check_chunk_stream(in_chunks: Vec<Vec<u8>>, size: u8) -> bool {
|
||||||
let size = size + 1; // Don't allow 0 as the size.
|
let size = (size as usize) + 1; // Don't allow 0 as the size.
|
||||||
let rt = Runtime::new().unwrap();
|
let rt = Runtime::new().unwrap();
|
||||||
rt.block_on(do_check_chunk_stream(in_chunks, size))
|
rt.block_on(do_check_chunk_stream(in_chunks, size))
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ use futures::{
|
|||||||
future::{self, TryFutureExt},
|
future::{self, TryFutureExt},
|
||||||
stream,
|
stream,
|
||||||
};
|
};
|
||||||
use quickcheck::{Arbitrary, StdGen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ fn test_invariants(fb: FacebookInit) -> Result<()> {
|
|||||||
// right for a store() call to succeed (all the chunks need to be saved, then we need to write
|
// right for a store() call to succeed (all the chunks need to be saved, then we need to write
|
||||||
// 3 aliases, and then the content).
|
// 3 aliases, and then the content).
|
||||||
let rt = tokio::runtime::Runtime::new()?;
|
let rt = tokio::runtime::Runtime::new()?;
|
||||||
let mut gen = StdGen::new(rand::thread_rng(), 128);
|
let mut gen = Gen::new(128);
|
||||||
|
|
||||||
let memblob = Arc::new(memblob::Memblob::default());
|
let memblob = Arc::new(memblob::Memblob::default());
|
||||||
let blob = FailingBlobstore::new(memblob.clone(), 0.75, 0.75);
|
let blob = FailingBlobstore::new(memblob.clone(), 0.75, 0.75);
|
||||||
@ -127,7 +127,7 @@ fn test_invariants(fb: FacebookInit) -> Result<()> {
|
|||||||
|
|
||||||
#[fbinit::test]
|
#[fbinit::test]
|
||||||
async fn test_store_bytes_consistency(fb: FacebookInit) -> Result<(), Error> {
|
async fn test_store_bytes_consistency(fb: FacebookInit) -> Result<(), Error> {
|
||||||
let mut gen = StdGen::new(rand::thread_rng(), 128);
|
let mut gen = Gen::new(128);
|
||||||
|
|
||||||
let memblob = Arc::new(memblob::Memblob::default());
|
let memblob = Arc::new(memblob::Memblob::default());
|
||||||
let ctx = CoreContext::test_mock(fb);
|
let ctx = CoreContext::test_mock(fb);
|
||||||
|
@ -203,10 +203,10 @@ mod test {
|
|||||||
// Can't add a set operator if we have don't have at least one node
|
// Can't add a set operator if we have don't have at least one node
|
||||||
revset.push(RevsetEntry::SingleNode(None));
|
revset.push(RevsetEntry::SingleNode(None));
|
||||||
} else {
|
} else {
|
||||||
let input_count = g.gen_range(0..revspecs_in_set) + 1;
|
let input_count = (usize::arbitrary(g) % revspecs_in_set) + 1;
|
||||||
revset.push(
|
revset.push(
|
||||||
// Bias towards SingleNode if we only have 1 rev
|
// Bias towards SingleNode if we only have 1 rev
|
||||||
match g.gen_range(0..4) {
|
match u32::arbitrary(g) % 4 {
|
||||||
0 => RevsetEntry::SingleNode(None),
|
0 => RevsetEntry::SingleNode(None),
|
||||||
1 => {
|
1 => {
|
||||||
if revspecs_in_set >= 2 {
|
if revspecs_in_set >= 2 {
|
||||||
@ -233,7 +233,7 @@ mod test {
|
|||||||
assert!(revspecs_in_set > 0, "Did not produce enough revs");
|
assert!(revspecs_in_set > 0, "Did not produce enough revs");
|
||||||
|
|
||||||
if revspecs_in_set > 1 {
|
if revspecs_in_set > 1 {
|
||||||
revset.push(match g.gen_range(0..2) {
|
revset.push(match u32::arbitrary(g) % 2 {
|
||||||
0 => RevsetEntry::Intersect(revspecs_in_set),
|
0 => RevsetEntry::Intersect(revspecs_in_set),
|
||||||
1 => RevsetEntry::Union(revspecs_in_set),
|
1 => RevsetEntry::Union(revspecs_in_set),
|
||||||
_ => panic!("Range returned too wide a variation"),
|
_ => panic!("Range returned too wide a variation"),
|
||||||
|
@ -24,7 +24,5 @@ vfs = { path = "../vfs" }
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
manifest-tree = { path = "../manifest-tree", features = ["for-tests"] }
|
manifest-tree = { path = "../manifest-tree", features = ["for-tests"] }
|
||||||
quickcheck = "1.0"
|
quickcheck = "1.0"
|
||||||
rand = { version = "0.8", features = ["small_rng"] }
|
|
||||||
rand_chacha = "0.3"
|
|
||||||
tempfile = "3.1"
|
tempfile = "3.1"
|
||||||
walkdir = "2.2.9"
|
walkdir = "2.2.9"
|
||||||
|
@ -813,9 +813,7 @@ mod test {
|
|||||||
use manifest_tree::testutil::{make_tree_manifest_from_meta, TestStore};
|
use manifest_tree::testutil::{make_tree_manifest_from_meta, TestStore};
|
||||||
use manifest_tree::Diff;
|
use manifest_tree::Diff;
|
||||||
use pathmatcher::AlwaysMatcher;
|
use pathmatcher::AlwaysMatcher;
|
||||||
use quickcheck::{Arbitrary, StdGen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
use rand::SeedableRng;
|
|
||||||
use rand_chacha::ChaChaRng;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::create_dir;
|
use std::fs::create_dir;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -889,8 +887,7 @@ mod test {
|
|||||||
|
|
||||||
fn generate_trees(tree_size: usize, count: usize) -> Vec<Vec<(RepoPathBuf, FileMetadata)>> {
|
fn generate_trees(tree_size: usize, count: usize) -> Vec<Vec<(RepoPathBuf, FileMetadata)>> {
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
let rng = ChaChaRng::from_seed([0u8; 32]);
|
let mut gen = Gen::new(5);
|
||||||
let mut gen = StdGen::new(rng, 5);
|
|
||||||
let paths = generate_repo_paths(tree_size * count, &mut gen);
|
let paths = generate_repo_paths(tree_size * count, &mut gen);
|
||||||
|
|
||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
|
@ -139,7 +139,7 @@ mod tests {
|
|||||||
let mut buf = Vec::<u8>::new();
|
let mut buf = Vec::<u8>::new();
|
||||||
let keys: Vec<Vec<u8>> = (0..1000usize)
|
let keys: Vec<Vec<u8>> = (0..1000usize)
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
let mut rng = thread_rng();
|
let rng = thread_rng();
|
||||||
rng.sample_iter(&Alphanumeric).take(i % 40).collect()
|
rng.sample_iter(&Alphanumeric).take(i % 40).collect()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
Loading…
Reference in New Issue
Block a user