radicle: Fix flaky test due to randomness
This commit is contained in:
parent
d973fd42f2
commit
14c204a11f
|
|
@ -678,8 +678,8 @@ impl store::FromHistory for Patch {
|
|||
// case of a rebase off the master branch, or a redaction of the
|
||||
// merge.
|
||||
let Ok(head) = repo.reference_oid(&op.author, &branch) else {
|
||||
continue;
|
||||
};
|
||||
continue;
|
||||
};
|
||||
if commit != head && !repo.is_ancestor_of(commit, head)? {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,19 +49,6 @@ impl<K: hash::Hash + Eq, V> AddressBook<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Cycle through the keys at random. The random cycle repeats ad-infintum.
|
||||
pub fn cycle(&self) -> impl Iterator<Item = &K> {
|
||||
self.shuffled().map(|(k, _)| k).cycle()
|
||||
}
|
||||
|
||||
/// Return a shuffled iterator over the keys.
|
||||
pub fn shuffled(&self) -> std::vec::IntoIter<(&K, &V)> {
|
||||
let mut items = self.inner.iter().collect::<Vec<_>>();
|
||||
self.rng.shuffle(&mut items);
|
||||
|
||||
items.into_iter()
|
||||
}
|
||||
|
||||
/// Return a new address book with the given RNG.
|
||||
pub fn with(self, rng: fastrand::Rng) -> Self {
|
||||
Self {
|
||||
|
|
@ -71,6 +58,22 @@ impl<K: hash::Hash + Eq, V> AddressBook<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<K: hash::Hash + Eq + Ord, V> AddressBook<K, V> {
|
||||
/// Return a shuffled iterator over the keys.
|
||||
pub fn shuffled(&self) -> std::vec::IntoIter<(&K, &V)> {
|
||||
let mut items = self.inner.iter().collect::<Vec<_>>();
|
||||
items.sort_by_key(|(k, _)| *k);
|
||||
self.rng.shuffle(&mut items);
|
||||
|
||||
items.into_iter()
|
||||
}
|
||||
|
||||
/// Cycle through the keys at random. The random cycle repeats ad-infintum.
|
||||
pub fn cycle(&self) -> impl Iterator<Item = &K> {
|
||||
self.shuffled().map(|(k, _)| k).cycle()
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: hash::Hash + Eq, V> Deref for AddressBook<K, V> {
|
||||
type Target = RandomMap<K, V>;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue