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.
This commit is contained in:
Martin von Zweigbergk 2021-11-23 23:00:34 -08:00
parent 831a0a7707
commit ea172f5f24
4 changed files with 9 additions and 9 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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

View file

@ -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()));
}