mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-28 01:07:09 +00:00
Check worktree invariants in randomized test
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
ce28dc39ff
commit
955268e2a6
1 changed files with 9 additions and 0 deletions
|
@ -1149,6 +1149,7 @@ mod tests {
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
new_scanner.scan_dirs().unwrap();
|
new_scanner.scan_dirs().unwrap();
|
||||||
|
scanner.snapshot().check_invariants();
|
||||||
assert_eq!(scanner.snapshot().to_vec(), new_scanner.snapshot().to_vec());
|
assert_eq!(scanner.snapshot().to_vec(), new_scanner.snapshot().to_vec());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1268,6 +1269,13 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Snapshot {
|
impl Snapshot {
|
||||||
|
fn check_invariants(&self) {
|
||||||
|
for entry in self.entries.items() {
|
||||||
|
let path = self.path_for_inode(entry.inode(), false).unwrap();
|
||||||
|
assert_eq!(self.inode_for_path(path).unwrap(), entry.inode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn to_vec(&self) -> Vec<(PathBuf, u64)> {
|
fn to_vec(&self) -> Vec<(PathBuf, u64)> {
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
|
||||||
|
@ -1291,6 +1299,7 @@ mod tests {
|
||||||
paths.push((computed_path, inode));
|
paths.push((computed_path, inode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_eq!(paths.len(), self.entries.items().len());
|
||||||
paths.sort_by(|a, b| a.0.cmp(&b.0));
|
paths.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
paths
|
paths
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue