diff --git a/cli/tests/test_root.rs b/cli/tests/test_root.rs index a84c3b677e..396b65f581 100644 --- a/cli/tests/test_root.rs +++ b/cli/tests/test_root.rs @@ -24,8 +24,7 @@ use crate::common::TestEnvironment; #[test_case(TestRepoBackend::Git ; "git backend")] fn test_root(backend: TestRepoBackend) { let test_env = TestEnvironment::default(); - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init_with_backend(&settings, backend); + let test_workspace = TestWorkspace::init_with_backend(backend); let root = test_workspace.workspace.workspace_root(); let subdir = root.join("subdir"); std::fs::create_dir(&subdir).unwrap(); diff --git a/lib/tests/test_bad_locking.rs b/lib/tests/test_bad_locking.rs index e957926f72..9d50dcb199 100644 --- a/lib/tests/test_bad_locking.rs +++ b/lib/tests/test_bad_locking.rs @@ -105,7 +105,7 @@ 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_with_backend(&settings, backend); + let test_workspace = TestWorkspace::init_with_backend_and_settings(backend, &settings); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root(); @@ -178,7 +178,7 @@ fn test_bad_locking_interrupted(backend: TestRepoBackend) { // that's a descendant of the other is resolved without creating a new // operation. let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init_with_backend(&settings, backend); + let test_workspace = TestWorkspace::init_with_backend_and_settings(backend, &settings); let test_env = &test_workspace.env; let repo = &test_workspace.repo; diff --git a/lib/tests/test_commit_concurrent.rs b/lib/tests/test_commit_concurrent.rs index b6094e3399..413fb59b72 100644 --- a/lib/tests/test_commit_concurrent.rs +++ b/lib/tests/test_commit_concurrent.rs @@ -47,8 +47,7 @@ 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_with_backend(&settings, backend); + let test_workspace = TestWorkspace::init_with_backend(backend); let repo = &test_workspace.repo; let num_threads = max(num_cpus::get(), 4); @@ -78,7 +77,7 @@ 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_with_backend(&settings, backend); + let test_workspace = TestWorkspace::init_with_backend_and_settings(backend, &settings); let test_env = &test_workspace.env; let num_threads = max(num_cpus::get(), 4); diff --git a/lib/tests/test_init.rs b/lib/tests/test_init.rs index 8845b540f1..d3b428801d 100644 --- a/lib/tests/test_init.rs +++ b/lib/tests/test_init.rs @@ -142,7 +142,7 @@ fn test_init_external_git() { fn test_init_with_default_config(backend: TestRepoBackend) { // Test that we can create a repo without setting any non-default config let settings = UserSettings::from_config(StackedConfig::with_defaults()).unwrap(); - let test_workspace = TestWorkspace::init_with_backend(&settings, backend); + let test_workspace = TestWorkspace::init_with_backend_and_settings(backend, &settings); let repo = &test_workspace.repo; let wc_commit_id = repo .view() @@ -160,7 +160,7 @@ fn test_init_with_default_config(backend: TestRepoBackend) { 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_with_backend(&settings, backend); + let test_workspace = TestWorkspace::init_with_backend_and_settings(backend, &settings); let repo = &test_workspace.repo; let wc_commit_id = repo .view() diff --git a/lib/tests/test_local_working_copy.rs b/lib/tests/test_local_working_copy.rs index e56501d035..b0483cebbc 100644 --- a/lib/tests/test_local_working_copy.rs +++ b/lib/tests/test_local_working_copy.rs @@ -105,8 +105,7 @@ fn tree_entries(tree: &MergedTree) -> Vec<(RepoPathBuf, Option) #[test] fn test_root() { // Test that the working copy is clean and empty after init. - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let wc = test_workspace.workspace.working_copy(); assert_eq!(wc.sparse_patterns().unwrap(), vec![RepoPathBuf::root()]); @@ -128,8 +127,7 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) { // 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_with_backend(&settings, backend); + let mut test_workspace = TestWorkspace::init_with_backend(backend); let repo = &test_workspace.repo; let store = repo.store().clone(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -374,8 +372,7 @@ fn test_checkout_file_transitions(backend: TestRepoBackend) { // Test case for issue #2165 #[test] fn test_conflict_subdirectory() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let path = RepoPath::from_internal_string("sub/file"); @@ -406,7 +403,8 @@ fn test_conflict_subdirectory() { #[test] fn test_acl() { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); + let test_workspace = + TestWorkspace::init_with_backend_and_settings(TestRepoBackend::Git, &settings); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -497,8 +495,7 @@ fn test_acl() { #[test] fn test_tree_builder_file_directory_transition() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let store = repo.store(); let mut ws = test_workspace.workspace; @@ -547,8 +544,7 @@ fn test_tree_builder_file_directory_transition() { #[test] fn test_conflicting_changes_on_disk() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let mut ws = test_workspace.workspace; let workspace_root = ws.workspace_root().to_owned(); @@ -630,8 +626,7 @@ fn test_conflicting_changes_on_disk() { #[test] fn test_reset() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let op_id = repo.op_id().clone(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -692,8 +687,7 @@ fn test_checkout_discard() { // Start a mutation, do a checkout, and then discard the mutation. The working // 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); + let mut test_workspace = TestWorkspace::init(); let repo = test_workspace.repo.clone(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -750,8 +744,7 @@ fn test_checkout_discard() { #[test] fn test_snapshot_file_directory_transition() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = test_workspace.repo.clone(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); let checkout_options = CheckoutOptions::empty_for_test(); @@ -799,8 +792,7 @@ fn test_snapshot_file_directory_transition() { #[test] fn test_materialize_snapshot_conflicted_files() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo.clone(); let ws = &mut test_workspace.workspace; let workspace_root = ws.workspace_root().to_owned(); @@ -924,8 +916,7 @@ fn test_materialize_snapshot_conflicted_files() { fn test_snapshot_racy_timestamps() { // 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); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -951,8 +942,7 @@ fn test_snapshot_racy_timestamps() { 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); + let mut test_workspace = TestWorkspace::init(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); let store = test_workspace.repo.store(); let ws = &mut test_workspace.workspace; @@ -1009,8 +999,7 @@ fn test_snapshot_special_file() { fn test_gitignores() { // Tests that .gitignore files are respected. - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); let gitignore_path = RepoPath::from_internal_string(".gitignore"); @@ -1069,8 +1058,7 @@ fn test_gitignores_in_ignored_dir() { // 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); + let mut test_workspace = TestWorkspace::init(); let op_id = test_workspace.repo.op_id().clone(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1120,8 +1108,7 @@ fn test_gitignores_checkout_never_overwrites_ignored() { // 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); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1159,8 +1146,7 @@ fn test_gitignores_ignored_directory_already_tracked() { // 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); + let mut test_workspace = TestWorkspace::init(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); let repo = test_workspace.repo.clone(); @@ -1265,8 +1251,7 @@ fn test_dotgit_ignored() { // 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); + let mut test_workspace = TestWorkspace::init(); let store = test_workspace.repo.store().clone(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1298,8 +1283,7 @@ fn test_dotgit_ignored() { fn test_git_submodule() { // Tests that git submodules are ignored. - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Git); + let mut test_workspace = TestWorkspace::init_with_backend(TestRepoBackend::Git); let repo = test_workspace.repo.clone(); let store = repo.store().clone(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1405,8 +1389,7 @@ fn test_git_submodule() { #[test] fn test_check_out_existing_file_cannot_be_removed() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1450,8 +1433,7 @@ fn test_check_out_existing_file_cannot_be_removed() { #[test] fn test_check_out_existing_file_replaced_with_directory() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1493,8 +1475,7 @@ fn test_check_out_existing_directory_symlink() { return; } - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1529,8 +1510,7 @@ fn test_check_out_existing_directory_symlink_icase_fs() { return; } - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); let is_icase_fs = check_icase_fs(&workspace_root); @@ -1571,8 +1551,7 @@ fn test_check_out_existing_file_symlink_icase_fs(victim_exists: bool) { return; } - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); let is_icase_fs = check_icase_fs(&workspace_root); @@ -1625,8 +1604,7 @@ fn test_check_out_file_removal_over_existing_directory_symlink() { return; } - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1674,8 +1652,7 @@ fn test_check_out_file_removal_over_existing_directory_symlink() { #[test_case("../pwned"; "escape from root")] #[test_case("sub/../../pwned"; "escape from sub dir")] fn test_check_out_malformed_file_path(file_path_str: &str) { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1701,8 +1678,7 @@ fn test_check_out_malformed_file_path(file_path_str: &str) { #[test_case(r"sub\..\../pwned"; "path separator")] #[test_case("d:/pwned"; "drive letter")] fn test_check_out_malformed_file_path_windows(file_path_str: &str) { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -1740,8 +1716,7 @@ fn test_check_out_malformed_file_path_windows(file_path_str: &str) { #[test_case("sub/.git/pwned"; "sub .git dir")] #[test_case("sub/.jj/pwned"; "sub .jj dir")] fn test_check_out_reserved_file_path(file_path_str: &str) { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); std::fs::create_dir(workspace_root.join(".git")).unwrap(); @@ -1801,8 +1776,7 @@ fn test_check_out_reserved_file_path(file_path_str: &str) { #[test_case("sub/.gIT/pwned"; "sub .git dir")] #[test_case("sub/.Jj/pwned"; "sub .jj dir")] fn test_check_out_reserved_file_path_icase_fs(file_path_str: &str) { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); std::fs::create_dir(workspace_root.join(".git")).unwrap(); @@ -1873,8 +1847,7 @@ fn test_check_out_reserved_file_path_icase_fs(file_path_str: &str) { #[test_case("sub/.gi\u{200e}t/pwned"; "sub .git dir")] #[test_case("sub/.jj\u{200f}/pwned"; "sub .jj dir")] fn test_check_out_reserved_file_path_hfs_plus(file_path_str: &str) { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); std::fs::create_dir(workspace_root.join(".git")).unwrap(); @@ -1946,8 +1919,7 @@ fn test_check_out_reserved_file_path_hfs_plus(file_path_str: &str) { // - https://en.wikipedia.org/wiki/8.3_filename // - See is_ntfs_dotgit() of Git and pathauditor of Mercurial fn test_check_out_reserved_file_path_vfat(vfat_path_str: &str, file_path_strs: &[&str]) { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); std::fs::create_dir(workspace_root.join(".git")).unwrap(); @@ -2022,8 +1994,7 @@ fn test_check_out_reserved_file_path_vfat(vfat_path_str: &str, file_path_strs: & #[test] fn test_fsmonitor() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -2120,8 +2091,7 @@ fn test_fsmonitor() { #[test] fn test_snapshot_max_new_file_size() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); let small_path = RepoPath::from_internal_string("small"); let large_path = RepoPath::from_internal_string("large"); diff --git a/lib/tests/test_local_working_copy_concurrent.rs b/lib/tests/test_local_working_copy_concurrent.rs index db5713acf4..3110017cf4 100644 --- a/lib/tests/test_local_working_copy_concurrent.rs +++ b/lib/tests/test_local_working_copy_concurrent.rs @@ -34,7 +34,7 @@ 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); + let mut test_workspace1 = TestWorkspace::init_with_settings(&settings); let repo = test_workspace1.repo.clone(); let workspace1_root = test_workspace1.workspace.workspace_root().to_owned(); @@ -108,7 +108,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); + let mut test_workspace = TestWorkspace::init_with_settings(&settings); let repo = &test_workspace.repo; let workspace_root = test_workspace.workspace.workspace_root().to_owned(); @@ -181,8 +181,7 @@ fn test_checkout_parallel() { #[test] fn test_racy_checkout() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let op_id = repo.op_id().clone(); let workspace_root = test_workspace.workspace.workspace_root().to_owned(); diff --git a/lib/tests/test_local_working_copy_sparse.rs b/lib/tests/test_local_working_copy_sparse.rs index 61c93aaa75..1cdce4cf06 100644 --- a/lib/tests/test_local_working_copy_sparse.rs +++ b/lib/tests/test_local_working_copy_sparse.rs @@ -33,8 +33,7 @@ fn to_owned_path_vec(paths: &[&RepoPath]) -> Vec { #[test] fn test_sparse_checkout() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let working_copy_path = test_workspace.workspace.workspace_root().to_owned(); @@ -177,8 +176,7 @@ fn test_sparse_checkout() { /// Test that sparse patterns are respected on commit #[test] fn test_sparse_commit() { - let settings = testutils::user_settings(); - let mut test_workspace = TestWorkspace::init(&settings); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let op_id = repo.op_id().clone(); let working_copy_path = test_workspace.workspace.workspace_root().to_owned(); @@ -277,8 +275,7 @@ fn test_sparse_commit() { #[test] 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); + let mut test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let working_copy_path = test_workspace.workspace.workspace_root().to_owned(); diff --git a/lib/tests/test_refs.rs b/lib/tests/test_refs.rs index 4f37435376..96d0f2c148 100644 --- a/lib/tests/test_refs.rs +++ b/lib/tests/test_refs.rs @@ -21,8 +21,7 @@ use testutils::TestWorkspace; #[test] fn test_merge_ref_targets() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; // 6 7 diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index d30264a089..9cec4eaf75 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -967,8 +967,7 @@ fn resolve_commit_ids_in_workspace( #[test] fn test_evaluate_expression_root_and_checkout() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let root_operation = repo.loader().root_operation(); @@ -1128,8 +1127,7 @@ fn test_evaluate_expression_roots() { #[test] fn test_evaluate_expression_parents() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let root_commit = repo.store().root_commit(); @@ -3526,8 +3524,7 @@ fn test_evaluate_expression_filter_combinator() { #[test] fn test_evaluate_expression_file() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let mut tx = repo.start_transaction(); @@ -3638,8 +3635,7 @@ fn test_evaluate_expression_file() { #[test] fn test_evaluate_expression_diff_contains() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let mut tx = repo.start_transaction(); @@ -3780,8 +3776,7 @@ fn test_evaluate_expression_diff_contains() { #[test] fn test_evaluate_expression_file_merged_parents() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let mut tx = repo.start_transaction(); @@ -3850,8 +3845,7 @@ fn test_evaluate_expression_file_merged_parents() { #[test] fn test_evaluate_expression_conflict() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let repo = &test_workspace.repo; let mut tx = repo.start_transaction(); diff --git a/lib/tests/test_signing.rs b/lib/tests/test_signing.rs index 2591d41f37..95442b493c 100644 --- a/lib/tests/test_signing.rs +++ b/lib/tests/test_signing.rs @@ -58,7 +58,7 @@ fn manual(backend: TestRepoBackend) { let settings = user_settings(true); let signer = Signer::new(Some(Box::new(TestSigningBackend)), vec![]); - let test_workspace = TestWorkspace::init_with_backend_and_signer(&settings, backend, signer); + let test_workspace = TestWorkspace::init_with_backend_and_signer(backend, signer, &settings); let repo = &test_workspace.repo; @@ -87,7 +87,7 @@ fn keep_on_rewrite(backend: TestRepoBackend) { let settings = user_settings(true); let signer = Signer::new(Some(Box::new(TestSigningBackend)), vec![]); - let test_workspace = TestWorkspace::init_with_backend_and_signer(&settings, backend, signer); + let test_workspace = TestWorkspace::init_with_backend_and_signer(backend, signer, &settings); let repo = &test_workspace.repo; @@ -112,7 +112,7 @@ fn manual_drop_on_rewrite(backend: TestRepoBackend) { let settings = user_settings(true); let signer = Signer::new(Some(Box::new(TestSigningBackend)), vec![]); - let test_workspace = TestWorkspace::init_with_backend_and_signer(&settings, backend, signer); + let test_workspace = TestWorkspace::init_with_backend_and_signer(backend, signer, &settings); let repo = &test_workspace.repo; @@ -141,7 +141,7 @@ fn forced(backend: TestRepoBackend) { let settings = user_settings(true); let signer = Signer::new(Some(Box::new(TestSigningBackend)), vec![]); - let test_workspace = TestWorkspace::init_with_backend_and_signer(&settings, backend, signer); + let test_workspace = TestWorkspace::init_with_backend_and_signer(backend, signer, &settings); let repo = &test_workspace.repo; @@ -163,7 +163,7 @@ fn configured(backend: TestRepoBackend) { let settings = user_settings(true); let signer = Signer::new(Some(Box::new(TestSigningBackend)), vec![]); - let test_workspace = TestWorkspace::init_with_backend_and_signer(&settings, backend, signer); + let test_workspace = TestWorkspace::init_with_backend_and_signer(backend, signer, &settings); let repo = &test_workspace.repo; diff --git a/lib/tests/test_workspace.rs b/lib/tests/test_workspace.rs index a8ab278df2..2b83df696d 100644 --- a/lib/tests/test_workspace.rs +++ b/lib/tests/test_workspace.rs @@ -45,7 +45,7 @@ fn test_load_bad_path() { #[test] fn test_init_additional_workspace() { let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init_with_settings(&settings); let workspace = &test_workspace.workspace; let ws2_id = WorkspaceId::new("ws2".to_string()); @@ -95,8 +95,7 @@ fn test_init_additional_workspace() { /// Test cross-thread access to a workspace, which requires it to be Send #[test] fn test_sendable() { - let settings = testutils::user_settings(); - let test_workspace = TestWorkspace::init(&settings); + let test_workspace = TestWorkspace::init(); let root = test_workspace.workspace.workspace_root().to_owned(); thread::spawn(move || { diff --git a/lib/testutils/src/lib.rs b/lib/testutils/src/lib.rs index 2cdf247995..d0ab95701c 100644 --- a/lib/testutils/src/lib.rs +++ b/lib/testutils/src/lib.rs @@ -251,22 +251,30 @@ pub struct TestWorkspace { } impl TestWorkspace { - pub fn init(settings: &UserSettings) -> Self { - Self::init_with_backend(settings, TestRepoBackend::Test) + pub fn init() -> Self { + Self::init_with_backend(TestRepoBackend::Test) } - pub fn init_with_backend(settings: &UserSettings, backend: TestRepoBackend) -> Self { - Self::init_with_backend_and_signer( - settings, - backend, - Signer::from_settings(settings).unwrap(), - ) + pub fn init_with_backend(backend: TestRepoBackend) -> Self { + Self::init_with_backend_and_settings(backend, &user_settings()) } - pub fn init_with_backend_and_signer( + pub fn init_with_settings(settings: &UserSettings) -> Self { + Self::init_with_backend_and_settings(TestRepoBackend::Test, settings) + } + + pub fn init_with_backend_and_settings( + backend: TestRepoBackend, settings: &UserSettings, + ) -> Self { + let signer = Signer::from_settings(settings).unwrap(); + Self::init_with_backend_and_signer(backend, signer, settings) + } + + pub fn init_with_backend_and_signer( backend: TestRepoBackend, signer: Signer, + settings: &UserSettings, ) -> Self { let env = TestEnvironment::init();