revlogindex: use tests from the dag crate

Summary: This adds some test coverage for the revlog DagAlgorithm implementation.

Reviewed By: sfilipco

Differential Revision: D22249157

fbshipit-source-id: a1d347b4d90d0e7f8fb229c317cc75c2b8e16242
This commit is contained in:
Jun Wu 2020-07-06 15:46:33 -07:00 committed by Facebook GitHub Bot
parent fcbe821dd1
commit b86f3bd6e2

View File

@ -1157,6 +1157,8 @@ impl DagAddHeads for RevlogIndex {
#[cfg(test)]
mod tests {
use super::*;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use tempfile::tempdir;
#[test]
@ -1339,4 +1341,20 @@ commit 3"#
let bytes = from_xxd(xxd);
assert_eq!(bytes, b"1234\n");
}
#[test]
fn test_generic_dag() {
let dir = tempdir().unwrap();
let id = AtomicUsize::new(0);
let new_dag = {
let dir = dir.path();
move || -> RevlogIndex {
let id = id.fetch_add(1, SeqCst);
let revlog_path = dir.join(format!("{}.i", id));
let nodemap_path = dir.join(format!("{}.nodemap", id));
RevlogIndex::new(&revlog_path, &nodemap_path).unwrap()
}
};
dag::tests::test_generic_dag(new_dag);
}
}