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/tests/commitgraph.rs (1 of 9 files). Show all
Unified · Split
| @@ -4,7 +4,7 @@ use std::{ · 3 unmodified lines | ||
| 4 | 4 | convert::{TryFrom, TryInto}, |
| 5 | 5 | hash::BuildHasher, |
| 6 | 6 | io::{BufRead, Cursor}, |
| 7 | − path::{Path, PathBuf}, | |
| 7 | + path::Path, | |
| 8 | 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 { | |
| 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") | |
| 76 | 65 | } |
| 77 | 66 | |
| 78 | 67 | pub fn hex_to_id(hex: &[u8]) -> git_hash::ObjectId { |