mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-07 21:27:06 +00:00
tests: compare trees without using .diff_summary()
I don't think modification types matter here. Testing paths should be good enough.
This commit is contained in:
parent
0b1a6cd9e0
commit
d435a8a793
1 changed files with 29 additions and 33 deletions
|
@ -12,16 +12,29 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
use futures::StreamExt as _;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use jj_lib::backend::{ChangeId, MillisSinceEpoch, Signature, Timestamp};
|
use jj_lib::backend::{ChangeId, MillisSinceEpoch, Signature, Timestamp};
|
||||||
use jj_lib::matchers::EverythingMatcher;
|
use jj_lib::matchers::EverythingMatcher;
|
||||||
use jj_lib::merged_tree::DiffSummary;
|
use jj_lib::merged_tree::MergedTree;
|
||||||
use jj_lib::repo::Repo;
|
use jj_lib::repo::Repo;
|
||||||
use jj_lib::repo_path::{RepoPath, RepoPathBuf};
|
use jj_lib::repo_path::{RepoPath, RepoPathBuf};
|
||||||
use jj_lib::settings::UserSettings;
|
use jj_lib::settings::UserSettings;
|
||||||
|
use pollster::FutureExt as _;
|
||||||
use test_case::test_case;
|
use test_case::test_case;
|
||||||
use testutils::{assert_rebased_onto, create_tree, CommitGraphBuilder, TestRepo, TestRepoBackend};
|
use testutils::{assert_rebased_onto, create_tree, CommitGraphBuilder, TestRepo, TestRepoBackend};
|
||||||
|
|
||||||
|
fn diff_paths(from_tree: &MergedTree, to_tree: &MergedTree) -> Vec<RepoPathBuf> {
|
||||||
|
from_tree
|
||||||
|
.diff_stream(to_tree, &EverythingMatcher)
|
||||||
|
.map(|(path, diff)| {
|
||||||
|
let _ = diff.unwrap();
|
||||||
|
path
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
.block_on()
|
||||||
|
}
|
||||||
|
|
||||||
fn to_owned_path_vec(paths: &[&RepoPath]) -> Vec<RepoPathBuf> {
|
fn to_owned_path_vec(paths: &[&RepoPath]) -> Vec<RepoPathBuf> {
|
||||||
paths.iter().map(|&path| path.to_owned()).collect()
|
paths.iter().map(|&path| path.to_owned()).collect()
|
||||||
}
|
}
|
||||||
|
@ -85,17 +98,11 @@ fn test_initial(backend: TestRepoBackend) {
|
||||||
assert_eq!(commit.author(), &author_signature);
|
assert_eq!(commit.author(), &author_signature);
|
||||||
assert_eq!(commit.committer(), &committer_signature);
|
assert_eq!(commit.committer(), &committer_signature);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store
|
diff_paths(
|
||||||
.root_commit()
|
&store.root_commit().tree().unwrap(),
|
||||||
.tree()
|
&commit.tree().unwrap(),
|
||||||
.unwrap()
|
),
|
||||||
.diff_summary(&commit.tree().unwrap(), &EverythingMatcher)
|
to_owned_path_vec(&[dir_file_path, root_file_path]),
|
||||||
.unwrap(),
|
|
||||||
DiffSummary {
|
|
||||||
modified: vec![],
|
|
||||||
added: to_owned_path_vec(&[dir_file_path, root_file_path]),
|
|
||||||
removed: vec![],
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,29 +176,18 @@ fn test_rewrite(backend: TestRepoBackend) {
|
||||||
rewrite_settings.user_email()
|
rewrite_settings.user_email()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
store
|
diff_paths(
|
||||||
.root_commit()
|
&store.root_commit().tree().unwrap(),
|
||||||
.tree()
|
&rewritten_commit.tree().unwrap(),
|
||||||
.unwrap()
|
),
|
||||||
.diff_summary(&rewritten_commit.tree().unwrap(), &EverythingMatcher)
|
to_owned_path_vec(&[dir_file_path, root_file_path]),
|
||||||
.unwrap(),
|
|
||||||
DiffSummary {
|
|
||||||
modified: vec![],
|
|
||||||
added: to_owned_path_vec(&[dir_file_path, root_file_path]),
|
|
||||||
removed: vec![],
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
initial_commit
|
diff_paths(
|
||||||
.tree()
|
&initial_commit.tree().unwrap(),
|
||||||
.unwrap()
|
&rewritten_commit.tree().unwrap(),
|
||||||
.diff_summary(&rewritten_commit.tree().unwrap(), &EverythingMatcher)
|
),
|
||||||
.unwrap(),
|
to_owned_path_vec(&[dir_file_path]),
|
||||||
DiffSummary {
|
|
||||||
modified: to_owned_path_vec(&[dir_file_path]),
|
|
||||||
added: vec![],
|
|
||||||
removed: vec![],
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue