History

[tree-diff] Beginning of more nested test-suite…

…which should make it possible to adapt the previous one.

Sebastian Thiel committed 5 years ago

Commit b8a90e71 parent d7418f33 files · +54 −6Browse files

Showing the changes to git-diff (2 of 3 files). Show all

Unified · Split

2 files
  1. git-diff/tests/fixtures/make_diff_repo.sh +6 −0
  2. git-diff/tests/visit/mod.rs +27 −3
git-diff/tests/fixtures/make_diff_repo.sh+6−0
@@ -1,12 +1,18 @@
11 #!/bin/bash
22 set -eu -o pipefail
33
4+
45 git init -q
56 git config commit.gpgsign false
67 git config core.autocrlf false
78
89 git checkout -q -b main
910
11+if [ -n "${1:-}" ]; then
12+ mkdir "$1"
13+ cd "$1"
14+fi
15+
1016 touch f
1117 git add f
1218 git commit -qm 'f added'
git-diff/tests/visit/mod.rs+27−3
@@ -6,9 +6,9 @@ mod changes { · 5 unmodified lines
66 use git_object::{bstr::ByteSlice, tree::EntryMode};
77 use git_odb::{linked, pack, Locate};
88
9− fn db() -> crate::Result<linked::Db> {
9+ fn db(args: impl IntoIterator<Item = &'static str>) -> crate::Result<linked::Db> {
1010 linked::Db::at(
11− test_tools::scripted_fixture_repo_read_only("make_diff_repo.sh")?
11+ test_tools::scripted_fixture_repo_read_only_with_args("make_diff_repo.sh", args)?
1212 .join(".git")
1313 .join("objects"),
1414 )
@@ -92,7 +92,7 @@ mod changes { · 77 unmodified lines
9292
9393 #[test]
9494 fn many_different_states() -> crate::Result {
95− let db = db()?;
95+ let db = db(None)?;
9696 let all_commits = all_commits(&db);
9797 assert_eq!(
9898 diff_with_previous_commit_from(&db, &all_commits[0])?,
@@ -395,5 +395,29 @@ mod changes { · 296 unmodified lines
395395 );
396396 Ok(())
397397 }
398+
399+ #[test]
400+ fn many_different_states_nested() -> crate::Result {
401+ let db = db(["a"].iter().copied())?;
402+ let all_commits = all_commits(&db);
403+
404+ assert_eq!(
405+ diff_with_previous_commit_from(&db, &all_commits[0])?,
406+ vec![
407+ recorder::Change::Addition {
408+ entry_mode: EntryMode::Tree,
409+ oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df"),
410+ path: "a".into()
411+ },
412+ recorder::Change::Addition {
413+ entry_mode: EntryMode::Blob,
414+ oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),
415+ path: "a/f".into()
416+ }
417+ ],
418+ ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A a/f"
419+ );
420+ Ok(())
421+ }
398422 }
399423 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t