From 0b24a177f6fcd908c6bc453c23242caf5adccdaa Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 17 Sep 2023 21:26:31 -0700 Subject: [PATCH] testutils: delete bool-typed `init()` in favor of enum-typed version It makes the call sites clearer if we pass the `TestRepoBackend` enum instead of the boolean `use_git` value. It's also more extensible (I plan to add another backend for tests). --- cli/src/merge_tools/builtin.rs | 6 +- lib/tests/test_bad_locking.rs | 18 +- lib/tests/test_commit_builder.rs | 34 +-- lib/tests/test_commit_concurrent.rs | 18 +- lib/tests/test_conflicts.rs | 14 +- .../test_default_revset_graph_iterator.rs | 14 +- lib/tests/test_diff_summary.rs | 42 +-- lib/tests/test_git.rs | 37 +-- lib/tests/test_id_prefix.rs | 4 +- lib/tests/test_index.rs | 85 +++--- lib/tests/test_init.rs | 18 +- lib/tests/test_load_repo.rs | 10 +- lib/tests/test_merge_trees.rs | 66 ++--- lib/tests/test_merged_tree.rs | 32 +-- lib/tests/test_mut_repo.rs | 153 +++++----- lib/tests/test_operations.rs | 34 +-- lib/tests/test_refs.rs | 4 +- lib/tests/test_revset.rs | 262 +++++++++--------- lib/tests/test_rewrite.rs | 186 ++++++------- lib/tests/test_view.rs | 45 +-- lib/tests/test_working_copy.rs | 98 +++---- lib/tests/test_working_copy_concurrent.rs | 8 +- lib/tests/test_working_copy_sparse.rs | 8 +- lib/tests/test_workspace.rs | 10 +- lib/testutils/src/lib.rs | 18 -- 25 files changed, 605 insertions(+), 619 deletions(-) diff --git a/cli/src/merge_tools/builtin.rs b/cli/src/merge_tools/builtin.rs index 39412e9e6f..9305063854 100644 --- a/cli/src/merge_tools/builtin.rs +++ b/cli/src/merge_tools/builtin.rs @@ -543,13 +543,13 @@ pub fn edit_merge_builtin( mod tests { use jj_lib::conflicts::extract_as_single_hunk; use jj_lib::repo::Repo; - use testutils::TestRepo; + use testutils::{TestRepo, TestRepoBackend}; use super::*; #[test] fn test_edit_diff_builtin() { - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let store = test_repo.repo.store(); let unused_path = RepoPath::from_internal_string("unused"); @@ -691,7 +691,7 @@ mod tests { #[test] fn test_make_merge_sections() { - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let store = test_repo.repo.store(); let path = RepoPath::from_internal_string("file"); diff --git a/lib/tests/test_bad_locking.rs b/lib/tests/test_bad_locking.rs index 94b0770b42..e285fb19b1 100644 --- a/lib/tests/test_bad_locking.rs +++ b/lib/tests/test_bad_locking.rs @@ -18,7 +18,7 @@ use itertools::Itertools; use jj_lib::repo::{Repo, StoreFactories}; use jj_lib::workspace::Workspace; use test_case::test_case; -use testutils::{create_random_commit, load_repo_at_head, TestWorkspace}; +use testutils::{create_random_commit, load_repo_at_head, TestRepoBackend, TestWorkspace}; fn copy_directory(src: &Path, dst: &Path) { std::fs::create_dir(dst).ok(); @@ -95,13 +95,13 @@ fn merge_directories(left: &Path, base: &Path, right: &Path, output: &Path) { } } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_bad_locking_children(use_git: bool) { +#[test_case(TestRepoBackend::Local; "local backend")] +#[test_case(TestRepoBackend::Git; "git backend")] +fn test_bad_locking_children(backend: TestRepoBackend) { // 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 = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root(); @@ -161,14 +161,14 @@ fn test_bad_locking_children(use_git: bool) { assert_eq!(op.parents.len(), 2); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_bad_locking_interrupted(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_bad_locking_interrupted(backend: TestRepoBackend) { // Test that an interrupted update of the op-heads resulting in on op-head // that's a descendant of the other is resolved without creating a new // operation. let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let mut tx = repo.start_transaction(&settings, "test"); diff --git a/lib/tests/test_commit_builder.rs b/lib/tests/test_commit_builder.rs index c7f38a5aac..506c3874b2 100644 --- a/lib/tests/test_commit_builder.rs +++ b/lib/tests/test_commit_builder.rs @@ -19,13 +19,13 @@ use jj_lib::repo::Repo; use jj_lib::repo_path::RepoPath; use jj_lib::settings::UserSettings; use test_case::test_case; -use testutils::{assert_rebased, create_tree, CommitGraphBuilder, TestRepo}; +use testutils::{assert_rebased, create_tree, CommitGraphBuilder, TestRepo, TestRepoBackend}; -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_initial(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_initial(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store(); @@ -92,11 +92,11 @@ fn test_initial(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rewrite(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rewrite(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store().clone(); @@ -188,12 +188,12 @@ fn test_rewrite(use_git: bool) { } // An author field with an empty name/email should get filled in on rewrite -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rewrite_update_missing_user(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rewrite_update_missing_user(backend: TestRepoBackend) { let missing_user_settings = UserSettings::from_config(config::Config::builder().build().unwrap()); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&missing_user_settings, "test"); @@ -237,11 +237,11 @@ fn test_rewrite_update_missing_user(use_git: bool) { ); } -#[test_case(false ; "local backend")] -// #[test_case(true ; "git backend")] -fn test_commit_builder_descendants(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +// #[test_case(TestRepoBackend::Git ; "git backend")] +fn test_commit_builder_descendants(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store().clone(); diff --git a/lib/tests/test_commit_concurrent.rs b/lib/tests/test_commit_concurrent.rs index 9f2404029d..4cde11ae2d 100644 --- a/lib/tests/test_commit_concurrent.rs +++ b/lib/tests/test_commit_concurrent.rs @@ -19,7 +19,7 @@ use std::thread; use jj_lib::dag_walk; use jj_lib::repo::{ReadonlyRepo, Repo}; use test_case::test_case; -use testutils::{load_repo_at_head, write_random_commit, TestWorkspace}; +use testutils::{load_repo_at_head, write_random_commit, TestRepoBackend, TestWorkspace}; fn count_non_merge_operations(repo: &Arc) -> usize { let op_store = repo.op_store(); @@ -38,14 +38,14 @@ fn count_non_merge_operations(repo: &Arc) -> usize { num_ops } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_commit_parallel(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_commit_parallel(backend: TestRepoBackend) { // This loads a Repo instance and creates and commits many concurrent // 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 = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let num_threads = max(num_cpus::get(), 4); @@ -70,13 +70,13 @@ fn test_commit_parallel(use_git: bool) { assert_eq!(count_non_merge_operations(&repo), num_threads + 2); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_commit_parallel_instances(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_commit_parallel_instances(backend: TestRepoBackend) { // 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 = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let num_threads = max(num_cpus::get(), 4); diff --git a/lib/tests/test_conflicts.rs b/lib/tests/test_conflicts.rs index 522212845b..07c10cb909 100644 --- a/lib/tests/test_conflicts.rs +++ b/lib/tests/test_conflicts.rs @@ -20,11 +20,11 @@ use jj_lib::merge::Merge; use jj_lib::repo::Repo; use jj_lib::repo_path::RepoPath; use jj_lib::store::Store; -use testutils::TestRepo; +use testutils::{TestRepo, TestRepoBackend}; #[test] fn test_materialize_conflict_basic() { - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let store = test_repo.repo.store(); let path = RepoPath::from_internal_string("file"); @@ -113,7 +113,7 @@ line 5 #[test] fn test_materialize_conflict_multi_rebase_conflicts() { - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let store = test_repo.repo.store(); // Create changes (a, b, c) on top of the base, and linearize them. @@ -232,7 +232,7 @@ line 3 #[test] fn test_materialize_parse_roundtrip() { - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let store = test_repo.repo.store(); let path = RepoPath::from_internal_string("file"); @@ -334,7 +334,7 @@ line 5 right #[test] fn test_materialize_conflict_modify_delete() { - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let store = test_repo.repo.store(); let path = RepoPath::from_internal_string("file"); @@ -614,7 +614,7 @@ line 5 #[test] fn test_update_conflict_from_content() { - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let store = test_repo.repo.store(); let path = RepoPath::from_internal_string("dir/file"); @@ -665,7 +665,7 @@ fn test_update_conflict_from_content() { #[test] fn test_update_conflict_from_content_modify_delete() { - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let store = test_repo.repo.store(); let path = RepoPath::from_internal_string("dir/file"); diff --git a/lib/tests/test_default_revset_graph_iterator.rs b/lib/tests/test_default_revset_graph_iterator.rs index c429be38b7..bc8d346b0e 100644 --- a/lib/tests/test_default_revset_graph_iterator.rs +++ b/lib/tests/test_default_revset_graph_iterator.rs @@ -20,7 +20,7 @@ use jj_lib::repo::{ReadonlyRepo, Repo as _}; use jj_lib::revset::ResolvedExpression; use jj_lib::revset_graph::RevsetGraphEdge; use test_case::test_case; -use testutils::{CommitGraphBuilder, TestRepo}; +use testutils::{CommitGraphBuilder, TestRepo, TestRepoBackend}; fn revset_for_commits<'index>( repo: &'index ReadonlyRepo, @@ -53,7 +53,7 @@ fn missing(commit: &Commit) -> RevsetGraphEdge { #[test_case(true ; "skip transitive edges")] fn test_graph_iterator_linearized(skip_transitive_edges: bool) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Tests that a fork and a merge becomes a single edge: @@ -89,7 +89,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 = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Tests that merges outside the set can result in more parent edges than there @@ -140,7 +140,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 = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Tests that the branch with "C" gets emitted correctly: @@ -182,7 +182,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 = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Tests that we get missing edges to "a" and "c" and not just one missing edge @@ -224,7 +224,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 = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); 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 @@ -271,7 +271,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 = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Tests a more complex case for skipping transitive edges. diff --git a/lib/tests/test_diff_summary.rs b/lib/tests/test_diff_summary.rs index 79ae6c45f7..42fb24a70a 100644 --- a/lib/tests/test_diff_summary.rs +++ b/lib/tests/test_diff_summary.rs @@ -16,12 +16,12 @@ use jj_lib::matchers::{EverythingMatcher, FilesMatcher}; use jj_lib::merged_tree::DiffSummary; use jj_lib::repo_path::RepoPath; use test_case::test_case; -use testutils::{create_tree, TestRepo}; +use testutils::{create_tree, TestRepo, TestRepoBackend}; -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_types(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_types(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let clean_path = RepoPath::from_internal_string("clean"); @@ -57,10 +57,10 @@ fn test_types(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_tree_file_transition(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_tree_file_transition(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let dir_file_path = RepoPath::from_internal_string("dir/file"); @@ -87,10 +87,10 @@ fn test_tree_file_transition(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_sorting(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_sorting(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let a_path = RepoPath::from_internal_string("a"); @@ -152,10 +152,10 @@ fn test_sorting(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_matcher_dir_file_transition(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_matcher_dir_file_transition(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let a_path = RepoPath::from_internal_string("a"); @@ -219,10 +219,10 @@ fn test_matcher_dir_file_transition(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_matcher_normal_cases(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_matcher_normal_cases(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let a_path = RepoPath::from_internal_string("a"); diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index e22bac5bd1..9230f14099 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -39,6 +39,7 @@ use maplit::{btreemap, hashset}; use tempfile::TempDir; use testutils::{ commit_transactions, create_random_commit, load_repo_at_head, write_random_commit, TestRepo, + TestRepoBackend, }; fn empty_git_commit<'r>( @@ -85,7 +86,7 @@ fn get_git_repo(repo: &Arc) -> git2::Repository { fn test_import_refs() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -185,7 +186,7 @@ fn test_import_refs() { fn test_import_refs_reimport() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_workspace = TestRepo::init(true); + let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_workspace.repo; let git_repo = get_git_repo(repo); @@ -277,7 +278,7 @@ 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 git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -302,7 +303,7 @@ fn test_import_refs_reimport_git_head_counts() { // descendant of it), we still keep it alive. let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -330,7 +331,7 @@ fn test_import_refs_reimport_git_head_without_ref() { // Simulate external `git checkout` in colocated repo, from anonymous branch. let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -364,7 +365,7 @@ fn test_import_refs_reimport_git_head_with_moved_ref() { // Simulate external history rewriting in colocated repo. let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -400,7 +401,7 @@ fn test_import_refs_reimport_git_head_with_moved_ref() { fn test_import_refs_reimport_with_deleted_remote_ref() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_workspace = TestRepo::init(true); + let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_workspace.repo; let git_repo = get_git_repo(repo); @@ -489,7 +490,7 @@ fn test_import_refs_reimport_with_deleted_remote_ref() { fn test_import_refs_reimport_with_moved_remote_ref() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_workspace = TestRepo::init(true); + let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_workspace.repo; let git_repo = get_git_repo(repo); @@ -605,7 +606,7 @@ fn test_import_refs_reimport_git_head_with_fixed_ref() { // Simulate external `git checkout` in colocated repo, from named branch. let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -640,7 +641,7 @@ fn test_import_refs_reimport_all_from_root_removed() { // we abandon the whole stack, but not including the root commit. let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -666,7 +667,7 @@ fn test_import_refs_reimport_all_from_root_removed() { fn test_import_refs_reimport_conflicted_remote_branch() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -709,7 +710,7 @@ fn test_import_refs_reimport_conflicted_remote_branch() { fn test_import_refs_reserved_remote_name() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -724,7 +725,7 @@ fn test_import_refs_reserved_remote_name() { fn test_import_some_refs() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_workspace = TestRepo::init(true); + let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_workspace.repo; let git_repo = get_git_repo(repo); @@ -966,7 +967,7 @@ fn test_import_refs_empty_git_repo() { fn test_import_refs_missing_git_commit() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_workspace = TestRepo::init(true); + let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_workspace.repo; let git_repo = get_git_repo(repo); @@ -2071,7 +2072,7 @@ fn test_push_updates_invalid_remote() { fn test_bulk_update_extra_on_import_refs() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -2117,7 +2118,7 @@ fn test_bulk_update_extra_on_import_refs() { fn test_rewrite_imported_commit() { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = get_git_repo(repo); @@ -2167,7 +2168,7 @@ fn test_rewrite_imported_commit() { #[test] fn test_concurrent_write_commit() { let settings = &testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Try to create identical commits with different change ids. Timestamp of the @@ -2229,7 +2230,7 @@ fn test_concurrent_write_commit() { #[test] fn test_concurrent_read_write_commit() { let settings = &testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Create unique commits and load them concurrently. In this test, we assume diff --git a/lib/tests/test_id_prefix.rs b/lib/tests/test_id_prefix.rs index 27dd7635bc..a09aabf3eb 100644 --- a/lib/tests/test_id_prefix.rs +++ b/lib/tests/test_id_prefix.rs @@ -19,12 +19,12 @@ use jj_lib::index::HexPrefix; use jj_lib::index::PrefixResolution::{AmbiguousMatch, NoMatch, SingleMatch}; use jj_lib::repo::Repo; use jj_lib::revset::RevsetExpression; -use testutils::TestRepo; +use testutils::{TestRepo, TestRepoBackend}; #[test] fn test_id_prefix() { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let root_commit_id = repo.store().root_commit_id(); let root_change_id = repo.store().root_change_id(); diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index 0a15cf5d0a..435fccab85 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -26,6 +26,7 @@ use jj_lib::settings::UserSettings; use test_case::test_case; use testutils::{ create_random_commit, load_repo_at_head, write_random_commit, CommitGraphBuilder, TestRepo, + TestRepoBackend, }; fn child_commit<'repo>( @@ -48,10 +49,10 @@ fn to_positions_vec(index: CompositeIndex<'_>, commit_ids: &[CommitId]) -> Vec) -> Vec { .collect() } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_index_commits_incremental_squashed(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_index_commits_incremental_squashed(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let repo = create_n_commits(&settings, repo, 2); assert_eq!(commits_by_level(&repo), vec![3]); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let repo = create_n_commits(&settings, repo, 100); assert_eq!(commits_by_level(&repo), vec![101]); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let repo = create_n_commits(&settings, repo, 1); let repo = create_n_commits(&settings, &repo, 2); @@ -514,7 +515,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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let repo = create_n_commits(&settings, repo, 32); let repo = create_n_commits(&settings, &repo, 16); @@ -523,7 +524,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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let repo = create_n_commits(&settings, repo, 30); let repo = create_n_commits(&settings, &repo, 15); @@ -532,7 +533,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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let repo = create_n_commits(&settings, repo, 10); let repo = create_n_commits(&settings, &repo, 10); @@ -548,11 +549,11 @@ fn test_index_commits_incremental_squashed(use_git: bool) { /// Test that .jj/repo/index/type is created when the repo is created, and that /// it is created when an old repo is loaded. -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_index_store_type(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_index_store_type(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; assert_eq!(as_readonly_composite(repo).num_commits(), 1); diff --git a/lib/tests/test_init.rs b/lib/tests/test_init.rs index 4bbdaaef4e..0edcd76bf2 100644 --- a/lib/tests/test_init.rs +++ b/lib/tests/test_init.rs @@ -20,7 +20,7 @@ use jj_lib::repo::Repo; use jj_lib::settings::UserSettings; use jj_lib::workspace::Workspace; use test_case::test_case; -use testutils::{write_random_commit, TestWorkspace}; +use testutils::{write_random_commit, TestRepoBackend, TestWorkspace}; fn canonicalize(input: &Path) -> (PathBuf, PathBuf) { let uncanonical = input.join("..").join(input.file_name().unwrap()); @@ -93,12 +93,12 @@ fn test_init_external_git() { write_random_commit(tx.mut_repo(), &settings); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_init_no_config_set(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_init_no_config_set(backend: TestRepoBackend) { // Test that we can create a repo without setting any config let settings = UserSettings::from_config(config::Config::default()); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let wc_commit_id = repo .view() @@ -111,12 +111,12 @@ fn test_init_no_config_set(use_git: bool) { assert_eq!(wc_commit.committer().email, "".to_string()); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_init_checkout(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_init_checkout(backend: TestRepoBackend) { // Test the contents of the working-copy commit after init let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let wc_commit_id = repo .view() diff --git a/lib/tests/test_load_repo.rs b/lib/tests/test_load_repo.rs index c9acc7852c..65e77a5f57 100644 --- a/lib/tests/test_load_repo.rs +++ b/lib/tests/test_load_repo.rs @@ -14,13 +14,13 @@ use jj_lib::repo::{RepoLoader, StoreFactories}; use test_case::test_case; -use testutils::{write_random_commit, TestRepo}; +use testutils::{write_random_commit, TestRepo, TestRepoBackend}; -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_load_at_operation(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_load_at_operation(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "add commit"); diff --git a/lib/tests/test_merge_trees.rs b/lib/tests/test_merge_trees.rs index d739479f95..0f1f63894f 100644 --- a/lib/tests/test_merge_trees.rs +++ b/lib/tests/test_merge_trees.rs @@ -19,15 +19,15 @@ use jj_lib::repo_path::{RepoPath, RepoPathComponent}; use jj_lib::rewrite::rebase_commit; use jj_lib::tree::{merge_trees, Tree}; use test_case::test_case; -use testutils::{create_single_tree, create_tree, TestRepo}; +use testutils::{create_single_tree, create_tree, TestRepo, TestRepoBackend}; -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_same_type(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_same_type(backend: TestRepoBackend) { // Tests all possible cases where the entry type is unchanged, specifically // using only normal files in all trees (no symlinks, no trees, etc.). - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store(); @@ -187,10 +187,10 @@ fn test_same_type(use_git: bool) { }; } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_executable(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_executable(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store(); @@ -239,12 +239,12 @@ fn test_executable(use_git: bool) { assert_eq!(merged_tree.value(&RepoPathComponent::from("xxx")), exec); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_subtrees(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_subtrees(backend: TestRepoBackend) { // Tests that subtrees are merged. - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store(); @@ -294,12 +294,12 @@ fn test_subtrees(use_git: bool) { assert_eq!(entries, expected_entries); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_subtree_becomes_empty(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_subtree_becomes_empty(backend: TestRepoBackend) { // Tests that subtrees that become empty are removed from the parent tree. - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store(); @@ -324,12 +324,12 @@ fn test_subtree_becomes_empty(use_git: bool) { assert_eq!(merged_tree.id(), store.empty_tree_id()); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_subtree_one_missing(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_subtree_one_missing(backend: TestRepoBackend) { // Tests that merging trees where one side is missing is resolved as if the // missing side was empty. - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store(); @@ -367,13 +367,13 @@ fn test_subtree_one_missing(use_git: bool) { assert_eq!(reverse_merged_tree.id(), merged_tree.id()); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_types(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_types(backend: TestRepoBackend) { // Tests conflicts between different types. This is mostly to test that the // conflicts survive the roundtrip to the store. - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store(); @@ -466,10 +466,10 @@ fn test_types(use_git: bool) { }; } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_simplify_conflict(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_simplify_conflict(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let store = repo.store(); @@ -549,11 +549,11 @@ fn test_simplify_conflict(use_git: bool) { }; } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_simplify_conflict_after_resolving_parent(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_simplify_conflict_after_resolving_parent(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Set up a repo like this: diff --git a/lib/tests/test_merged_tree.rs b/lib/tests/test_merged_tree.rs index d297a0ebeb..07a33ac752 100644 --- a/lib/tests/test_merged_tree.rs +++ b/lib/tests/test_merged_tree.rs @@ -21,7 +21,7 @@ use jj_lib::repo::Repo; use jj_lib::repo_path::{RepoPath, RepoPathComponent, RepoPathJoin}; use jj_lib::tree::merge_trees; use pretty_assertions::assert_eq; -use testutils::{create_single_tree, write_file, TestRepo}; +use testutils::{create_single_tree, write_file, TestRepo, TestRepoBackend}; fn file_value(file_id: &FileId) -> TreeValue { TreeValue::File { @@ -32,7 +32,7 @@ fn file_value(file_id: &FileId) -> TreeValue { #[test] fn test_from_legacy_tree() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let store = repo.store(); @@ -223,7 +223,7 @@ fn test_from_legacy_tree() { #[test] fn test_path_value_and_entries() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Create a MergedTree @@ -348,7 +348,7 @@ fn test_path_value_and_entries() { #[test] fn test_resolve_success() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let unchanged_path = RepoPath::from_internal_string("unchanged"); @@ -415,7 +415,7 @@ fn test_resolve_success() { #[test] fn test_resolve_root_becomes_empty() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let store = repo.store(); @@ -432,7 +432,7 @@ fn test_resolve_root_becomes_empty() { #[test] fn test_resolve_with_conflict() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // The trivial conflict should be resolved but the non-trivial should not (and @@ -459,7 +459,7 @@ fn test_resolve_with_conflict() { #[test] fn test_conflict_iterator() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let unchanged_path = RepoPath::from_internal_string("dir/subdir/unchanged"); @@ -575,7 +575,7 @@ fn test_conflict_iterator() { } #[test] fn test_conflict_iterator_higher_arity() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let two_sided_path = RepoPath::from_internal_string("dir/2-sided"); @@ -652,7 +652,7 @@ fn test_conflict_iterator_higher_arity() { /// Diff two resolved trees #[test] fn test_diff_resolved() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let clean_path = RepoPath::from_internal_string("dir1/file"); @@ -711,7 +711,7 @@ fn test_diff_resolved() { /// Diff two conflicted trees #[test] fn test_diff_conflicted() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // path1 is a clean (unchanged) conflict @@ -816,7 +816,7 @@ fn test_diff_conflicted() { #[test] fn test_diff_dir_file() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // path1: file1 -> directory1 @@ -1048,7 +1048,7 @@ fn test_diff_dir_file() { /// Merge 3 resolved trees that can be resolved #[test] fn test_merge_simple() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let path1 = RepoPath::from_internal_string("dir1/file"); @@ -1069,7 +1069,7 @@ fn test_merge_simple() { /// Merge 3 resolved trees that can be partially resolved #[test] fn test_merge_partial_resolution() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // path1 can be resolved, path2 cannot @@ -1096,7 +1096,7 @@ fn test_merge_partial_resolution() { /// Merge 3 resolved trees, including one empty legacy tree #[test] fn test_merge_with_empty_legacy_tree() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let path1 = RepoPath::from_internal_string("dir1/file"); @@ -1121,7 +1121,7 @@ fn test_merge_with_empty_legacy_tree() { /// at by only simplifying the conflict (no need to recurse) #[test] fn test_merge_simplify_only() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let path = RepoPath::from_internal_string("dir1/file"); @@ -1154,7 +1154,7 @@ fn test_merge_simplify_only() { /// result is a 3-way conflict. #[test] fn test_merge_simplify_result() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // The conflict in path1 cannot be resolved, but the conflict in path2 can. diff --git a/lib/tests/test_mut_repo.rs b/lib/tests/test_mut_repo.rs index d5706a120e..cd22455eed 100644 --- a/lib/tests/test_mut_repo.rs +++ b/lib/tests/test_mut_repo.rs @@ -18,14 +18,15 @@ use maplit::hashset; use test_case::test_case; use testutils::{ assert_rebased, create_random_commit, write_random_commit, CommitGraphBuilder, TestRepo, + TestRepoBackend, }; -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_edit(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_edit(backend: TestRepoBackend) { // Test that MutableRepo::edit() uses the requested commit (not a new child) let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -39,12 +40,12 @@ fn test_edit(use_git: bool) { assert_eq!(repo.view().get_wc_commit_id(&ws_id), Some(wc_commit.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_checkout(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_checkout(backend: TestRepoBackend) { // Test that MutableRepo::check_out() creates a child let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -64,13 +65,13 @@ fn test_checkout(use_git: bool) { assert_eq!(repo.view().get_wc_commit_id(&ws_id), Some(wc_commit.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_checkout_previous_not_empty(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_checkout_previous_not_empty(backend: TestRepoBackend) { // Test that MutableRepo::check_out() does not usually abandon the previous // commit. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -88,13 +89,13 @@ fn test_checkout_previous_not_empty(use_git: bool) { assert!(mut_repo.view().heads().contains(old_wc_commit.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_checkout_previous_empty(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_checkout_previous_empty(backend: TestRepoBackend) { // Test that MutableRepo::check_out() abandons the previous commit if it was // empty. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -119,13 +120,13 @@ fn test_checkout_previous_empty(use_git: bool) { assert!(!mut_repo.view().heads().contains(old_wc_commit.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_checkout_previous_empty_with_description(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_checkout_previous_empty_with_description(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -151,13 +152,13 @@ fn test_checkout_previous_empty_with_description(use_git: bool) { assert!(mut_repo.view().heads().contains(old_wc_commit.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_checkout_previous_empty_with_local_branch(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_checkout_previous_empty_with_local_branch(backend: TestRepoBackend) { // Test that MutableRepo::check_out() does not abandon the previous commit if it // is pointed by local branch. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -183,13 +184,13 @@ fn test_checkout_previous_empty_with_local_branch(use_git: bool) { assert!(mut_repo.view().heads().contains(old_wc_commit.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_checkout_previous_empty_non_head(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_checkout_previous_empty_non_head(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -225,13 +226,13 @@ fn test_checkout_previous_empty_non_head(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_edit_initial(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_edit_initial(backend: TestRepoBackend) { // Test that MutableRepo::edit() can be used on the initial working-copy commit // in a workspace let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -250,13 +251,13 @@ fn test_edit_initial(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_add_head_success(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_add_head_success(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Create a commit outside of the repo by using a temporary transaction. Then @@ -277,13 +278,13 @@ fn test_add_head_success(use_git: bool) { assert!(repo.index().has_id(new_commit.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_add_head_ancestor(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_add_head_ancestor(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -300,13 +301,13 @@ fn test_add_head_ancestor(use_git: bool) { assert_eq!(repo.view().heads(), &hashset! {commit3.id().clone()}); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_add_head_not_immediate_child(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_add_head_not_immediate_child(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -340,14 +341,14 @@ fn test_add_head_not_immediate_child(use_git: bool) { assert!(mut_repo.index().has_id(child.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_remove_head(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_remove_head(backend: TestRepoBackend) { // Test that MutableRepo::remove_head() removes the head, and that it's still // removed after commit. It should remain in the index, since we otherwise would // have to reindex everything. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -378,13 +379,13 @@ fn test_remove_head(use_git: bool) { assert!(repo.index().has_id(commit3.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_add_public_head(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_add_public_head(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -400,13 +401,13 @@ fn test_add_public_head(use_git: bool) { assert!(repo.view().public_heads().contains(commit1.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_add_public_head_ancestor(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_add_public_head_ancestor(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -425,13 +426,13 @@ fn test_add_public_head_ancestor(use_git: bool) { assert!(!repo.view().public_heads().contains(commit1.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_remove_public_head(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_remove_public_head(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -449,14 +450,14 @@ fn test_remove_public_head(use_git: bool) { assert!(!repo.view().public_heads().contains(commit1.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_has_changed(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_has_changed(backend: TestRepoBackend) { // Test that MutableRepo::has_changed() reports changes iff the view has changed // (e.g. not after setting a branch to point to where it was already // pointing). let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -527,14 +528,14 @@ fn test_has_changed(use_git: bool) { assert!(!mut_repo.has_changes()); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_simple(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_simple(backend: TestRepoBackend) { // Tests that MutableRepo::create_descendant_rebaser() creates a // DescendantRebaser that rebases descendants of rewritten and abandoned // commits. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -566,13 +567,13 @@ fn test_rebase_descendants_simple(use_git: bool) { .is_none()); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_conflicting_rewrite(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_conflicting_rewrite(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -601,11 +602,11 @@ fn test_rebase_descendants_conflicting_rewrite(use_git: bool) { .is_none()); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rename_remote(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rename_remote(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); let mut_repo = tx.mut_repo(); diff --git a/lib/tests/test_operations.rs b/lib/tests/test_operations.rs index cc5fb7d2a0..79a2623f5b 100644 --- a/lib/tests/test_operations.rs +++ b/lib/tests/test_operations.rs @@ -17,7 +17,7 @@ use std::path::Path; use jj_lib::backend::{CommitId, ObjectId}; use jj_lib::repo::Repo; use test_case::test_case; -use testutils::{create_random_commit, write_random_commit, TestRepo}; +use testutils::{create_random_commit, write_random_commit, TestRepo, TestRepoBackend}; fn list_dir(dir: &Path) -> Vec { std::fs::read_dir(dir) @@ -26,12 +26,12 @@ fn list_dir(dir: &Path) -> Vec { .collect() } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_unpublished_operation(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_unpublished_operation(backend: TestRepoBackend) { // Test that the operation doesn't get published until that's requested. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let op_heads_dir = repo.repo_path().join("op_heads").join("heads"); @@ -48,13 +48,13 @@ fn test_unpublished_operation(use_git: bool) { assert_eq!(list_dir(&op_heads_dir), vec![op_id1.hex()]); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_consecutive_operations(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_consecutive_operations(backend: TestRepoBackend) { // Test that consecutive operations result in a single op-head on disk after // each operation let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let op_heads_dir = repo.repo_path().join("op_heads").join("heads"); @@ -81,13 +81,13 @@ fn test_consecutive_operations(use_git: bool) { assert_eq!(list_dir(&op_heads_dir), vec![op_id2.hex()]); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_concurrent_operations(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_concurrent_operations(backend: TestRepoBackend) { // 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 = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let op_heads_dir = repo.repo_path().join("op_heads").join("heads"); @@ -127,12 +127,12 @@ fn assert_heads(repo: &dyn Repo, expected: Vec<&CommitId>) { assert_eq!(*repo.view().heads(), expected); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_isolation(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_isolation(backend: TestRepoBackend) { // Test that two concurrent transactions don't see each other's changes. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); diff --git a/lib/tests/test_refs.rs b/lib/tests/test_refs.rs index 3f787d6a94..c9798f6f3c 100644 --- a/lib/tests/test_refs.rs +++ b/lib/tests/test_refs.rs @@ -16,12 +16,12 @@ use jj_lib::merge::Merge; use jj_lib::op_store::RefTarget; use jj_lib::refs::merge_ref_targets; use jj_lib::repo::Repo; -use testutils::{CommitGraphBuilder, TestWorkspace}; +use testutils::{CommitGraphBuilder, TestRepoBackend, TestWorkspace}; #[test] fn test_merge_ref_targets() { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, false); + let test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local); let repo = &test_workspace.repo; // 6 7 diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index c53cd8499e..b6434e486b 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -40,7 +40,7 @@ use jj_lib::workspace::Workspace; use test_case::test_case; use testutils::{ create_random_commit, create_tree, write_random_commit, CommitGraphBuilder, TestRepo, - TestWorkspace, + TestRepoBackend, TestWorkspace, }; fn resolve_symbol(repo: &dyn Repo, symbol: &str) -> Result, RevsetResolutionError> { @@ -72,7 +72,7 @@ fn revset_for_commits<'index>( #[test] fn test_resolve_symbol_empty_string() { - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; assert_matches!( @@ -85,7 +85,7 @@ fn test_resolve_symbol_empty_string() { 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 = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -193,7 +193,7 @@ fn test_resolve_symbol_change_id(readonly: bool) { let settings = testutils::user_settings(); let git_settings = GitSettings::default(); // Test only with git so we can get predictable change ids - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let git_repo = repo @@ -332,11 +332,11 @@ fn test_resolve_symbol_change_id(readonly: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_resolve_working_copy(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_resolve_working_copy(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -380,7 +380,7 @@ fn test_resolve_working_copy(use_git: bool) { #[test] fn test_resolve_symbol_branches() { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -592,7 +592,7 @@ fn test_resolve_symbol_branches() { #[test] fn test_resolve_symbol_tags() { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -640,7 +640,7 @@ fn test_resolve_symbol_tags() { #[test] fn test_resolve_symbol_git_head() { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -684,7 +684,7 @@ fn test_resolve_symbol_git_head() { #[test] fn test_resolve_symbol_git_refs() { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -816,11 +816,11 @@ fn resolve_commit_ids_in_workspace( expression.evaluate(repo).unwrap().iter().collect() } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_root_and_checkout(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_root_and_checkout(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -845,11 +845,11 @@ fn test_evaluate_expression_root_and_checkout(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_heads(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_heads(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); @@ -911,11 +911,11 @@ fn test_evaluate_expression_heads(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_roots(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_roots(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); @@ -967,11 +967,11 @@ fn test_evaluate_expression_roots(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_parents(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_parents(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let root_commit = repo.store().root_commit(); @@ -1050,11 +1050,11 @@ fn test_evaluate_expression_parents(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_children(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_children(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1137,11 +1137,11 @@ fn test_evaluate_expression_children(use_git: bool) { assert_eq!(resolve_commit_ids(mut_repo, "none()+"), vec![]); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_ancestors(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_ancestors(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); @@ -1225,11 +1225,11 @@ fn test_evaluate_expression_ancestors(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_range(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_range(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1307,11 +1307,11 @@ fn test_evaluate_expression_range(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_dag_range(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_dag_range(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let root_commit_id = repo.store().root_commit_id().clone(); @@ -1418,11 +1418,11 @@ fn test_evaluate_expression_dag_range(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_connected(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_connected(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let root_commit_id = repo.store().root_commit_id().clone(); @@ -1495,11 +1495,11 @@ fn test_evaluate_expression_connected(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_descendants(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_descendants(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1597,21 +1597,21 @@ fn test_evaluate_expression_descendants(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_none(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_none(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // none() is empty (doesn't include the checkout, for example) assert_eq!(resolve_commit_ids(repo.as_ref(), "none()"), vec![]); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_all(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_all(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1635,11 +1635,11 @@ fn test_evaluate_expression_all(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_visible_heads(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_visible_heads(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1655,11 +1655,11 @@ fn test_evaluate_expression_visible_heads(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_git_refs(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_git_refs(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1715,11 +1715,11 @@ fn test_evaluate_expression_git_refs(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_git_head(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_git_head(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1736,11 +1736,11 @@ fn test_evaluate_expression_git_head(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_branches(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_branches(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1812,11 +1812,11 @@ fn test_evaluate_expression_branches(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_remote_branches(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_remote_branches(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -1941,11 +1941,11 @@ fn test_evaluate_expression_remote_branches(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_latest(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_latest(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2025,11 +2025,11 @@ fn test_evaluate_expression_latest(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_merges(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_merges(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2053,11 +2053,11 @@ fn test_evaluate_expression_merges(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_description(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_description(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2099,11 +2099,11 @@ fn test_evaluate_expression_description(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_author(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_author(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2173,11 +2173,11 @@ fn test_evaluate_expression_author(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_mine(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_mine(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2242,11 +2242,11 @@ fn test_evaluate_expression_mine(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_committer(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_committer(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2308,11 +2308,11 @@ fn test_evaluate_expression_committer(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_union(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_union(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); @@ -2381,11 +2381,11 @@ fn test_evaluate_expression_union(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_intersection(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_intersection(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); @@ -2421,11 +2421,11 @@ fn test_evaluate_expression_intersection(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_difference(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_difference(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let root_commit = repo.store().root_commit(); @@ -2508,11 +2508,11 @@ fn test_evaluate_expression_difference(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_filter_combinator(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_filter_combinator(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2572,11 +2572,11 @@ fn test_evaluate_expression_filter_combinator(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_file(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_file(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2683,11 +2683,11 @@ fn test_evaluate_expression_file(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_conflict(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_evaluate_expression_conflict(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2722,7 +2722,7 @@ fn test_evaluate_expression_conflict(use_git: bool) { #[test] fn test_reverse_graph_iterator() { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; // Tests that merges, forks, direct edges, indirect edges, and "missing" edges @@ -2787,7 +2787,7 @@ fn test_reverse_graph_iterator() { #[test] fn test_change_id_index() { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -2893,7 +2893,7 @@ fn test_change_id_index() { #[test] fn test_no_such_revision_suggestion() { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(true); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); diff --git a/lib/tests/test_rewrite.rs b/lib/tests/test_rewrite.rs index 14218412da..16d8a1bb76 100644 --- a/lib/tests/test_rewrite.rs +++ b/lib/tests/test_rewrite.rs @@ -21,14 +21,14 @@ use maplit::{hashmap, hashset}; use test_case::test_case; use testutils::{ assert_rebased, create_random_commit, create_tree, write_random_commit, CommitGraphBuilder, - TestRepo, + TestRepo, TestRepoBackend, }; -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_sideways(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_sideways(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit F. Commits C-E should be rebased. @@ -72,11 +72,11 @@ fn test_rebase_descendants_sideways(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_forward(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_forward(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit F. Commits C and E should be rebased onto F. @@ -132,11 +132,11 @@ fn test_rebase_descendants_forward(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_reorder(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_reorder(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit E was replaced by commit D, and commit C was replaced by commit F @@ -184,11 +184,11 @@ fn test_rebase_descendants_reorder(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_backward(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_backward(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit C was replaced by commit B. Commit D should be rebased. @@ -222,11 +222,11 @@ fn test_rebase_descendants_backward(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_chain_becomes_branchy(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_chain_becomes_branchy(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit E and commit C was replaced by commit F. @@ -270,11 +270,11 @@ fn test_rebase_descendants_chain_becomes_branchy(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_internal_merge(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_internal_merge(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit F. Commits C-E should be rebased. @@ -320,11 +320,11 @@ fn test_rebase_descendants_internal_merge(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_external_merge(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_external_merge(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit C was replaced by commit F. Commits E should be rebased. The rebased @@ -369,11 +369,11 @@ fn test_rebase_descendants_external_merge(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_abandon(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_abandon(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B and commit E were abandoned. Commit C and commit D should get @@ -415,11 +415,11 @@ fn test_rebase_descendants_abandon(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_abandon_no_descendants(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_abandon_no_descendants(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B and C were abandoned. Commit A should become a head. @@ -450,11 +450,11 @@ fn test_rebase_descendants_abandon_no_descendants(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_abandon_and_replace(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_abandon_and_replace(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit E. Commit C was abandoned. Commit D should @@ -489,11 +489,11 @@ fn test_rebase_descendants_abandon_and_replace(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_abandon_degenerate_merge(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_abandon_degenerate_merge(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was abandoned. Commit D should get rebased to have only C as parent @@ -527,11 +527,11 @@ fn test_rebase_descendants_abandon_degenerate_merge(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_abandon_widen_merge(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_abandon_widen_merge(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit E was abandoned. Commit F should get rebased to have B, C, and D as @@ -573,11 +573,11 @@ fn test_rebase_descendants_abandon_widen_merge(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_multiple_sideways(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_multiple_sideways(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B and commit D were both replaced by commit F. Commit C and commit E @@ -620,11 +620,11 @@ fn test_rebase_descendants_multiple_sideways(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_multiple_swap(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_multiple_swap(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit D. Commit D was replaced by commit B. @@ -665,11 +665,11 @@ fn test_rebase_descendants_multiple_swap(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_multiple_no_descendants(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_multiple_no_descendants(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit C. Commit C was replaced by commit B. @@ -704,11 +704,11 @@ fn test_rebase_descendants_multiple_no_descendants(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_divergent_rewrite(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_divergent_rewrite(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit B2. Commit D was replaced by commits D2 and @@ -772,11 +772,11 @@ fn test_rebase_descendants_divergent_rewrite(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_repeated(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_repeated(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit B2. Commit C should get rebased. Rebasing @@ -840,11 +840,11 @@ fn test_rebase_descendants_repeated(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_contents(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_contents(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Commit B was replaced by commit D. Commit C should have the changes from @@ -917,7 +917,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Branch "main" points to commit B. B gets rewritten as B2. Branch main should @@ -955,7 +955,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Branch "main" points to branch C. C gets rewritten as C2 and B gets rewritten @@ -1004,7 +1004,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Branch "main" points to commit B. B gets rewritten as B2. Branch main should @@ -1062,7 +1062,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Branch "main" points to commit B. B is then abandoned. Branch main should @@ -1096,7 +1096,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Branch "main" points to commit B. B gets rewritten as B2, B3, B4. Branch main @@ -1165,7 +1165,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Branch "main" is a conflict removing commit A and adding commits B and C. @@ -1242,7 +1242,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Branch "main" is a conflict removing ancestor commit A and adding commit B @@ -1288,7 +1288,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Branch "main" initially points to commit A. One operation rewrites it to @@ -1312,11 +1312,11 @@ fn test_rebase_descendants_branch_delete_modify_abandon() { assert_eq!(tx.mut_repo().get_local_branch("main"), RefTarget::absent()); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_update_checkout(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_update_checkout(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Checked-out commit B was replaced by commit C. C should become @@ -1362,11 +1362,11 @@ fn test_rebase_descendants_update_checkout(use_git: bool) { assert_eq!(repo.view().get_wc_commit_id(&ws3_id), Some(commit_a.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_update_checkout_abandoned(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_update_checkout_abandoned(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Checked-out commit B was abandoned. A child of A @@ -1414,11 +1414,11 @@ fn test_rebase_descendants_update_checkout_abandoned(use_git: bool) { assert_eq!(repo.view().get_wc_commit_id(&ws3_id), Some(commit_a.id())); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_rebase_descendants_update_checkout_abandoned_merge(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_rebase_descendants_update_checkout_abandoned_merge(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; // Checked-out merge commit D was abandoned. A parent commit should become diff --git a/lib/tests/test_view.rs b/lib/tests/test_view.rs index 6d1c2039a2..0272a8ac30 100644 --- a/lib/tests/test_view.rs +++ b/lib/tests/test_view.rs @@ -18,12 +18,13 @@ use maplit::{btreemap, hashset}; use test_case::test_case; use testutils::{ commit_transactions, create_random_commit, write_random_commit, CommitGraphBuilder, TestRepo, + TestRepoBackend, }; -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_heads_empty(use_git: bool) { - let test_repo = TestRepo::init(use_git); +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_heads_empty(backend: TestRepoBackend) { + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; assert_eq!( @@ -36,11 +37,11 @@ fn test_heads_empty(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_heads_fork(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_heads_fork(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -59,11 +60,11 @@ fn test_heads_fork(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_heads_merge(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_heads_merge(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); + let test_repo = TestRepo::init_with_backend(backend); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -81,7 +82,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -139,7 +140,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; // Workspace 1 gets updated in both transactions. @@ -230,7 +231,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -321,7 +322,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -365,7 +366,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; let mut tx = repo.start_transaction(&settings, "test"); @@ -421,7 +422,7 @@ fn test_merge_views_git_heads() { // Tests merging of git heads (by performing concurrent operations). See // test_refs.rs for tests of merging of individual ref targets. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let repo = &test_repo.repo; let mut tx0 = repo.start_transaction(&settings, "test"); @@ -453,7 +454,7 @@ fn test_merge_views_divergent() { // We start with just commit A. Operation 1 rewrites it as A2. Operation 2 // rewrites it as A3. let settings = testutils::user_settings(); - let test_repo = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let mut tx = test_repo.repo.start_transaction(&settings, "test"); let commit_a = write_random_commit(tx.mut_repo(), &settings); @@ -492,7 +493,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let mut tx = test_repo.repo.start_transaction(&settings, "test"); let commit_a = write_random_commit(tx.mut_repo(), &settings); @@ -538,7 +539,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let mut tx = test_repo.repo.start_transaction(&settings, "test"); let commit_a2 = write_random_commit(tx.mut_repo(), &settings); @@ -594,7 +595,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 = TestRepo::init(false); + let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local); let mut tx = test_repo.repo.start_transaction(&settings, "test"); let commit_a = write_random_commit(tx.mut_repo(), &settings); diff --git a/lib/tests/test_working_copy.rs b/lib/tests/test_working_copy.rs index f207c4dab4..c7b595ee02 100644 --- a/lib/tests/test_working_copy.rs +++ b/lib/tests/test_working_copy.rs @@ -35,14 +35,14 @@ use jj_lib::repo_path::{RepoPath, RepoPathComponent, RepoPathJoin}; use jj_lib::settings::UserSettings; use jj_lib::working_copy::{LockedWorkingCopy, SnapshotError, SnapshotOptions, WorkingCopy}; use test_case::test_case; -use testutils::{create_tree, write_random_commit, TestWorkspace}; +use testutils::{create_tree, write_random_commit, TestRepoBackend, TestWorkspace}; -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_root(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_root(backend: TestRepoBackend) { // Test that the working copy is clean and empty after init. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let wc = test_workspace.workspace.working_copy(); assert_eq!(wc.sparse_patterns().unwrap(), vec![RepoPath::root()]); @@ -57,15 +57,15 @@ fn test_root(use_git: bool) { assert_eq!(new_tree.id(), repo.store().empty_merged_tree_id()); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_checkout_file_transitions(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_checkout_file_transitions(backend: TestRepoBackend) { // Tests switching between commits where a certain path is of one type in one // commit and another type in the other. Includes a "missing" type, so we cover // additions and removals as well. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let store = repo.store().clone(); let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -170,7 +170,7 @@ fn test_checkout_file_transitions(use_git: bool) { ]; #[cfg(unix)] kinds.push(Kind::Symlink); - if use_git { + if backend == TestRepoBackend::Git { kinds.push(Kind::GitSubmodule); } let mut left_tree_builder = MergedTreeBuilder::new(store.empty_merged_tree_id()); @@ -264,7 +264,7 @@ fn test_checkout_file_transitions(use_git: bool) { #[test] fn test_conflict_subdirectory() { let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, true); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); let repo = &test_workspace.repo; let path = RepoPath::from_internal_string("sub/file"); @@ -279,11 +279,11 @@ fn test_conflict_subdirectory() { .unwrap(); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_tree_builder_file_directory_transition(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_tree_builder_file_directory_transition(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let store = repo.store(); let mut workspace = test_workspace.workspace; @@ -328,7 +328,7 @@ fn test_tree_builder_file_directory_transition(use_git: bool) { #[test] fn test_reset() { let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, false); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local); let repo = &test_workspace.repo; let op_id = repo.op_id().clone(); let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -379,7 +379,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 = TestWorkspace::init(&settings, false); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local); let repo = test_workspace.repo.clone(); let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -419,13 +419,13 @@ fn test_checkout_discard() { assert!(!reloaded_wc.file_states().unwrap().contains_key(&file2_path)); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_snapshot_racy_timestamps(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_snapshot_racy_timestamps(backend: TestRepoBackend) { // Tests that file modifications are detected even if they happen the same // millisecond as the updated working copy state. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -458,7 +458,7 @@ fn test_snapshot_special_file() { // Tests that we ignore when special files (such as sockets and pipes) exist on // disk. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, false); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local); let workspace_root = test_workspace.workspace.workspace_root().clone(); let store = test_workspace.repo.store(); @@ -508,13 +508,13 @@ fn test_snapshot_special_file() { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_gitignores(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_gitignores(backend: TestRepoBackend) { // Tests that .gitignore files are respected. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let workspace_root = test_workspace.workspace.workspace_root().clone(); let gitignore_path = RepoPath::from_internal_string(".gitignore"); @@ -568,14 +568,14 @@ fn test_gitignores(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_gitignores_in_ignored_dir(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_gitignores_in_ignored_dir(backend: TestRepoBackend) { // Tests that .gitignore files in an ignored directory are ignored, i.e. that // they cannot override the ignores from the parent let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let op_id = test_workspace.repo.op_id().clone(); let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -616,14 +616,14 @@ fn test_gitignores_in_ignored_dir(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_gitignores_checkout_never_overwrites_ignored(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_gitignores_checkout_never_overwrites_ignored(backend: TestRepoBackend) { // Tests that a .gitignore'd file doesn't get overwritten if check out a commit // where the file is tracked. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -648,14 +648,14 @@ fn test_gitignores_checkout_never_overwrites_ignored(use_git: bool) { assert_eq!(std::fs::read(&path).unwrap(), b"garbage"); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_gitignores_ignored_directory_already_tracked(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_gitignores_ignored_directory_already_tracked(backend: TestRepoBackend) { // Tests that a .gitignore'd directory that already has a tracked file in it // does not get removed when snapshotting the working directory. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let workspace_root = test_workspace.workspace.workspace_root().clone(); let repo = test_workspace.repo.clone(); @@ -697,14 +697,14 @@ fn test_gitignores_ignored_directory_already_tracked(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_dotgit_ignored(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_dotgit_ignored(backend: TestRepoBackend) { // Tests that .git directories and files are always ignored (we could accept // them if the backend is not git). let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let store = test_workspace.repo.store().clone(); let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -737,7 +737,7 @@ fn test_gitsubmodule() { // Tests that git submodules are ignored. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, true); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); let repo = &test_workspace.repo; let store = repo.store().clone(); let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -792,11 +792,11 @@ fn test_gitsubmodule() { } #[cfg(unix)] -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_existing_directory_symlink(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +#[test_case(TestRepoBackend::Git ; "git backend")] +fn test_existing_directory_symlink(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, use_git); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, backend); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -817,7 +817,7 @@ fn test_existing_directory_symlink(use_git: bool) { #[test] fn test_fsmonitor() { let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, true); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -918,7 +918,7 @@ fn test_snapshot_max_new_file_size() { .build() .unwrap(), ); - let mut test_workspace = TestWorkspace::init(&settings, true); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); let workspace_root = test_workspace.workspace.workspace_root().clone(); let small_path = RepoPath::from_internal_string("small"); let large_path = RepoPath::from_internal_string("large"); diff --git a/lib/tests/test_working_copy_concurrent.rs b/lib/tests/test_working_copy_concurrent.rs index be0d84acd6..0600d030e4 100644 --- a/lib/tests/test_working_copy_concurrent.rs +++ b/lib/tests/test_working_copy_concurrent.rs @@ -20,14 +20,14 @@ use jj_lib::repo::{Repo, StoreFactories}; use jj_lib::repo_path::RepoPath; use jj_lib::working_copy::{CheckoutError, SnapshotOptions}; use jj_lib::workspace::Workspace; -use testutils::{create_tree, write_working_copy_file, TestWorkspace}; +use testutils::{create_tree, write_working_copy_file, TestRepoBackend, TestWorkspace}; #[test] fn test_concurrent_checkout() { // Test that we error out if a concurrent checkout is detected (i.e. if the // working-copy commit changed on disk after we read it). let settings = testutils::user_settings(); - let mut test_workspace1 = TestWorkspace::init(&settings, true); + let mut test_workspace1 = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); let repo1 = test_workspace1.repo.clone(); let workspace1_root = test_workspace1.workspace.workspace_root().clone(); @@ -72,7 +72,7 @@ fn test_checkout_parallel() { // Test that concurrent checkouts by different processes (simulated by using // different repo instances) is safe. let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, true); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().clone(); @@ -137,7 +137,7 @@ fn test_checkout_parallel() { #[test] fn test_racy_checkout() { let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, true); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); let repo = &test_workspace.repo; let op_id = repo.op_id().clone(); let workspace_root = test_workspace.workspace.workspace_root().clone(); diff --git a/lib/tests/test_working_copy_sparse.rs b/lib/tests/test_working_copy_sparse.rs index 99903cd536..0a0f8a83ff 100644 --- a/lib/tests/test_working_copy_sparse.rs +++ b/lib/tests/test_working_copy_sparse.rs @@ -17,12 +17,12 @@ use jj_lib::matchers::EverythingMatcher; use jj_lib::repo::Repo; use jj_lib::repo_path::RepoPath; use jj_lib::working_copy::{CheckoutStats, WorkingCopy}; -use testutils::{create_tree, TestWorkspace}; +use testutils::{create_tree, TestRepoBackend, TestWorkspace}; #[test] fn test_sparse_checkout() { let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, false); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local); let repo = &test_workspace.repo; let working_copy_path = test_workspace.workspace.workspace_root().clone(); @@ -129,7 +129,7 @@ fn test_sparse_checkout() { #[test] fn test_sparse_commit() { let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings, false); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local); let repo = &test_workspace.repo; let op_id = repo.op_id().clone(); let working_copy_path = test_workspace.workspace.workspace_root().clone(); @@ -192,7 +192,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 = TestWorkspace::init(&settings, false); + let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local); let repo = &test_workspace.repo; let working_copy_path = test_workspace.workspace.workspace_root().clone(); diff --git a/lib/tests/test_workspace.rs b/lib/tests/test_workspace.rs index 2e9806f20a..5296b621df 100644 --- a/lib/tests/test_workspace.rs +++ b/lib/tests/test_workspace.rs @@ -17,7 +17,7 @@ use jj_lib::op_store::WorkspaceId; use jj_lib::repo::{Repo, StoreFactories}; use jj_lib::workspace::{Workspace, WorkspaceLoadError}; use test_case::test_case; -use testutils::TestWorkspace; +use testutils::{TestRepoBackend, TestWorkspace}; #[test] fn test_load_bad_path() { @@ -32,11 +32,11 @@ fn test_load_bad_path() { ); } -#[test_case(false ; "local backend")] -// #[test_case(true ; "git backend")] -fn test_init_additional_workspace(use_git: bool) { +#[test_case(TestRepoBackend::Local ; "local backend")] +// #[test_case(TestRepoBackend::Git ; "git backend")] +fn test_init_additional_workspace(backend: TestRepoBackend) { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings, use_git); + let test_workspace = TestWorkspace::init_with_backend(&settings, backend); let workspace = &test_workspace.workspace; let ws2_id = WorkspaceId::new("ws2".to_string()); diff --git a/lib/testutils/src/lib.rs b/lib/testutils/src/lib.rs index 44cfa77197..a9e4d0b579 100644 --- a/lib/testutils/src/lib.rs +++ b/lib/testutils/src/lib.rs @@ -100,15 +100,6 @@ impl TestRepoBackend { } impl TestRepo { - pub fn init(use_git: bool) -> Self { - let backend = if use_git { - TestRepoBackend::Git - } else { - TestRepoBackend::Local - }; - Self::init_with_backend(backend) - } - pub fn init_with_backend(backend: TestRepoBackend) -> Self { let settings = user_settings(); let temp_dir = new_temp_dir(); @@ -144,15 +135,6 @@ pub struct TestWorkspace { } impl TestWorkspace { - pub fn init(settings: &UserSettings, use_git: bool) -> Self { - let backend = if use_git { - TestRepoBackend::Git - } else { - TestRepoBackend::Local - }; - Self::init_with_backend(settings, backend) - } - pub fn init_with_backend(settings: &UserSettings, backend: TestRepoBackend) -> Self { let temp_dir = new_temp_dir();