Move project assertions into main assertion function
Co-authored-by: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
parent
ef04dc14cc
commit
22a6a243bc
2 changed files with 16 additions and 32 deletions
|
@ -869,7 +869,17 @@ fn check_consistency_between_clients(clients: &[(Rc<TestClient>, TestAppContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_project.check_invariants(cx);
|
for buffer in guest_project.opened_buffers(cx) {
|
||||||
|
let buffer = buffer.read(cx);
|
||||||
|
assert_eq!(
|
||||||
|
buffer.deferred_ops_len(),
|
||||||
|
0,
|
||||||
|
"{} has deferred operations for buffer {:?} in project {:?}",
|
||||||
|
client.username,
|
||||||
|
buffer.file().unwrap().full_path(cx),
|
||||||
|
guest_project.remote_id(),
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -659,37 +659,11 @@ impl Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub fn check_invariants(&self, cx: &AppContext) {
|
pub fn opened_buffers(&self, cx: &AppContext) -> Vec<ModelHandle<Buffer>> {
|
||||||
if self.is_local() {
|
self.opened_buffers
|
||||||
let mut worktree_root_paths = HashMap::default();
|
.values()
|
||||||
for worktree in self.worktrees(cx) {
|
.filter_map(|b| b.upgrade(cx))
|
||||||
let worktree = worktree.read(cx);
|
.collect()
|
||||||
let abs_path = worktree.as_local().unwrap().abs_path().clone();
|
|
||||||
let prev_worktree_id = worktree_root_paths.insert(abs_path.clone(), worktree.id());
|
|
||||||
assert_eq!(
|
|
||||||
prev_worktree_id,
|
|
||||||
None,
|
|
||||||
"abs path {:?} for worktree {:?} is not unique ({:?} was already registered with the same path)",
|
|
||||||
abs_path,
|
|
||||||
worktree.id(),
|
|
||||||
prev_worktree_id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let replica_id = self.replica_id();
|
|
||||||
for buffer in self.opened_buffers.values() {
|
|
||||||
if let Some(buffer) = buffer.upgrade(cx) {
|
|
||||||
let buffer = buffer.read(cx);
|
|
||||||
assert_eq!(
|
|
||||||
buffer.deferred_ops_len(),
|
|
||||||
0,
|
|
||||||
"replica {}, buffer {} has deferred operations",
|
|
||||||
replica_id,
|
|
||||||
buffer.remote_id()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue