mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
097e4ad00c
Summary: The earlier diffs in this stack have removed all our dependencies on the Tokio 0.1 runtime environment (so, basically, `tokio-executor` and `tokio-timer`), so we don't need this anymore. We do still have some deps on `tokio-io`, but this is just traits + helpers, so this doesn't actually prevent us from removing the 0.1 runtime! Note that we still have a few transitive dependencies on Tokio 0.1: - async-unit uses tokio-compat - hg depends on tokio-compat too, and we depend on it in tests This isn't the end of the world though, we can live with that :) Reviewed By: ahornby Differential Revision: D26544410 fbshipit-source-id: 24789be2402c3f48220dcaad110e8246ef02ecd8
110 lines
4.2 KiB
Rust
110 lines
4.2 KiB
Rust
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#![deny(warnings)]
|
|
|
|
use fixtures::*;
|
|
|
|
// An extra level of nesting is required to avoid clashes between crate and module names.
|
|
mod test {
|
|
macro_rules! test_verify {
|
|
($repo:ident) => {
|
|
mod $repo {
|
|
use std::collections::HashSet;
|
|
|
|
use fbinit::FacebookInit;
|
|
use futures::{compat::Future01CompatExt, TryStreamExt};
|
|
use futures_old::{Future, Stream};
|
|
|
|
use blobrepo_hg::BlobRepoHg;
|
|
use blobrepo_utils::{BonsaiMFVerify, BonsaiMFVerifyResult};
|
|
use context::CoreContext;
|
|
|
|
use crate::$repo;
|
|
|
|
#[fbinit::test]
|
|
async fn test(fb: FacebookInit) {
|
|
let ctx = CoreContext::test_mock(fb);
|
|
|
|
let repo = $repo::getrepo(fb).await;
|
|
let heads = repo.get_heads_maybe_stale(ctx.clone()).compat().collect();
|
|
|
|
let verify = BonsaiMFVerify {
|
|
ctx: ctx.clone(),
|
|
logger: ctx.logger().clone(),
|
|
repo,
|
|
follow_limit: 1024,
|
|
ignores: HashSet::new(),
|
|
broken_merges_before: None,
|
|
debug_bonsai_diff: false,
|
|
};
|
|
|
|
let results = heads
|
|
.map_err(|err| panic!("cannot get the heads {}", err))
|
|
.and_then(|heads| verify.verify(heads).collect());
|
|
results
|
|
.and_then(move |results| {
|
|
let diffs = results.into_iter().filter_map(move |(res, meta)| {
|
|
match res {
|
|
BonsaiMFVerifyResult::Invalid(difference) => {
|
|
let cs_id = meta.changeset_id;
|
|
Some(
|
|
difference
|
|
.changes(ctx.clone())
|
|
.collect()
|
|
.map(move |changes| (cs_id, changes)),
|
|
)
|
|
}
|
|
_ => None,
|
|
}
|
|
});
|
|
|
|
futures_old::future::join_all(diffs)
|
|
})
|
|
.map(|diffs| {
|
|
let mut failed = false;
|
|
let mut desc = Vec::new();
|
|
for (changeset_id, changes) in diffs {
|
|
failed = true;
|
|
desc.push(format!(
|
|
"*** Inconsistent roundtrip for {}",
|
|
changeset_id,
|
|
));
|
|
for changed_entry in changes {
|
|
desc.push(format!(" - Changed entry: {:?}", changed_entry));
|
|
}
|
|
desc.push("".to_string());
|
|
}
|
|
let desc = desc.join("\n");
|
|
if failed {
|
|
panic!(
|
|
"Inconsistencies detected, roundtrip test failed\n\n{}",
|
|
desc
|
|
);
|
|
}
|
|
})
|
|
.map_err(|err| {
|
|
panic!("verify error {}", err);
|
|
})
|
|
.compat()
|
|
.await
|
|
.unwrap()
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
test_verify!(branch_even);
|
|
test_verify!(branch_uneven);
|
|
test_verify!(branch_wide);
|
|
test_verify!(linear);
|
|
test_verify!(merge_even);
|
|
test_verify!(merge_uneven);
|
|
test_verify!(unshared_merge_even);
|
|
test_verify!(unshared_merge_uneven);
|
|
}
|