mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 14:00:51 +00:00
tests: move init_{repo,workspace}
functions onto types
I tried to create a `TestRepo` and was surprised that I couldn't do that by calling a function on it.
This commit is contained in:
parent
6c6e6cb423
commit
4cf04f373e
22 changed files with 216 additions and 202 deletions
|
@ -57,23 +57,25 @@ pub struct TestRepo {
|
|||
pub repo: Arc<ReadonlyRepo>,
|
||||
}
|
||||
|
||||
pub fn init_repo(settings: &UserSettings, use_git: bool) -> TestRepo {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
impl TestRepo {
|
||||
pub fn init(settings: &UserSettings, use_git: bool) -> Self {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
|
||||
let repo_dir = temp_dir.path().join("repo");
|
||||
fs::create_dir(&repo_dir).unwrap();
|
||||
let repo_dir = temp_dir.path().join("repo");
|
||||
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_external_git(settings, repo_dir, git_path)
|
||||
} else {
|
||||
ReadonlyRepo::init_local(settings, repo_dir)
|
||||
};
|
||||
let repo = if use_git {
|
||||
let git_path = temp_dir.path().join("git-repo");
|
||||
git2::Repository::init(&git_path).unwrap();
|
||||
ReadonlyRepo::init_external_git(settings, repo_dir, git_path)
|
||||
} else {
|
||||
ReadonlyRepo::init_local(settings, repo_dir)
|
||||
};
|
||||
|
||||
TestRepo {
|
||||
_temp_dir: temp_dir,
|
||||
repo,
|
||||
Self {
|
||||
_temp_dir: temp_dir,
|
||||
repo,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,28 +85,28 @@ pub struct TestWorkspace {
|
|||
pub repo: Arc<ReadonlyRepo>,
|
||||
}
|
||||
|
||||
pub fn init_workspace(settings: &UserSettings, use_git: bool) -> TestWorkspace {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
|
||||
let workspace_root = temp_dir.path().join("repo");
|
||||
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()
|
||||
} else {
|
||||
Workspace::init_local(settings, workspace_root).unwrap()
|
||||
};
|
||||
|
||||
TestWorkspace {
|
||||
temp_dir,
|
||||
workspace,
|
||||
repo,
|
||||
}
|
||||
}
|
||||
|
||||
impl TestWorkspace {
|
||||
pub fn init(settings: &UserSettings, use_git: bool) -> Self {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
|
||||
let workspace_root = temp_dir.path().join("repo");
|
||||
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()
|
||||
} else {
|
||||
Workspace::init_local(settings, workspace_root).unwrap()
|
||||
};
|
||||
|
||||
Self {
|
||||
temp_dir,
|
||||
workspace,
|
||||
repo,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn root_dir(&self) -> PathBuf {
|
||||
self.temp_dir.path().join("repo").join("..")
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ use std::path::Path;
|
|||
|
||||
use jujutsu_lib::repo::ReadonlyRepo;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestWorkspace;
|
||||
use jujutsu_lib::workspace::Workspace;
|
||||
use tempfile::TempDir;
|
||||
use test_case::test_case;
|
||||
|
@ -95,7 +96,7 @@ fn test_bad_locking_children(use_git: bool) {
|
|||
// Test that two new commits created on separate machines are both visible (not
|
||||
// lost due to lack of locking)
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let workspace_root = test_workspace.workspace.workspace_root();
|
||||
|
||||
|
@ -159,7 +160,7 @@ fn test_bad_locking_interrupted(use_git: bool) {
|
|||
// that's a descendant of the other is resolved without creating a new
|
||||
// operation.
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
|
|
@ -17,7 +17,7 @@ use jujutsu_lib::matchers::EverythingMatcher;
|
|||
use jujutsu_lib::repo_path::RepoPath;
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::{assert_rebased, CommitGraphBuilder};
|
||||
use jujutsu_lib::testutils::{assert_rebased, CommitGraphBuilder, TestRepo};
|
||||
use jujutsu_lib::tree::DiffSummary;
|
||||
use test_case::test_case;
|
||||
|
||||
|
@ -25,7 +25,7 @@ use test_case::test_case;
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_initial(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store();
|
||||
|
||||
|
@ -70,7 +70,7 @@ fn test_initial(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rewrite(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store().clone();
|
||||
|
||||
|
@ -157,7 +157,7 @@ fn test_rewrite(use_git: bool) {
|
|||
// #[test_case(true ; "git backend")]
|
||||
fn test_commit_builder_descendants(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store().clone();
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ use std::cmp::max;
|
|||
use std::thread;
|
||||
|
||||
use jujutsu_lib::repo::ReadonlyRepo;
|
||||
use jujutsu_lib::testutils::TestWorkspace;
|
||||
use jujutsu_lib::{dag_walk, testutils};
|
||||
use test_case::test_case;
|
||||
|
||||
|
@ -43,7 +44,7 @@ fn test_commit_parallel(use_git: bool) {
|
|||
// transactions from it. It then reloads the repo. That should merge all the
|
||||
// operations and all commits should be visible.
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let num_threads = max(num_cpus::get(), 4);
|
||||
|
@ -77,7 +78,7 @@ fn test_commit_parallel_instances(use_git: bool) {
|
|||
// Like the test above but creates a new repo instance for every thread, which
|
||||
// makes it behave very similar to separate processes.
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let num_threads = max(num_cpus::get(), 4);
|
||||
|
|
|
@ -17,11 +17,12 @@ use jujutsu_lib::conflicts::{materialize_conflict, parse_conflict, update_confli
|
|||
use jujutsu_lib::files::MergeHunk;
|
||||
use jujutsu_lib::repo_path::RepoPath;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestRepo;
|
||||
|
||||
#[test]
|
||||
fn test_materialize_conflict_basic() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let store = test_repo.repo.store();
|
||||
|
||||
let path = RepoPath::from_internal_string("file");
|
||||
|
@ -101,7 +102,7 @@ line 5
|
|||
#[test]
|
||||
fn test_materialize_conflict_modify_delete() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let store = test_repo.repo.store();
|
||||
|
||||
let path = RepoPath::from_internal_string("file");
|
||||
|
@ -179,7 +180,7 @@ line 5
|
|||
#[test]
|
||||
fn test_materialize_conflict_delete_modify() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let store = test_repo.repo.store();
|
||||
|
||||
let path = RepoPath::from_internal_string("file");
|
||||
|
@ -423,7 +424,7 @@ line 5
|
|||
#[test]
|
||||
fn test_update_conflict_from_content() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let store = test_repo.repo.store();
|
||||
|
||||
let path = RepoPath::from_internal_string("dir/file");
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
use jujutsu_lib::matchers::{EverythingMatcher, FilesMatcher};
|
||||
use jujutsu_lib::repo_path::RepoPath;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestRepo;
|
||||
use jujutsu_lib::tree::DiffSummary;
|
||||
use maplit::hashset;
|
||||
use test_case::test_case;
|
||||
|
@ -23,7 +24,7 @@ use test_case::test_case;
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_types(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let clean_path = RepoPath::from_internal_string("clean");
|
||||
|
@ -63,7 +64,7 @@ fn test_types(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_tree_file_transition(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let dir_file_path = RepoPath::from_internal_string("dir/file");
|
||||
|
@ -94,7 +95,7 @@ fn test_tree_file_transition(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_sorting(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let a_path = RepoPath::from_internal_string("a");
|
||||
|
@ -160,7 +161,7 @@ fn test_sorting(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_matcher_dir_file_transition(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let a_path = RepoPath::from_internal_string("a");
|
||||
|
@ -228,7 +229,7 @@ fn test_matcher_dir_file_transition(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_matcher_normal_cases(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let a_path = RepoPath::from_internal_string("a");
|
||||
|
|
|
@ -22,7 +22,7 @@ use jujutsu_lib::git::{GitFetchError, GitPushError, GitRefUpdate};
|
|||
use jujutsu_lib::op_store::{BranchTarget, RefTarget};
|
||||
use jujutsu_lib::repo::ReadonlyRepo;
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
use jujutsu_lib::testutils::create_random_commit;
|
||||
use jujutsu_lib::testutils::{create_random_commit, TestRepo};
|
||||
use jujutsu_lib::{git, testutils};
|
||||
use maplit::{btreemap, hashset};
|
||||
use tempfile::TempDir;
|
||||
|
@ -55,7 +55,7 @@ fn commit_id(commit: &git2::Commit) -> CommitId {
|
|||
#[test]
|
||||
fn test_import_refs() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
let git_repo = repo.store().git_repo().unwrap();
|
||||
|
||||
|
@ -144,7 +144,7 @@ fn test_import_refs() {
|
|||
#[test]
|
||||
fn test_import_refs_reimport() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_repo(&settings, true);
|
||||
let test_workspace = TestRepo::init(&settings, true);
|
||||
let repo = &test_workspace.repo;
|
||||
let git_repo = repo.store().git_repo().unwrap();
|
||||
|
||||
|
@ -238,7 +238,7 @@ fn test_import_refs_reimport() {
|
|||
fn test_import_refs_reimport_head_removed() {
|
||||
// Test that re-importing refs doesn't cause a deleted head to come back
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
let git_repo = repo.store().git_repo().unwrap();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ use jujutsu_lib::index::IndexRef;
|
|||
use jujutsu_lib::repo::ReadonlyRepo;
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::{create_random_commit, CommitGraphBuilder};
|
||||
use jujutsu_lib::testutils::{create_random_commit, CommitGraphBuilder, TestRepo};
|
||||
use test_case::test_case;
|
||||
|
||||
#[must_use]
|
||||
|
@ -42,7 +42,7 @@ fn generation_number<'a>(index: impl Into<IndexRef<'a>>, commit_id: &CommitId) -
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_index_commits_empty_repo(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let index = repo.index();
|
||||
|
@ -60,7 +60,7 @@ fn test_index_commits_empty_repo(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_index_commits_standard_cases(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// o H
|
||||
|
@ -128,7 +128,7 @@ fn test_index_commits_standard_cases(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_index_commits_criss_cross(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let num_generations = 50;
|
||||
|
@ -228,7 +228,7 @@ fn test_index_commits_criss_cross(use_git: bool) {
|
|||
fn test_index_commits_previous_operations(use_git: bool) {
|
||||
// Test that commits visible only in previous operations are indexed.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Remove commit B and C in one operation and make sure they're still
|
||||
|
@ -276,7 +276,7 @@ fn test_index_commits_previous_operations(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_index_commits_incremental(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Create A in one operation, then B and C in another. Check that the index is
|
||||
|
@ -324,7 +324,7 @@ fn test_index_commits_incremental(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_index_commits_incremental_empty_transaction(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Create A in one operation, then just an empty transaction. Check that the
|
||||
|
@ -366,7 +366,7 @@ fn test_index_commits_incremental_empty_transaction(use_git: bool) {
|
|||
fn test_index_commits_incremental_already_indexed(use_git: bool) {
|
||||
// Tests that trying to add a commit that's already been added is a no-op.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Create A in one operation, then try to add it again an new transaction.
|
||||
|
@ -415,24 +415,24 @@ fn commits_by_level(repo: &ReadonlyRepo) -> Vec<u32> {
|
|||
fn test_index_commits_incremental_squashed(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 1);
|
||||
assert_eq!(commits_by_level(&repo), vec![2]);
|
||||
let repo = create_n_commits(&settings, &repo, 1);
|
||||
assert_eq!(commits_by_level(&repo), vec![3]);
|
||||
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 2);
|
||||
assert_eq!(commits_by_level(&repo), vec![3]);
|
||||
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 100);
|
||||
assert_eq!(commits_by_level(&repo), vec![101]);
|
||||
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 1);
|
||||
let repo = create_n_commits(&settings, &repo, 2);
|
||||
|
@ -442,7 +442,7 @@ fn test_index_commits_incremental_squashed(use_git: bool) {
|
|||
let repo = create_n_commits(&settings, &repo, 32);
|
||||
assert_eq!(commits_by_level(&repo), vec![64]);
|
||||
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 32);
|
||||
let repo = create_n_commits(&settings, &repo, 16);
|
||||
|
@ -451,7 +451,7 @@ fn test_index_commits_incremental_squashed(use_git: bool) {
|
|||
let repo = create_n_commits(&settings, &repo, 2);
|
||||
assert_eq!(commits_by_level(&repo), vec![57, 6]);
|
||||
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 30);
|
||||
let repo = create_n_commits(&settings, &repo, 15);
|
||||
|
@ -460,7 +460,7 @@ fn test_index_commits_incremental_squashed(use_git: bool) {
|
|||
let repo = create_n_commits(&settings, &repo, 1);
|
||||
assert_eq!(commits_by_level(&repo), vec![31, 15, 7, 3, 1]);
|
||||
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let repo = create_n_commits(&settings, repo, 10);
|
||||
let repo = create_n_commits(&settings, &repo, 10);
|
||||
|
|
|
@ -17,6 +17,7 @@ use std::path::{Path, PathBuf};
|
|||
use jujutsu_lib::op_store::WorkspaceId;
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestWorkspace;
|
||||
use jujutsu_lib::workspace::Workspace;
|
||||
use test_case::test_case;
|
||||
|
||||
|
@ -83,7 +84,7 @@ fn test_init_external_git() {
|
|||
fn test_init_no_config_set(use_git: bool) {
|
||||
// Test that we can create a repo without setting any config
|
||||
let settings = UserSettings::from_config(config::Config::default());
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let checkout_id = repo.view().get_checkout(&WorkspaceId::default()).unwrap();
|
||||
let checkout_commit = repo.store().get_commit(checkout_id).unwrap();
|
||||
|
@ -110,7 +111,7 @@ fn test_init_no_config_set(use_git: bool) {
|
|||
fn test_init_checkout(use_git: bool) {
|
||||
// Test the contents of the checkout after init
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let checkout_id = repo.view().get_checkout(&WorkspaceId::default()).unwrap();
|
||||
let checkout_commit = repo.store().get_commit(checkout_id).unwrap();
|
||||
|
|
|
@ -14,13 +14,14 @@
|
|||
|
||||
use jujutsu_lib::repo::RepoLoader;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestRepo;
|
||||
use test_case::test_case;
|
||||
|
||||
#[test_case(false ; "local backend")]
|
||||
#[test_case(true ; "git backend")]
|
||||
fn test_load_at_operation(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("add commit");
|
||||
|
|
|
@ -18,6 +18,7 @@ use jujutsu_lib::backend::{ConflictPart, TreeValue};
|
|||
use jujutsu_lib::commit_builder::CommitBuilder;
|
||||
use jujutsu_lib::repo_path::{RepoPath, RepoPathComponent};
|
||||
use jujutsu_lib::rewrite::rebase_commit;
|
||||
use jujutsu_lib::testutils::TestRepo;
|
||||
use jujutsu_lib::tree::Tree;
|
||||
use jujutsu_lib::{testutils, tree};
|
||||
use test_case::test_case;
|
||||
|
@ -29,7 +30,7 @@ fn test_same_type(use_git: bool) {
|
|||
// using only normal files in all trees (no symlinks, no trees, etc.).
|
||||
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store();
|
||||
|
||||
|
@ -214,7 +215,7 @@ fn test_subtrees(use_git: bool) {
|
|||
// Tests that subtrees are merged.
|
||||
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store();
|
||||
|
||||
|
@ -271,7 +272,7 @@ fn test_subtree_becomes_empty(use_git: bool) {
|
|||
// Tests that subtrees that become empty are removed from the parent tree.
|
||||
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store();
|
||||
|
||||
|
@ -303,7 +304,7 @@ fn test_subtree_one_missing(use_git: bool) {
|
|||
// Tests that merging trees where one side is missing is resolved as if the
|
||||
// missing side was empty.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store();
|
||||
|
||||
|
@ -350,7 +351,7 @@ fn test_types(use_git: bool) {
|
|||
// conflicts survive the roundtrip to the store.
|
||||
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store();
|
||||
|
||||
|
@ -460,7 +461,7 @@ fn test_types(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_simplify_conflict(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let store = repo.store();
|
||||
|
||||
|
@ -560,7 +561,7 @@ fn test_simplify_conflict(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_simplify_conflict_after_resolving_parent(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Set up a repo like this:
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
use jujutsu_lib::commit_builder::CommitBuilder;
|
||||
use jujutsu_lib::op_store::{RefTarget, WorkspaceId};
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::{assert_rebased, CommitGraphBuilder};
|
||||
use jujutsu_lib::testutils::{assert_rebased, CommitGraphBuilder, TestRepo};
|
||||
use maplit::hashset;
|
||||
use test_case::test_case;
|
||||
|
||||
|
@ -27,7 +27,7 @@ use test_case::test_case;
|
|||
fn test_checkout_open(use_git: bool) {
|
||||
// Test that MutableRepo::check_out() uses the requested commit if it's open
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -52,7 +52,7 @@ fn test_checkout_closed(use_git: bool) {
|
|||
// Test that MutableRepo::check_out() creates a child if the requested commit is
|
||||
// closed
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -79,7 +79,7 @@ fn test_checkout_previous_not_empty(use_git: bool) {
|
|||
// Test that MutableRepo::check_out() does not usually abandon the previous
|
||||
// commit.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -107,7 +107,7 @@ fn test_checkout_previous_empty(use_git: bool) {
|
|||
// Test that MutableRepo::check_out() abandons the previous commit if it was
|
||||
// empty.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -139,7 +139,7 @@ fn test_checkout_previous_empty_with_description(use_git: bool) {
|
|||
// Test that MutableRepo::check_out() does not abandon the previous commit if it
|
||||
// has a non-empty description.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -172,7 +172,7 @@ fn test_checkout_previous_empty_non_head(use_git: bool) {
|
|||
// Test that MutableRepo::check_out() does not abandon the previous commit if it
|
||||
// was empty and is not a head
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -214,7 +214,7 @@ fn test_checkout_initial(use_git: bool) {
|
|||
// Test that MutableRepo::check_out() can be used on the initial checkout in a
|
||||
// workspace
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -242,7 +242,7 @@ fn test_add_head_success(use_git: bool) {
|
|||
// Test that MutableRepo::add_head() adds the head, and that it's still there
|
||||
// after commit. It should also be indexed.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Create a commit outside of the repo by using a temporary transaction. Then
|
||||
|
@ -277,7 +277,7 @@ fn test_add_head_ancestor(use_git: bool) {
|
|||
// Test that MutableRepo::add_head() does not add a head if it's an ancestor of
|
||||
// an existing head.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -307,7 +307,7 @@ fn test_add_head_not_immediate_child(use_git: bool) {
|
|||
// Test that MutableRepo::add_head() can be used for adding a head that is not
|
||||
// an immediate child of a current head.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -356,7 +356,7 @@ fn test_remove_head(use_git: bool) {
|
|||
// for commits no longer visible in that case so we don't have to reindex e.g.
|
||||
// when the user does `jj op undo`.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -393,7 +393,7 @@ fn test_add_public_head(use_git: bool) {
|
|||
// Test that MutableRepo::add_public_head() adds the head, and that it's still
|
||||
// there after commit.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -415,7 +415,7 @@ fn test_add_public_head_ancestor(use_git: bool) {
|
|||
// Test that MutableRepo::add_public_head() does not add a public head if it's
|
||||
// an ancestor of an existing public head.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -440,7 +440,7 @@ fn test_remove_public_head(use_git: bool) {
|
|||
// Test that MutableRepo::remove_public_head() removes the head, and that it's
|
||||
// still removed after commit.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -465,7 +465,7 @@ fn test_has_changed(use_git: bool) {
|
|||
// (e.g. not after setting a branch to point to where it was already
|
||||
// pointing).
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -553,7 +553,7 @@ fn test_rebase_descendants_simple(use_git: bool) {
|
|||
// DescendantRebaser that rebases descendants of rewritten and abandoned
|
||||
// commits.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -591,7 +591,7 @@ fn test_rebase_descendants_conflicting_rewrite(use_git: bool) {
|
|||
// Tests MutableRepo::create_descendant_rebaser() when a commit has been marked
|
||||
// as rewritten to several other commits.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
|
|
@ -18,6 +18,7 @@ use jujutsu_lib::backend::CommitId;
|
|||
use jujutsu_lib::commit_builder::CommitBuilder;
|
||||
use jujutsu_lib::repo::RepoRef;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestRepo;
|
||||
use test_case::test_case;
|
||||
|
||||
fn list_dir(dir: &Path) -> Vec<String> {
|
||||
|
@ -32,7 +33,7 @@ fn list_dir(dir: &Path) -> Vec<String> {
|
|||
fn test_unpublished_operation(use_git: bool) {
|
||||
// Test that the operation doesn't get published until that's requested.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let op_heads_dir = repo.repo_path().join("op_heads");
|
||||
|
@ -55,7 +56,7 @@ fn test_consecutive_operations(use_git: bool) {
|
|||
// Test that consecutive operations result in a single op-head on disk after
|
||||
// each operation
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let op_heads_dir = repo.repo_path().join("op_heads");
|
||||
|
@ -88,7 +89,7 @@ fn test_concurrent_operations(use_git: bool) {
|
|||
// Test that consecutive operations result in multiple op-heads on disk until
|
||||
// the repo has been reloaded (which currently happens right away).
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let op_heads_dir = repo.repo_path().join("op_heads");
|
||||
|
@ -133,7 +134,7 @@ fn assert_heads(repo: RepoRef, expected: Vec<&CommitId>) {
|
|||
fn test_isolation(use_git: bool) {
|
||||
// Test that two concurrent transactions don't see each other's changes.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
use jujutsu_lib::op_store::RefTarget;
|
||||
use jujutsu_lib::refs::merge_ref_targets;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::CommitGraphBuilder;
|
||||
use jujutsu_lib::testutils::{CommitGraphBuilder, TestWorkspace};
|
||||
|
||||
#[test]
|
||||
fn test_merge_ref_targets() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, false);
|
||||
let test_workspace = TestWorkspace::init(&settings, false);
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
// 6 7
|
||||
|
|
|
@ -17,7 +17,7 @@ use jujutsu_lib::commit_builder::CommitBuilder;
|
|||
use jujutsu_lib::op_store::{RefTarget, WorkspaceId};
|
||||
use jujutsu_lib::repo::RepoRef;
|
||||
use jujutsu_lib::revset::{parse, resolve_symbol, RevsetError};
|
||||
use jujutsu_lib::testutils::CommitGraphBuilder;
|
||||
use jujutsu_lib::testutils::{CommitGraphBuilder, TestRepo};
|
||||
use jujutsu_lib::{git, testutils};
|
||||
use test_case::test_case;
|
||||
|
||||
|
@ -25,7 +25,7 @@ use test_case::test_case;
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_resolve_symbol_root(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
assert_eq!(
|
||||
|
@ -38,7 +38,7 @@ fn test_resolve_symbol_root(use_git: bool) {
|
|||
fn test_resolve_symbol_commit_id() {
|
||||
let settings = testutils::user_settings();
|
||||
// Test only with git so we can get predictable commit ids
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -125,7 +125,7 @@ fn test_resolve_symbol_commit_id() {
|
|||
fn test_resolve_symbol_change_id() {
|
||||
let settings = testutils::user_settings();
|
||||
// Test only with git so we can get predictable change ids
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let git_repo = repo.store().git_repo().unwrap();
|
||||
|
@ -239,7 +239,7 @@ fn test_resolve_symbol_change_id() {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_resolve_symbol_checkout(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -288,7 +288,7 @@ fn test_resolve_symbol_checkout(use_git: bool) {
|
|||
#[test]
|
||||
fn test_resolve_symbol_git_refs() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -437,7 +437,7 @@ fn resolve_commit_ids_in_workspace(
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_root_and_checkout(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -464,7 +464,7 @@ fn test_evaluate_expression_root_and_checkout(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_heads(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
@ -526,7 +526,7 @@ fn test_evaluate_expression_heads(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_roots(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
@ -588,7 +588,7 @@ fn test_evaluate_expression_roots(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_parents(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
@ -649,7 +649,7 @@ fn test_evaluate_expression_parents(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_children(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -703,7 +703,7 @@ fn test_evaluate_expression_children(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_ancestors(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
@ -739,7 +739,7 @@ fn test_evaluate_expression_ancestors(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_range(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -802,7 +802,7 @@ fn test_evaluate_expression_range(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_dag_range(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit_id = repo.store().root_commit_id().clone();
|
||||
|
@ -872,7 +872,7 @@ fn test_evaluate_expression_dag_range(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_connected(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit_id = repo.store().root_commit_id().clone();
|
||||
|
@ -952,7 +952,7 @@ fn test_evaluate_expression_connected(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_descendants(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1001,7 +1001,7 @@ fn test_evaluate_expression_descendants(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_none(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// none() is empty (doesn't include the checkout, for example)
|
||||
|
@ -1012,7 +1012,7 @@ fn test_evaluate_expression_none(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_all(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1040,7 +1040,7 @@ fn test_evaluate_expression_all(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_visible_heads(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1060,7 +1060,7 @@ fn test_evaluate_expression_visible_heads(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_public_heads(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
@ -1093,7 +1093,7 @@ fn test_evaluate_expression_public_heads(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_git_refs(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1162,7 +1162,7 @@ fn test_evaluate_expression_git_refs(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_git_head(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1186,7 +1186,7 @@ fn test_evaluate_expression_git_head(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_branches(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1255,7 +1255,7 @@ fn test_evaluate_expression_branches(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_remote_branches(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1335,7 +1335,7 @@ fn test_evaluate_expression_remote_branches(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_merges(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1366,7 +1366,7 @@ fn test_evaluate_expression_merges(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_description(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1409,7 +1409,7 @@ fn test_evaluate_expression_description(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_author(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1472,7 +1472,7 @@ fn test_evaluate_expression_author(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_committer(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1535,7 +1535,7 @@ fn test_evaluate_expression_committer(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_union(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
@ -1608,7 +1608,7 @@ fn test_evaluate_expression_union(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_intersection(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
@ -1648,7 +1648,7 @@ fn test_evaluate_expression_intersection(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_difference(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
|
|
@ -16,14 +16,14 @@ use itertools::Itertools;
|
|||
use jujutsu_lib::revset::revset_for_commits;
|
||||
use jujutsu_lib::revset_graph_iterator::RevsetGraphEdge;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::CommitGraphBuilder;
|
||||
use jujutsu_lib::testutils::{CommitGraphBuilder, TestRepo};
|
||||
use test_case::test_case;
|
||||
|
||||
#[test_case(false ; "keep transitive edges")]
|
||||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_linearized(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Tests that a fork and a merge becomes a single edge:
|
||||
|
@ -65,7 +65,7 @@ fn test_graph_iterator_linearized(skip_transitive_edges: bool) {
|
|||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_virtual_octopus(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Tests that merges outside the set can result in more parent edges than there
|
||||
|
@ -127,7 +127,7 @@ fn test_graph_iterator_virtual_octopus(skip_transitive_edges: bool) {
|
|||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_simple_fork(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Tests that the branch with "C" gets emitted correctly:
|
||||
|
@ -175,7 +175,7 @@ fn test_graph_iterator_simple_fork(skip_transitive_edges: bool) {
|
|||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_multiple_missing(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Tests that we get missing edges to "a" and "c" and not just one missing edge
|
||||
|
@ -229,7 +229,7 @@ fn test_graph_iterator_multiple_missing(skip_transitive_edges: bool) {
|
|||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_edge_to_ancestor(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Tests that we get both an edge from F to D and to D's ancestor C if we keep
|
||||
|
@ -294,7 +294,7 @@ fn test_graph_iterator_edge_to_ancestor(skip_transitive_edges: bool) {
|
|||
#[test_case(true ; "skip transitive edges")]
|
||||
fn test_graph_iterator_edge_escapes_from_(skip_transitive_edges: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Tests a more complex case for skipping transitive edges.
|
||||
|
@ -385,7 +385,7 @@ fn test_graph_iterator_edge_escapes_from_(skip_transitive_edges: bool) {
|
|||
#[test]
|
||||
fn test_reverse_graph_iterator() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let test_repo = TestRepo::init(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Tests that merges, forks, direct edges, indirect edges, and "missing" edges
|
||||
|
|
|
@ -17,7 +17,7 @@ use jujutsu_lib::op_store::{RefTarget, WorkspaceId};
|
|||
use jujutsu_lib::repo_path::RepoPath;
|
||||
use jujutsu_lib::rewrite::DescendantRebaser;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::{assert_rebased, create_random_commit, CommitGraphBuilder};
|
||||
use jujutsu_lib::testutils::{assert_rebased, create_random_commit, CommitGraphBuilder, TestRepo};
|
||||
use maplit::{hashmap, hashset};
|
||||
use test_case::test_case;
|
||||
|
||||
|
@ -25,7 +25,7 @@ use test_case::test_case;
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_sideways(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit F. Commits C-E should be rebased.
|
||||
|
@ -73,7 +73,7 @@ fn test_rebase_descendants_sideways(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_forward(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit F. Commits C and E should be rebased onto F.
|
||||
|
@ -133,7 +133,7 @@ fn test_rebase_descendants_forward(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_reorder(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit E was replaced by commit D, and commit C was replaced by commit F
|
||||
|
@ -185,7 +185,7 @@ fn test_rebase_descendants_reorder(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_backward(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit C was replaced by commit B. Commit D should be rebased.
|
||||
|
@ -223,7 +223,7 @@ fn test_rebase_descendants_backward(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_chain_becomes_branchy(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit E and commit C was replaced by commit F.
|
||||
|
@ -271,7 +271,7 @@ fn test_rebase_descendants_chain_becomes_branchy(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_internal_merge(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit F. Commits C-E should be rebased.
|
||||
|
@ -321,7 +321,7 @@ fn test_rebase_descendants_internal_merge(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_external_merge(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit C was replaced by commit F. Commits E should be rebased. The rebased
|
||||
|
@ -370,7 +370,7 @@ fn test_rebase_descendants_external_merge(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_abandon(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B and commit E were abandoned. Commit C and commit D should get
|
||||
|
@ -416,7 +416,7 @@ fn test_rebase_descendants_abandon(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_abandon_no_descendants(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B and C were abandoned. Commit A should become a head.
|
||||
|
@ -451,7 +451,7 @@ fn test_rebase_descendants_abandon_no_descendants(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_abandon_and_replace(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit E. Commit C was abandoned. Commit D should
|
||||
|
@ -490,7 +490,7 @@ fn test_rebase_descendants_abandon_and_replace(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_abandon_degenerate_merge(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was abandoned. Commit D should get rebased to have only C as parent
|
||||
|
@ -528,7 +528,7 @@ fn test_rebase_descendants_abandon_degenerate_merge(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_abandon_widen_merge(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit E was abandoned. Commit F should get rebased to have B, C, and D as
|
||||
|
@ -574,7 +574,7 @@ fn test_rebase_descendants_abandon_widen_merge(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_multiple_sideways(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B and commit D were both replaced by commit F. Commit C and commit E
|
||||
|
@ -621,7 +621,7 @@ fn test_rebase_descendants_multiple_sideways(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_multiple_swap(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit D. Commit D was replaced by commit B.
|
||||
|
@ -666,7 +666,7 @@ fn test_rebase_descendants_multiple_swap(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_multiple_no_descendants(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit C. Commit C was replaced by commit B.
|
||||
|
@ -705,7 +705,7 @@ fn test_rebase_descendants_multiple_no_descendants(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_divergent_rewrite(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit B2. Commit D was replaced by commits D2 and
|
||||
|
@ -773,7 +773,7 @@ fn test_rebase_descendants_divergent_rewrite(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_repeated(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit B2. Commit C should get rebased. Rebasing
|
||||
|
@ -835,7 +835,7 @@ fn test_rebase_descendants_repeated(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_contents(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Commit B was replaced by commit D. Commit C should have the changes from
|
||||
|
@ -900,7 +900,7 @@ fn test_rebase_descendants_contents(use_git: bool) {
|
|||
#[test]
|
||||
fn test_rebase_descendants_basic_branch_update() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" points to commit B. B gets rewritten as B2. Branch main should
|
||||
|
@ -935,7 +935,7 @@ fn test_rebase_descendants_basic_branch_update() {
|
|||
#[test]
|
||||
fn test_rebase_descendants_branch_move_two_steps() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" points to branch C. C gets rewritten as C2 and B gets rewritten
|
||||
|
@ -978,7 +978,7 @@ fn test_rebase_descendants_branch_move_two_steps() {
|
|||
#[test]
|
||||
fn test_rebase_descendants_basic_branch_update_with_non_local_branch() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" points to commit B. B gets rewritten as B2. Branch main should
|
||||
|
@ -1033,7 +1033,7 @@ fn test_rebase_descendants_basic_branch_update_with_non_local_branch() {
|
|||
#[test]
|
||||
fn test_rebase_descendants_update_branch_after_abandon() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" points to commit B. B is then abandoned. Branch main should
|
||||
|
@ -1067,7 +1067,7 @@ fn test_rebase_descendants_update_branch_after_abandon() {
|
|||
#[test]
|
||||
fn test_rebase_descendants_update_branches_after_divergent_rewrite() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" points to commit B. B gets rewritten as B2, B3, B4. Branch main
|
||||
|
@ -1123,7 +1123,7 @@ fn test_rebase_descendants_update_branches_after_divergent_rewrite() {
|
|||
#[test]
|
||||
fn test_rebase_descendants_rewrite_updates_branch_conflict() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" is a conflict removing commit A and adding commits B and C.
|
||||
|
@ -1184,7 +1184,7 @@ fn test_rebase_descendants_rewrite_updates_branch_conflict() {
|
|||
#[test]
|
||||
fn test_rebase_descendants_rewrite_resolves_branch_conflict() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" is a conflict removing ancestor commit A and adding commit B
|
||||
|
@ -1227,7 +1227,7 @@ fn test_rebase_descendants_rewrite_resolves_branch_conflict() {
|
|||
#[test]
|
||||
fn test_rebase_descendants_branch_delete_modify_abandon() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" initially points to commit A. One operation rewrites it to
|
||||
|
@ -1258,7 +1258,7 @@ fn test_rebase_descendants_branch_delete_modify_abandon() {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_update_checkout_open(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Checked-out, open commit B was replaced by open commit C. C should become
|
||||
|
@ -1302,7 +1302,7 @@ fn test_rebase_descendants_update_checkout_open(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_update_checkout_closed(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Checked-out, open commit B was replaced by closed commit C. A child of C
|
||||
|
@ -1355,7 +1355,7 @@ fn test_rebase_descendants_update_checkout_closed(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_rebase_descendants_update_checkout_abandoned_merge(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Checked-out, open merge commit D was abandoned. A parent commit should become
|
||||
|
|
|
@ -19,7 +19,7 @@ use jujutsu_lib::op_store::{BranchTarget, RefTarget, WorkspaceId};
|
|||
use jujutsu_lib::repo::ReadonlyRepo;
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::CommitGraphBuilder;
|
||||
use jujutsu_lib::testutils::{CommitGraphBuilder, TestRepo};
|
||||
use jujutsu_lib::transaction::Transaction;
|
||||
use maplit::{btreemap, hashset};
|
||||
use test_case::test_case;
|
||||
|
@ -28,7 +28,7 @@ use test_case::test_case;
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_heads_empty(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
assert_eq!(
|
||||
|
@ -45,7 +45,7 @@ fn test_heads_empty(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_heads_fork(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
||||
|
@ -68,7 +68,7 @@ fn test_heads_fork(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_heads_merge(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let test_repo = TestRepo::init(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
||||
|
@ -86,7 +86,7 @@ fn test_heads_merge(use_git: bool) {
|
|||
fn test_merge_views_heads() {
|
||||
// Tests merging of the view's heads (by performing concurrent operations).
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -153,7 +153,7 @@ fn test_merge_views_heads() {
|
|||
fn test_merge_views_checkout() {
|
||||
// Tests merging of the view's checkout (by performing concurrent operations).
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Workspace 1 gets updated in both transactions.
|
||||
|
@ -239,7 +239,7 @@ fn test_merge_views_branches() {
|
|||
// Tests merging of branches (by performing concurrent operations). See
|
||||
// test_refs.rs for tests of merging of individual ref targets.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -340,7 +340,7 @@ fn test_merge_views_tags() {
|
|||
// Tests merging of tags (by performing concurrent operations). See
|
||||
// test_refs.rs for tests of merging of individual ref targets.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -386,7 +386,7 @@ fn test_merge_views_git_refs() {
|
|||
// Tests merging of git refs (by performing concurrent operations). See
|
||||
// test_refs.rs for tests of merging of individual ref targets.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -466,7 +466,7 @@ fn test_merge_views_child_on_rewritten(child_first: bool) {
|
|||
// We start with just commit A. Operation 1 adds commit B on top. Operation 2
|
||||
// rewrites A as A2.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction("test");
|
||||
let commit_a =
|
||||
|
@ -509,7 +509,7 @@ fn test_merge_views_child_on_rewritten_divergent(on_rewritten: bool, child_first
|
|||
// gets rebased onto A4 if it was based on A2 before, but if it was based on
|
||||
// A3, it should remain there.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction("test");
|
||||
let commit_a2 =
|
||||
|
@ -561,7 +561,7 @@ fn test_merge_views_child_on_abandoned(child_first: bool) {
|
|||
// We start with commit B on top of commit A. Operation 1 adds commit C on top.
|
||||
// Operation 2 abandons B.
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = testutils::init_repo(&settings, false);
|
||||
let test_repo = TestRepo::init(&settings, false);
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction("test");
|
||||
let commit_a =
|
||||
|
|
|
@ -26,6 +26,7 @@ use jujutsu_lib::repo::ReadonlyRepo;
|
|||
use jujutsu_lib::repo_path::{RepoPath, RepoPathComponent, RepoPathJoin};
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestWorkspace;
|
||||
use jujutsu_lib::tree_builder::TreeBuilder;
|
||||
use jujutsu_lib::working_copy::WorkingCopy;
|
||||
use test_case::test_case;
|
||||
|
@ -35,7 +36,7 @@ use test_case::test_case;
|
|||
fn test_root(use_git: bool) {
|
||||
// Test that the working copy is clean and empty after init.
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
let wc = test_workspace.workspace.working_copy_mut();
|
||||
|
@ -57,7 +58,7 @@ fn test_checkout_file_transitions(use_git: bool) {
|
|||
// additions and removals as well.
|
||||
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let store = repo.store().clone();
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
|
@ -277,7 +278,7 @@ fn test_checkout_file_transitions(use_git: bool) {
|
|||
#[test]
|
||||
fn test_reset() {
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, false);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, false);
|
||||
let repo = &test_workspace.repo;
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
@ -343,7 +344,7 @@ fn test_checkout_discard() {
|
|||
// copy files should remain changed, but the state files should not be
|
||||
// written.
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, false);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, false);
|
||||
let repo = test_workspace.repo.clone();
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
@ -390,7 +391,7 @@ fn test_commit_racy_timestamps(use_git: bool) {
|
|||
// millisecond as the updated working copy state.
|
||||
let _home_dir = testutils::new_user_home();
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
@ -422,7 +423,7 @@ fn test_gitignores(use_git: bool) {
|
|||
|
||||
let _home_dir = testutils::new_user_home();
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
@ -498,7 +499,7 @@ fn test_gitignores_checkout_overwrites_ignored(use_git: bool) {
|
|||
|
||||
let _home_dir = testutils::new_user_home();
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
@ -551,7 +552,7 @@ fn test_gitignores_ignored_directory_already_tracked(use_git: bool) {
|
|||
|
||||
let _home_dir = testutils::new_user_home();
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
// Add a .gitignore file saying to ignore the directory "ignored/"
|
||||
|
@ -595,7 +596,7 @@ fn test_dotgit_ignored(use_git: bool) {
|
|||
|
||||
let _home_dir = testutils::new_user_home();
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ use std::thread;
|
|||
use jujutsu_lib::gitignore::GitIgnoreFile;
|
||||
use jujutsu_lib::repo_path::RepoPath;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestWorkspace;
|
||||
use jujutsu_lib::working_copy::CheckoutError;
|
||||
use jujutsu_lib::workspace::Workspace;
|
||||
use test_case::test_case;
|
||||
|
@ -28,7 +29,7 @@ fn test_concurrent_checkout(use_git: bool) {
|
|||
// Test that we error out if a concurrent checkout is detected (i.e. if the
|
||||
// current checkout changed on disk after we read it).
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace1 = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace1 = TestWorkspace::init(&settings, use_git);
|
||||
let repo1 = test_workspace1.repo.clone();
|
||||
let workspace1_root = test_workspace1.workspace.workspace_root().clone();
|
||||
|
||||
|
@ -78,7 +79,7 @@ fn test_checkout_parallel(use_git: bool) {
|
|||
// Test that concurrent checkouts by different processes (simulated by using
|
||||
// different repo instances) is safe.
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
|
|
@ -17,12 +17,13 @@ use jujutsu_lib::gitignore::GitIgnoreFile;
|
|||
use jujutsu_lib::matchers::EverythingMatcher;
|
||||
use jujutsu_lib::repo_path::RepoPath;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestWorkspace;
|
||||
use jujutsu_lib::working_copy::{CheckoutStats, WorkingCopy};
|
||||
|
||||
#[test]
|
||||
fn test_sparse_checkout() {
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, false);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, false);
|
||||
let repo = &test_workspace.repo;
|
||||
let working_copy_path = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
@ -129,7 +130,7 @@ fn test_sparse_checkout() {
|
|||
#[test]
|
||||
fn test_sparse_commit() {
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, false);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, false);
|
||||
let repo = &test_workspace.repo;
|
||||
let working_copy_path = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
@ -207,7 +208,7 @@ fn test_sparse_commit() {
|
|||
fn test_sparse_commit_gitignore() {
|
||||
// Test that (untracked) .gitignore files in parent directories are respected
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = testutils::init_workspace(&settings, false);
|
||||
let mut test_workspace = TestWorkspace::init(&settings, false);
|
||||
let repo = &test_workspace.repo;
|
||||
let working_copy_path = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
use jujutsu_lib::op_store::WorkspaceId;
|
||||
use jujutsu_lib::testutils;
|
||||
use jujutsu_lib::testutils::TestWorkspace;
|
||||
use jujutsu_lib::workspace::{Workspace, WorkspaceLoadError};
|
||||
use test_case::test_case;
|
||||
|
||||
|
@ -34,7 +35,7 @@ fn test_load_bad_path() {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_load_from_subdir(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let workspace = &test_workspace.workspace;
|
||||
|
||||
let subdir = workspace.workspace_root().join("dir").join("subdir");
|
||||
|
@ -50,7 +51,7 @@ fn test_load_from_subdir(use_git: bool) {
|
|||
// #[test_case(true ; "git backend")]
|
||||
fn test_init_additional_workspace(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let test_workspace = TestWorkspace::init(&settings, use_git);
|
||||
let workspace = &test_workspace.workspace;
|
||||
|
||||
let ws2_id = WorkspaceId::new("ws2".to_string());
|
||||
|
|
Loading…
Reference in a new issue