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 @@
1#!/bin/bash1#!/bin/bash
2set -eu -o pipefail2set -eu -o pipefail
3 3
4
4git init -q5git init -q
5git config commit.gpgsign false6git config commit.gpgsign false
6git config core.autocrlf false7git config core.autocrlf false
7 8
8git checkout -q -b main9git checkout -q -b main
9 10
11if [ -n "${1:-}" ]; then
12 mkdir "$1"
13 cd "$1"
14fi
15
10touch f16touch f
11git add f17git add f
12git commit -qm 'f added'18git commit -qm 'f added'
git-diff/tests/visit/mod.rs+27−3
@@ -6,9 +6,9 @@ mod changes { · 5 unmodified lines
6 use git_object::{bstr::ByteSlice, tree::EntryMode};6 use git_object::{bstr::ByteSlice, tree::EntryMode};
7 use git_odb::{linked, pack, Locate};7 use git_odb::{linked, pack, Locate};
8 8
9 fn db() -> crate::Result<linked::Db> {9 fn db(args: impl IntoIterator<Item = &'static str>) -> crate::Result<linked::Db> {
10 linked::Db::at(10 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)?
12 .join(".git")12 .join(".git")
13 .join("objects"),13 .join("objects"),
14 )14 )
@@ -92,7 +92,7 @@ mod changes { · 77 unmodified lines
92 92
93 #[test]93 #[test]
94 fn many_different_states() -> crate::Result {94 fn many_different_states() -> crate::Result {
95 let db = db()?;95 let db = db(None)?;
96 let all_commits = all_commits(&db);96 let all_commits = all_commits(&db);
97 assert_eq!(97 assert_eq!(
98 diff_with_previous_commit_from(&db, &all_commits[0])?,98 diff_with_previous_commit_from(&db, &all_commits[0])?,
@@ -395,5 +395,29 @@ mod changes { · 296 unmodified lines
395 );395 );
396 Ok(())396 Ok(())
397 }397 }
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 }
398 }422 }
399}423}

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