History

git-commitgraph uses test-tools

I plan to eventually make running the test-repo initialization more efficient as there are more and more of these, and this should easily be shared across crates.

Sebastian Thiel committed 5 years ago

Commit 5d30e5a1 parent b1176269 files · +9 −37Browse files

Showing the changes to git-commitgraph (8 of 9 files). Show all

Unified · Split

8 files
  1. git-commitgraph/Cargo.toml +1 −1
  2. git-commitgraph/tests/commitgraph.rs +4 −15
  3. git-commitgraph/tests/fixtures/create_fixtures.sh +3 −10
  4. git-commitgraph/tests/fixtures/octopus_merges.sh +0 −2
  5. git-commitgraph/tests/fixtures/single_commit.sh +0 −2
  6. git-commitgraph/tests/fixtures/single_parent.sh +0 −2
  7. git-commitgraph/tests/fixtures/split_chain.sh +0 −2
  8. git-commitgraph/tests/fixtures/two_parents.sh +0 −2
git-commitgraph/Cargo.toml+1−1
@@ -26,4 +26,4 @@ serde = { version = "1.0.114", optional = true, default-features = false, featur · 25 unmodified lines
2626 thiserror = "1.0.20"
2727
2828 [dev-dependencies]
29−tempfile = "3.1.0"
29+test-tools = { version = "0.1", path = "../tests/tools" }
git-commitgraph/tests/commitgraph.rs+4−15
@@ -4,7 +4,7 @@ use std::{ · 3 unmodified lines
44 convert::{TryFrom, TryInto},
55 hash::BuildHasher,
66 io::{BufRead, Cursor},
7− path::{Path, PathBuf},
7+ path::Path,
88 process::Command,
99 };
1010
@@ -59,20 +59,9 @@ pub fn check_common(cg: &Graph, expected: &HashMap<String, RefInfo, impl BuildHa · 48 unmodified lines
5959 );
6060 }
6161
62−pub fn create_repo(script_path: &str) -> tempfile::TempDir {
63− let dir = tempfile::tempdir().expect("failed to create temp dir");
64− let status = Command::new("bash")
65− .arg(fixture_path(script_path))
66− .arg(dir.path())
67− .env_remove("GIT_DIR")
68− .status()
69− .expect("failed to run repo script");
70− assert!(status.success(), "repo script failed");
71− dir
72−}
73−
74−pub fn fixture_path(path: &str) -> PathBuf {
75− PathBuf::from("tests").join("fixtures").join(path)
62+use test_tools::assure_fixture_repo_present;
63+pub fn create_repo(script_path: &str) -> test_tools::tempdir::TempDir {
64+ assure_fixture_repo_present(script_path).expect("script succeeds all the time")
7665 }
7766
7867 pub fn hex_to_id(hex: &[u8]) -> git_hash::ObjectId {
git-commitgraph/tests/fixtures/create_fixtures.sh+3−10
@@ -12,23 +12,16 @@ run() { · 11 unmodified lines
1212
1313 local temp_dir=$(mktemp -d create_fixtures-XXXXXXXXXX)
1414 trap "rm -rf $temp_dir" EXIT
15− "$script" "$temp_dir"
15+ (cd "$temp_dir" && "$script")
1616 cp -dR "$temp_dir/.git/objects/" "$target_dir/"
1717 rm -rf "$temp_dir"
1818 trap - EXIT
1919 }
2020
21−run bloom
22−run bloom_too_large
21+#run bloom
22+#run bloom_too_large
2323 run octopus_merges
2424 run single_commit
2525 run single_parent
2626 run split_chain
2727 run two_parents
28−
29−#"$script_dir"/bloom.sh "$parent_dir/bloom"
30−#"$script_dir"/bloom_too_large.sh "$parent_dir/bloom_to_large"
31−#"$script_dir"/octopus_merges.sh "$parent_dir/octopus_merges"
32−#"$script_dir"/single_commit.sh "$parent_dir/single_commit"
33−#"$script_dir"/single_parent.sh "$parent_dir/single_parent"
34−#"$script_dir"/two_parents.sh "$parent_dir/two_parents"
git-commitgraph/tests/fixtures/octopus_merges.sh+0−2
@@ -8,8 +8,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 7 unmodified lines
88 export GIT_COMMITTER_EMAIL=committer@example.com
99 export GIT_COMMITTER_NAME=committer
1010
11−mkdir -p "$1"
12−cd "$1"
1311 git init -q
1412 git config commit.gpgsign false
1513
git-commitgraph/tests/fixtures/single_commit.sh+0−2
@@ -10,8 +10,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 9 unmodified lines
1010 export GIT_COMMITTER_EMAIL=committer@example.com
1111 export GIT_COMMITTER_NAME=committer
1212
13−mkdir -p "$1"
14−cd "$1"
1513 git init -q
1614 git config commit.gpgsign false
1715
git-commitgraph/tests/fixtures/single_parent.sh+0−2
@@ -8,8 +8,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 7 unmodified lines
88 export GIT_COMMITTER_EMAIL=committer@example.com
99 export GIT_COMMITTER_NAME=committer
1010
11−mkdir -p "$1"
12−cd "$1"
1311 git init -q
1412 git config commit.gpgsign false
1513
git-commitgraph/tests/fixtures/split_chain.sh+0−2
@@ -8,8 +8,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 7 unmodified lines
88 export GIT_COMMITTER_EMAIL=committer@example.com
99 export GIT_COMMITTER_NAME=committer
1010
11−mkdir -p "$1"
12−cd "$1"
1311 git init -q
1412 git config commit.gpgsign false
1513
git-commitgraph/tests/fixtures/two_parents.sh+0−2
@@ -8,8 +8,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 7 unmodified lines
88 export GIT_COMMITTER_EMAIL=committer@example.com
99 export GIT_COMMITTER_NAME=committer
1010
11−mkdir -p "$1"
12−cd "$1"
1311 git init -q
1412 git config commit.gpgsign false
1513