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.
Showing the changes to git-commitgraph (8 of 9 files). Show all
Unified · Split
| @@ -26,4 +26,4 @@ serde = { version = "1.0.114", optional = true, default-features = false, featur · 25 unmodified lines | |||
| 26 | thiserror = "1.0.20" | 26 | thiserror = "1.0.20" |
| 27 | 27 | ||
| 28 | [dev-dependencies] | 28 | [dev-dependencies] |
| 29 | tempfile = "3.1.0" | 29 | test-tools = { version = "0.1", path = "../tests/tools" } |
| @@ -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 | ||
| 62 | pub fn create_repo(script_path: &str) -> tempfile::TempDir { | 62 | use test_tools::assure_fixture_repo_present; |
| 63 | let dir = tempfile::tempdir().expect("failed to create temp dir"); | 63 | pub 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 | |||
| 74 | pub fn fixture_path(path: &str) -> PathBuf { | ||
| 75 | PathBuf::from("tests").join("fixtures").join(path) | ||
| 76 | } | 65 | } |
| 77 | 66 | ||
| 78 | pub fn hex_to_id(hex: &[u8]) -> git_hash::ObjectId { | 67 | pub fn hex_to_id(hex: &[u8]) -> git_hash::ObjectId { |
| @@ -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" EXIT | 14 | 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 - EXIT | 18 | trap - EXIT |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | run bloom | 21 | #run bloom |
| 22 | run bloom_too_large | 22 | #run bloom_too_large |
| 23 | run octopus_merges | 23 | run octopus_merges |
| 24 | run single_commit | 24 | run single_commit |
| 25 | run single_parent | 25 | run single_parent |
| 26 | run split_chain | 26 | run split_chain |
| 27 | run two_parents | 27 | 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" | ||
| @@ -8,8 +8,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 7 unmodified lines | |||
| 8 | export GIT_COMMITTER_EMAIL=committer@example.com | 8 | export GIT_COMMITTER_EMAIL=committer@example.com |
| 9 | export GIT_COMMITTER_NAME=committer | 9 | export GIT_COMMITTER_NAME=committer |
| 10 | 10 | ||
| 11 | mkdir -p "$1" | ||
| 12 | cd "$1" | ||
| 13 | git init -q | 11 | git init -q |
| 14 | git config commit.gpgsign false | 12 | git config commit.gpgsign false |
| 15 | 13 | ||
| @@ -10,8 +10,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 9 unmodified lines | |||
| 10 | export GIT_COMMITTER_EMAIL=committer@example.com | 10 | export GIT_COMMITTER_EMAIL=committer@example.com |
| 11 | export GIT_COMMITTER_NAME=committer | 11 | export GIT_COMMITTER_NAME=committer |
| 12 | 12 | ||
| 13 | mkdir -p "$1" | ||
| 14 | cd "$1" | ||
| 15 | git init -q | 13 | git init -q |
| 16 | git config commit.gpgsign false | 14 | git config commit.gpgsign false |
| 17 | 15 | ||
| @@ -8,8 +8,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 7 unmodified lines | |||
| 8 | export GIT_COMMITTER_EMAIL=committer@example.com | 8 | export GIT_COMMITTER_EMAIL=committer@example.com |
| 9 | export GIT_COMMITTER_NAME=committer | 9 | export GIT_COMMITTER_NAME=committer |
| 10 | 10 | ||
| 11 | mkdir -p "$1" | ||
| 12 | cd "$1" | ||
| 13 | git init -q | 11 | git init -q |
| 14 | git config commit.gpgsign false | 12 | git config commit.gpgsign false |
| 15 | 13 | ||
| @@ -8,8 +8,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 7 unmodified lines | |||
| 8 | export GIT_COMMITTER_EMAIL=committer@example.com | 8 | export GIT_COMMITTER_EMAIL=committer@example.com |
| 9 | export GIT_COMMITTER_NAME=committer | 9 | export GIT_COMMITTER_NAME=committer |
| 10 | 10 | ||
| 11 | mkdir -p "$1" | ||
| 12 | cd "$1" | ||
| 13 | git init -q | 11 | git init -q |
| 14 | git config commit.gpgsign false | 12 | git config commit.gpgsign false |
| 15 | 13 | ||
| @@ -8,8 +8,6 @@ export GIT_COMMITTER_DATE="2000-01-02 00:00:00 +0000" · 7 unmodified lines | |||
| 8 | export GIT_COMMITTER_EMAIL=committer@example.com | 8 | export GIT_COMMITTER_EMAIL=committer@example.com |
| 9 | export GIT_COMMITTER_NAME=committer | 9 | export GIT_COMMITTER_NAME=committer |
| 10 | 10 | ||
| 11 | mkdir -p "$1" | ||
| 12 | cd "$1" | ||
| 13 | git init -q | 11 | git init -q |
| 14 | git config commit.gpgsign false | 12 | git config commit.gpgsign false |
| 15 | 13 | ||