mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
Refactor ReachabilityIndex tests to accept a closure instead of a trait object
Summary: The tests for ReachabilityIndex now accept a closure that creates a trait object, instead of a trait object directly. I was having problems later in this stack where I couldn't pass a SkiplistIndex object into these tests, because it help Arcs and hence wasnt 'UnwindSafe'. Modifying the tests to take a closure that creates the index object inside of the tokio async unit test fixes this. Reviewed By: StanislavGlebik Differential Revision: D9009053 fbshipit-source-id: de5e698b4d27aec1ab47fa7fda73da8ad46aab95
This commit is contained in:
parent
bf8a175125
commit
98fecf7f7c
@ -117,19 +117,19 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn linear_reachability() {
|
||||
let bfs = GenerationNumberBFS::new();
|
||||
test_linear_reachability(bfs);
|
||||
let bfs_constructor = || GenerationNumberBFS::new();
|
||||
test_linear_reachability(bfs_constructor);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn merge_uneven_reachability() {
|
||||
let bfs = GenerationNumberBFS::new();
|
||||
test_merge_uneven_reachability(bfs);
|
||||
let bfs_constructor = || GenerationNumberBFS::new();
|
||||
test_merge_uneven_reachability(bfs_constructor);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn branch_wide_reachability() {
|
||||
let bfs = GenerationNumberBFS::new();
|
||||
test_branch_wide_reachability(bfs);
|
||||
let bfs_constructor = || GenerationNumberBFS::new();
|
||||
test_branch_wide_reachability(bfs_constructor);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
use async_unit;
|
||||
use futures::future::Future;
|
||||
use std::panic::UnwindSafe;
|
||||
use std::sync::Arc;
|
||||
|
||||
use mercurial_types::HgNodeHash;
|
||||
@ -21,9 +20,10 @@ pub fn string_to_nodehash(hash: &'static str) -> HgNodeHash {
|
||||
|
||||
use index::ReachabilityIndex;
|
||||
|
||||
pub fn test_linear_reachability<T: 'static + ReachabilityIndex + UnwindSafe + Send>(mut index: T) {
|
||||
pub fn test_linear_reachability<T: ReachabilityIndex + 'static>(index_creator: fn() -> T) {
|
||||
async_unit::tokio_unit_test(move || {
|
||||
let repo = Arc::new(linear::getrepo(None));
|
||||
let mut index = index_creator();
|
||||
let ordered_hashes = vec![
|
||||
string_to_nodehash("a9473beb2eb03ddb1cccc3fbaeb8a4820f9cd157"),
|
||||
string_to_nodehash("0ed509bf086fadcb8a8a5384dc3b550729b0fc17"),
|
||||
@ -48,11 +48,10 @@ pub fn test_linear_reachability<T: 'static + ReachabilityIndex + UnwindSafe + Se
|
||||
});
|
||||
}
|
||||
|
||||
pub fn test_merge_uneven_reachability<T: 'static + ReachabilityIndex + UnwindSafe + Send>(
|
||||
mut index: T,
|
||||
) {
|
||||
pub fn test_merge_uneven_reachability<T: ReachabilityIndex + 'static>(index_creator: fn() -> T) {
|
||||
async_unit::tokio_unit_test(move || {
|
||||
let repo = Arc::new(merge_uneven::getrepo(None));
|
||||
let mut index = index_creator();
|
||||
let root_node = string_to_nodehash("15c40d0abc36d47fb51c8eaec51ac7aad31f669c");
|
||||
|
||||
// order is oldest to newest
|
||||
@ -102,12 +101,11 @@ pub fn test_merge_uneven_reachability<T: 'static + ReachabilityIndex + UnwindSaf
|
||||
}
|
||||
});
|
||||
}
|
||||
pub fn test_branch_wide_reachability<T: 'static + ReachabilityIndex + UnwindSafe + Send>(
|
||||
mut index: T,
|
||||
) {
|
||||
pub fn test_branch_wide_reachability<T: ReachabilityIndex + 'static>(index_creator: fn() -> T) {
|
||||
async_unit::tokio_unit_test(move || {
|
||||
// this repo has no merges but many branches
|
||||
let repo = Arc::new(branch_wide::getrepo(None));
|
||||
let mut index = index_creator();
|
||||
let root_node = string_to_nodehash("ecba698fee57eeeef88ac3dcc3b623ede4af47bd");
|
||||
|
||||
let b1 = string_to_nodehash("9e8521affb7f9d10e9551a99c526e69909042b20");
|
||||
|
Loading…
Reference in New Issue
Block a user