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
26thiserror = "1.0.20"26thiserror = "1.0.20"
27 27
28[dev-dependencies]28[dev-dependencies]
29tempfile = "3.1.0"29test-tools = { version = "0.1", path = "../tests/tools" }
git-commitgraph/tests/commitgraph.rs+4−15
@@ -4,7 +4,7 @@ use std::{ · 3 unmodified lines
4 convert::{TryFrom, TryInto},4 convert::{TryFrom, TryInto},
5 hash::BuildHasher,5 hash::BuildHasher,
6 io::{BufRead, Cursor},6 io::{BufRead, Cursor},
7 path::{Path, PathBuf},7 path::Path,
8 process::Command,8 process::Command,
9};9};
10 10
@@ -59,20 +59,9 @@ pub fn check_common(cg: &Graph, expected: &HashMap<String, RefInfo, impl BuildHa · 48 unmodified lines
59 );59 );
60}60}
61 61
62pub fn create_repo(script_path: &str) -> tempfile::TempDir {62use test_tools::assure_fixture_repo_present;
63 let dir = tempfile::tempdir().expect("failed to create temp dir");63pub fn create_repo(script_path: &str) -> test_tools::tempdir::TempDir {
64 let status = Command::new("bash")64 assure_fixture_repo_present(script_path).expect("script succeeds all the time")
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
74pub fn fixture_path(path: &str) -> PathBuf {
75 PathBuf::from("tests").join("fixtures").join(path)
76}65}
77 66
78pub fn hex_to_id(hex: &[u8]) -> git_hash::ObjectId {67pub 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
12 12
13 local temp_dir=$(mktemp -d create_fixtures-XXXXXXXXXX)13 local temp_dir=$(mktemp -d create_fixtures-XXXXXXXXXX)
14 trap "rm -rf $temp_dir" EXIT14 trap "rm -rf $temp_dir" EXIT
15 "$script" "$temp_dir"15 (cd "$temp_dir" && "$script")
16 cp -dR "$temp_dir/.git/objects/" "$target_dir/"16 cp -dR "$temp_dir/.git/objects/" "$target_dir/"
17 rm -rf "$temp_dir"17 rm -rf "$temp_dir"
18 trap - EXIT18 trap - EXIT
19}19}
20 20
21run bloom21#run bloom
22run bloom_too_large22#run bloom_too_large
23run octopus_merges23run octopus_merges
24run single_commit24run single_commit
25run single_parent25run single_parent
26run split_chain26run split_chain
27run two_parents27run 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
8export GIT_COMMITTER_EMAIL=committer@example.com8export GIT_COMMITTER_EMAIL=committer@example.com
9export GIT_COMMITTER_NAME=committer9export GIT_COMMITTER_NAME=committer
10 10
11mkdir -p "$1"
12cd "$1"
13git init -q11git init -q
14git config commit.gpgsign false12git config commit.gpgsign false
15 13
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
10export GIT_COMMITTER_EMAIL=committer@example.com10export GIT_COMMITTER_EMAIL=committer@example.com
11export GIT_COMMITTER_NAME=committer11export GIT_COMMITTER_NAME=committer
12 12
13mkdir -p "$1"
14cd "$1"
15git init -q13git init -q
16git config commit.gpgsign false14git config commit.gpgsign false
17 15
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
8export GIT_COMMITTER_EMAIL=committer@example.com8export GIT_COMMITTER_EMAIL=committer@example.com
9export GIT_COMMITTER_NAME=committer9export GIT_COMMITTER_NAME=committer
10 10
11mkdir -p "$1"
12cd "$1"
13git init -q11git init -q
14git config commit.gpgsign false12git config commit.gpgsign false
15 13
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
8export GIT_COMMITTER_EMAIL=committer@example.com8export GIT_COMMITTER_EMAIL=committer@example.com
9export GIT_COMMITTER_NAME=committer9export GIT_COMMITTER_NAME=committer
10 10
11mkdir -p "$1"
12cd "$1"
13git init -q11git init -q
14git config commit.gpgsign false12git config commit.gpgsign false
15 13
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
8export GIT_COMMITTER_EMAIL=committer@example.com8export GIT_COMMITTER_EMAIL=committer@example.com
9export GIT_COMMITTER_NAME=committer9export GIT_COMMITTER_NAME=committer
10 10
11mkdir -p "$1"
12cd "$1"
13git init -q11git init -q
14git config commit.gpgsign false12git config commit.gpgsign false
15 13