mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
16384599a8
Summary: This allows code that is being exercised under async_unit to call into code that expects a Tokio 0.2 environment (e.g. 0.2 timers). Unfortunately, this requires turning off LSAN for the async_unit tests, since it looks like LSAN and Tokio 0.2 don't work very well together, resulting in LSAN reporting leaked memory for some TLS structures that were initialized by tokio-preview (regardless of whether the Runtime is being dropped): https://fb.workplace.com/groups/rust.language/permalink/3249964938385432/ Considering async_unit is effectively only used in Mononoke, and Mononoke already turns off LSAN in tests for precisely this reason ... it's probably reasonable to do the same here. The main body of changes here is also about updating the majority of our changes to stop calling wait(), and use this new async unit everywhere. This is effectively a pretty big batch conversion of all of our tests to use async fns instead of the former approaches. I've also updated a substantial number of utility functions to be async fns. A few notable changes here: - Some pushrebase tests were pretty flaky — the race they look for isn't deterministic. I added some actual waiting (using pushrebase hooks) to make it more deterministic. This is kinda copy pasted from the globalrev hook (where I had introduced this first), but this will do for now. - The multiplexblob tests don't work at all with new futures, because they call `poll()` all over the place. I've updated them to new futures, which required a bit of reworking. - I took out a couple tests in async unit that were broken anyway. Reviewed By: StanislavGlebik Differential Revision: D19902539 fbshipit-source-id: 352b4a531ef5fa855114c1dd8bb4d70ed967dd55
112 lines
4.7 KiB
Rust
112 lines
4.7 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::{Future, Stream};
|
|
|
|
use blobrepo_utils::{BonsaiMFVerify, BonsaiMFVerifyResult};
|
|
use context::CoreContext;
|
|
|
|
use crate::$repo;
|
|
|
|
#[fbinit::test]
|
|
fn test(fb: FacebookInit) {
|
|
async_unit::tokio_unit_test(async move {
|
|
let ctx = CoreContext::test_mock(fb);
|
|
|
|
let repo = $repo::getrepo(fb).await;
|
|
let heads = repo.get_heads_maybe_stale(ctx.clone()).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());
|
|
tokio::spawn(
|
|
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::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);
|
|
}),
|
|
);
|
|
})
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
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);
|
|
}
|