From ea172f5f243bb566856c3e9e8d9150a2dc3ab3ee Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Tue, 23 Nov 2021 23:00:34 -0800 Subject: [PATCH] tests: when reloading a repo, pass in repo path, not workspace root I'm about to change `ReadonlyRepo::load()` to take the path to the `.jj/` directory, so this patch prepares for that. It already works because `ReadonlyRepo::load()` will search up the directory tree for the `.jj/` entry. --- lib/tests/test_bad_locking.rs | 4 ++-- lib/tests/test_commit_concurrent.rs | 4 ++-- lib/tests/test_index.rs | 6 +++--- lib/tests/test_load_repo.rs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/tests/test_bad_locking.rs b/lib/tests/test_bad_locking.rs index 2a995bb57..f7ec0dad2 100644 --- a/lib/tests/test_bad_locking.rs +++ b/lib/tests/test_bad_locking.rs @@ -167,10 +167,10 @@ fn test_bad_locking_interrupted(use_git: bool) { copy_directory(&backup_path, &op_heads_dir); // Reload the repo and check that only the new head is present. - let reloaded_repo = ReadonlyRepo::load(&settings, repo.working_copy_path().clone()).unwrap(); + let reloaded_repo = ReadonlyRepo::load(&settings, repo.repo_path().clone()).unwrap(); assert_eq!(reloaded_repo.op_id(), &op_id); // Reload once more to make sure that the .jj/op_heads/ directory was updated // correctly. - let reloaded_repo = ReadonlyRepo::load(&settings, repo.working_copy_path().clone()).unwrap(); + let reloaded_repo = ReadonlyRepo::load(&settings, repo.repo_path().clone()).unwrap(); assert_eq!(reloaded_repo.op_id(), &op_id); } diff --git a/lib/tests/test_commit_concurrent.rs b/lib/tests/test_commit_concurrent.rs index 78925d02c..d4e6dbb55 100644 --- a/lib/tests/test_commit_concurrent.rs +++ b/lib/tests/test_commit_concurrent.rs @@ -84,7 +84,7 @@ fn test_commit_parallel_instances(use_git: bool) { let mut threads = vec![]; for _ in 0..num_threads { let settings = settings.clone(); - let repo = ReadonlyRepo::load(&settings, repo.working_copy_path().clone()).unwrap(); + let repo = ReadonlyRepo::load(&settings, repo.repo_path().clone()).unwrap(); let handle = thread::spawn(move || { let mut tx = repo.start_transaction("test"); testutils::create_random_commit(&settings, &repo).write_to_repo(tx.mut_repo()); @@ -97,7 +97,7 @@ fn test_commit_parallel_instances(use_git: bool) { } // One commit per thread plus the commit from the initial checkout on top of the // root commit - let repo = ReadonlyRepo::load(&settings, repo.working_copy_path().clone()).unwrap(); + let repo = ReadonlyRepo::load(&settings, repo.repo_path().clone()).unwrap(); assert_eq!(repo.view().heads().len(), num_threads + 1); // One operation for initializing the repo (containing the root id and the diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index eff91b9d4..8512f70ab 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -262,7 +262,7 @@ fn test_index_commits_previous_operations(use_git: bool) { std::fs::remove_dir_all(&index_operations_dir).unwrap(); std::fs::create_dir(&index_operations_dir).unwrap(); - let repo = ReadonlyRepo::load(&settings, repo.working_copy_path().clone()).unwrap(); + let repo = ReadonlyRepo::load(&settings, repo.repo_path().clone()).unwrap(); let index = repo.index(); // There should be the root commit and the working copy commit, plus // 3 more @@ -309,7 +309,7 @@ fn test_index_commits_incremental(use_git: bool) { let commit_c = child_commit(&settings, &repo, &commit_b).write_to_repo(tx.mut_repo()); tx.commit(); - let repo = ReadonlyRepo::load(&settings, repo.working_copy_path().clone()).unwrap(); + let repo = ReadonlyRepo::load(&settings, repo.repo_path().clone()).unwrap(); let index = repo.index(); // There should be the root commit and the working copy commit, plus // 3 more @@ -354,7 +354,7 @@ fn test_index_commits_incremental_empty_transaction(use_git: bool) { repo.start_transaction("test").commit(); - let repo = ReadonlyRepo::load(&settings, repo.working_copy_path().clone()).unwrap(); + let repo = ReadonlyRepo::load(&settings, repo.repo_path().clone()).unwrap(); let index = repo.index(); // There should be the root commit and the working copy commit, plus // 1 more diff --git a/lib/tests/test_load_repo.rs b/lib/tests/test_load_repo.rs index e94c31a0c..ce5116b2e 100644 --- a/lib/tests/test_load_repo.rs +++ b/lib/tests/test_load_repo.rs @@ -60,13 +60,13 @@ fn test_load_at_operation(use_git: bool) { // If we load the repo at head, we should not see the commit since it was // removed - let loader = RepoLoader::init(&settings, repo.working_copy_path().clone()).unwrap(); + let loader = RepoLoader::init(&settings, repo.repo_path().clone()).unwrap(); let head_repo = loader.load_at_head(); assert!(!head_repo.view().heads().contains(commit.id())); // If we load the repo at the previous operation, we should see the commit since // it has not been removed yet - let loader = RepoLoader::init(&settings, repo.working_copy_path().clone()).unwrap(); + let loader = RepoLoader::init(&settings, repo.repo_path().clone()).unwrap(); let old_repo = loader.load_at(repo.operation()); assert!(old_repo.view().heads().contains(commit.id())); }