mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-09 05:50:36 +00:00
testutils: use .jj
-internal git repos in most tests
I don't think there's much reason to run most tests with a `.git`
directory outside of `.jj`. I think it's just that way for historical
reasons. It's been that way since I added support for `.jj`-internal
repos in a8a9f7dedd
.
The reason I want to switch is to make it a little easier to create
test repos for different backends. The problem with `.jj`-external git
repos is that they depend on an additional path.
I had to update `test_bad_locking.rs` to make the code merging
directories able handle missing directories on some side, because
git's loose objects result in directories getting created on one or
both sides.
This commit is contained in:
parent
2bc641c57c
commit
79527d707c
2 changed files with 39 additions and 37 deletions
|
@ -38,6 +38,7 @@ fn merge_directories(left: &Path, base: &Path, right: &Path, output: &Path) {
|
|||
std::fs::create_dir(output).unwrap();
|
||||
let mut sub_dirs = vec![];
|
||||
// Walk the left side and copy to the output
|
||||
if left.exists() {
|
||||
for entry in std::fs::read_dir(left).unwrap() {
|
||||
let path = entry.unwrap().path();
|
||||
let base_name = path.file_name().unwrap();
|
||||
|
@ -49,8 +50,10 @@ fn merge_directories(left: &Path, base: &Path, right: &Path, output: &Path) {
|
|||
std::fs::copy(&child_left, child_output).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Walk the base and find files removed in the right side, then remove them in
|
||||
// the output
|
||||
if base.exists() {
|
||||
for entry in std::fs::read_dir(base).unwrap() {
|
||||
let path = entry.unwrap().path();
|
||||
let base_name = path.file_name().unwrap();
|
||||
|
@ -63,8 +66,10 @@ fn merge_directories(left: &Path, base: &Path, right: &Path, output: &Path) {
|
|||
std::fs::remove_file(child_output).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Walk the right side and find files added in the right side, then add them in
|
||||
// the output
|
||||
if right.exists() {
|
||||
for entry in std::fs::read_dir(right).unwrap() {
|
||||
let path = entry.unwrap().path();
|
||||
let base_name = path.file_name().unwrap();
|
||||
|
@ -79,6 +84,7 @@ fn merge_directories(left: &Path, base: &Path, right: &Path, output: &Path) {
|
|||
std::fs::copy(&child_right, child_output).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do the merge in subdirectories
|
||||
for base_name in sub_dirs.iter().sorted().dedup() {
|
||||
let child_base = base.join(base_name);
|
||||
|
|
|
@ -93,13 +93,11 @@ impl TestRepo {
|
|||
fs::create_dir(&repo_dir).unwrap();
|
||||
|
||||
let repo = if use_git {
|
||||
let git_path = temp_dir.path().join("git-repo");
|
||||
git2::Repository::init(&git_path).unwrap();
|
||||
ReadonlyRepo::init(
|
||||
&settings,
|
||||
&repo_dir,
|
||||
|store_path| -> Result<Box<dyn Backend>, BackendInitError> {
|
||||
Ok(Box::new(GitBackend::init_external(store_path, &git_path)?))
|
||||
Ok(Box::new(GitBackend::init_internal(store_path)?))
|
||||
},
|
||||
ReadonlyRepo::default_op_store_factory(),
|
||||
ReadonlyRepo::default_op_heads_store_factory(),
|
||||
|
@ -144,9 +142,7 @@ impl TestWorkspace {
|
|||
fs::create_dir(&workspace_root).unwrap();
|
||||
|
||||
let (workspace, repo) = if use_git {
|
||||
let git_path = temp_dir.path().join("git-repo");
|
||||
git2::Repository::init(&git_path).unwrap();
|
||||
Workspace::init_external_git(settings, &workspace_root, &git_path).unwrap()
|
||||
Workspace::init_internal_git(settings, &workspace_root).unwrap()
|
||||
} else {
|
||||
Workspace::init_local(settings, &workspace_root).unwrap()
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue