forked from mirrors/jj
tests: wherever we test with only one backend, use the test backend
I don't think there's any reason to use the local backend in tests instead of using the stricter test backend. I think we should generally use the test backend in tests and only use the local backend or git backend when there's a particular reason to do so (such as in `test_bad_locking` where the on-disk directory structure matters). But this patch only deals with the simpler cases where we were only testing with the local backend.
This commit is contained in:
parent
aa3dfaa859
commit
0f7054e8c3
8 changed files with 45 additions and 37 deletions
|
@ -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, TestRepoBackend};
|
||||
use testutils::TestRepo;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_edit_diff_builtin() {
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let store = test_repo.repo.store();
|
||||
|
||||
let path = RepoPath::from_internal_string("file");
|
||||
|
|
|
@ -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, TestRepoBackend};
|
||||
use testutils::TestRepo;
|
||||
|
||||
#[test]
|
||||
fn test_materialize_conflict_basic() {
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let store = test_repo.repo.store();
|
||||
|
||||
let path = RepoPath::from_internal_string("dir/file");
|
||||
|
|
|
@ -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, TestRepoBackend, TestWorkspace};
|
||||
use testutils::{CommitGraphBuilder, TestWorkspace};
|
||||
|
||||
#[test]
|
||||
fn test_merge_ref_targets() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local);
|
||||
let test_workspace = TestWorkspace::init(&settings);
|
||||
let repo = &test_workspace.repo;
|
||||
|
||||
// 6 7
|
||||
|
|
|
@ -917,7 +917,7 @@ fn test_rebase_descendants_contents(backend: TestRepoBackend) {
|
|||
#[test]
|
||||
fn test_rebase_descendants_basic_branch_update() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Branch "main" initially points to commit A. One operation rewrites it to
|
||||
|
|
|
@ -82,7 +82,7 @@ fn test_heads_merge(backend: TestRepoBackend) {
|
|||
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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction(&settings, "test");
|
||||
|
@ -140,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// Workspace 1 gets updated in both transactions.
|
||||
|
@ -231,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction(&settings, "test");
|
||||
|
@ -322,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction(&settings, "test");
|
||||
|
@ -366,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction(&settings, "test");
|
||||
|
@ -422,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx0 = repo.start_transaction(&settings, "test");
|
||||
|
@ -454,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction(&settings, "test");
|
||||
let commit_a = write_random_commit(tx.mut_repo(), &settings);
|
||||
|
@ -493,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction(&settings, "test");
|
||||
let commit_a = write_random_commit(tx.mut_repo(), &settings);
|
||||
|
@ -539,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction(&settings, "test");
|
||||
let commit_a2 = write_random_commit(tx.mut_repo(), &settings);
|
||||
|
@ -595,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_with_backend(TestRepoBackend::Local);
|
||||
let test_repo = TestRepo::init();
|
||||
|
||||
let mut tx = test_repo.repo.start_transaction(&settings, "test");
|
||||
let commit_a = write_random_commit(tx.mut_repo(), &settings);
|
||||
|
|
|
@ -328,7 +328,7 @@ fn test_tree_builder_file_directory_transition(backend: TestRepoBackend) {
|
|||
#[test]
|
||||
fn test_reset() {
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local);
|
||||
let mut test_workspace = TestWorkspace::init(&settings);
|
||||
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_with_backend(&settings, TestRepoBackend::Local);
|
||||
let mut test_workspace = TestWorkspace::init(&settings);
|
||||
let repo = test_workspace.repo.clone();
|
||||
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_with_backend(&settings, TestRepoBackend::Local);
|
||||
let mut test_workspace = TestWorkspace::init(&settings);
|
||||
let workspace_root = test_workspace.workspace.workspace_root().clone();
|
||||
let store = test_workspace.repo.store();
|
||||
|
||||
|
|
|
@ -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, TestRepoBackend, TestWorkspace};
|
||||
use testutils::{create_tree, TestWorkspace};
|
||||
|
||||
#[test]
|
||||
fn test_sparse_checkout() {
|
||||
let settings = testutils::user_settings();
|
||||
let mut test_workspace = TestWorkspace::init_with_backend(&settings, TestRepoBackend::Local);
|
||||
let mut test_workspace = TestWorkspace::init(&settings);
|
||||
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_with_backend(&settings, TestRepoBackend::Local);
|
||||
let mut test_workspace = TestWorkspace::init(&settings);
|
||||
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_with_backend(&settings, TestRepoBackend::Local);
|
||||
let mut test_workspace = TestWorkspace::init(&settings);
|
||||
let repo = &test_workspace.repo;
|
||||
let working_copy_path = test_workspace.workspace.workspace_root().clone();
|
||||
|
||||
|
|
|
@ -106,6 +106,10 @@ impl TestRepoBackend {
|
|||
}
|
||||
|
||||
impl TestRepo {
|
||||
pub fn init() -> Self {
|
||||
Self::init_with_backend(TestRepoBackend::Test)
|
||||
}
|
||||
|
||||
pub fn init_with_backend(backend: TestRepoBackend) -> Self {
|
||||
let settings = user_settings();
|
||||
let temp_dir = new_temp_dir();
|
||||
|
@ -141,6 +145,10 @@ pub struct TestWorkspace {
|
|||
}
|
||||
|
||||
impl TestWorkspace {
|
||||
pub fn init(settings: &UserSettings) -> Self {
|
||||
Self::init_with_backend(settings, TestRepoBackend::Test)
|
||||
}
|
||||
|
||||
pub fn init_with_backend(settings: &UserSettings, backend: TestRepoBackend) -> Self {
|
||||
let temp_dir = new_temp_dir();
|
||||
|
||||
|
|
Loading…
Reference in a new issue