forked from mirrors/jj
tests: don't create workspaces in revset tests
This commit is contained in:
parent
8d5587355b
commit
10fbe2cb55
1 changed files with 63 additions and 70 deletions
|
@ -25,8 +25,8 @@ use test_case::test_case;
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_resolve_symbol_root(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
assert_eq!(
|
||||
resolve_symbol(repo.as_repo_ref(), "root", None),
|
||||
|
@ -38,8 +38,8 @@ fn test_resolve_symbol_root(use_git: bool) {
|
|||
fn test_resolve_symbol_commit_id() {
|
||||
let settings = testutils::user_settings();
|
||||
// Test only with git so we can get predictable commit ids
|
||||
let test_workspace = testutils::init_workspace(&settings, true);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -125,8 +125,8 @@ fn test_resolve_symbol_commit_id() {
|
|||
fn test_resolve_symbol_change_id() {
|
||||
let settings = testutils::user_settings();
|
||||
// Test only with git so we can get predictable change ids
|
||||
let test_workspace = testutils::init_workspace(&settings, true);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let git_repo = repo.store().git_repo().unwrap();
|
||||
// Add some commits that will end up having change ids with common prefixes
|
||||
|
@ -239,8 +239,8 @@ fn test_resolve_symbol_change_id() {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_resolve_symbol_checkout(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -289,8 +289,8 @@ fn test_resolve_symbol_checkout(use_git: bool) {
|
|||
#[test]
|
||||
fn test_resolve_symbol_git_refs() {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, true);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, true);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -390,15 +390,13 @@ fn test_resolve_symbol_git_refs() {
|
|||
);
|
||||
|
||||
// Cannot shadow checkout ("@") or root symbols
|
||||
let ws_id = WorkspaceId::default();
|
||||
mut_repo.set_checkout(ws_id.clone(), commit1.id().clone());
|
||||
mut_repo.set_git_ref("@".to_string(), RefTarget::Normal(commit2.id().clone()));
|
||||
mut_repo.set_git_ref("root".to_string(), RefTarget::Normal(commit3.id().clone()));
|
||||
assert_eq!(
|
||||
resolve_symbol(mut_repo.as_repo_ref(), "@", Some(&WorkspaceId::default())),
|
||||
Ok(vec![mut_repo
|
||||
.view()
|
||||
.get_checkout(&WorkspaceId::default())
|
||||
.unwrap()
|
||||
.clone()])
|
||||
resolve_symbol(mut_repo.as_repo_ref(), "@", Some(&ws_id)),
|
||||
Ok(vec![mut_repo.view().get_checkout(&ws_id).unwrap().clone()])
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_symbol(mut_repo.as_repo_ref(), "root", None),
|
||||
|
@ -440,8 +438,8 @@ fn resolve_commit_ids_in_workspace(
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_root_and_checkout(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -467,8 +465,8 @@ fn test_evaluate_expression_root_and_checkout(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_heads_of(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -529,8 +527,8 @@ fn test_evaluate_expression_heads_of(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_parents(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -590,13 +588,12 @@ fn test_evaluate_expression_parents(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_children(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let checkout_id = repo.view().checkout().clone();
|
||||
let commit1 = testutils::create_random_commit(&settings, repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
|
@ -614,7 +611,7 @@ fn test_evaluate_expression_children(use_git: bool) {
|
|||
// Can find children of the root commit
|
||||
assert_eq!(
|
||||
resolve_commit_ids(mut_repo.as_repo_ref(), "root+"),
|
||||
vec![commit1.id().clone(), checkout_id]
|
||||
vec![commit1.id().clone()]
|
||||
);
|
||||
|
||||
// Children of all commits in input are returned, including those already in the
|
||||
|
@ -645,8 +642,8 @@ fn test_evaluate_expression_children(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_ancestors(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -681,8 +678,8 @@ fn test_evaluate_expression_ancestors(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_range(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -744,8 +741,8 @@ fn test_evaluate_expression_range(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_dag_range(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit_id = repo.store().root_commit_id().clone();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -814,14 +811,13 @@ fn test_evaluate_expression_dag_range(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_descendants(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let root_commit_id = repo.store().root_commit_id().clone();
|
||||
let checkout_id = repo.view().checkout().clone();
|
||||
let commit1 = testutils::create_random_commit(&settings, repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
|
@ -845,7 +841,6 @@ fn test_evaluate_expression_descendants(use_git: bool) {
|
|||
commit3.id().clone(),
|
||||
commit2.id().clone(),
|
||||
commit1.id().clone(),
|
||||
checkout_id,
|
||||
root_commit_id,
|
||||
]
|
||||
);
|
||||
|
@ -865,8 +860,8 @@ fn test_evaluate_expression_descendants(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_none(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
// none() is empty (doesn't include the checkout, for example)
|
||||
assert_eq!(resolve_commit_ids(repo.as_repo_ref(), "none()"), vec![]);
|
||||
|
@ -876,13 +871,12 @@ fn test_evaluate_expression_none(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_all(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
let root_commit_id = repo.store().root_commit_id().clone();
|
||||
let checkout_id = repo.view().checkout().clone();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
|
@ -896,7 +890,6 @@ fn test_evaluate_expression_all(use_git: bool) {
|
|||
commit3.id().clone(),
|
||||
commit2.id().clone(),
|
||||
commit1.id().clone(),
|
||||
checkout_id,
|
||||
root_commit_id,
|
||||
]
|
||||
);
|
||||
|
@ -906,19 +899,19 @@ fn test_evaluate_expression_all(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_heads(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
let checkout_id = repo.view().checkout().clone();
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
|
||||
assert_eq!(
|
||||
resolve_commit_ids(mut_repo.as_repo_ref(), "heads()"),
|
||||
vec![commit2.id().clone(), checkout_id]
|
||||
vec![commit3.id().clone(), commit2.id().clone()]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -926,8 +919,8 @@ fn test_evaluate_expression_heads(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_public_heads(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -959,8 +952,8 @@ fn test_evaluate_expression_public_heads(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_git_refs(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -1028,8 +1021,8 @@ fn test_evaluate_expression_git_refs(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_git_head(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -1052,8 +1045,8 @@ fn test_evaluate_expression_git_head(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_branches(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -1121,8 +1114,8 @@ fn test_evaluate_expression_branches(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_remote_branches(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -1201,8 +1194,8 @@ fn test_evaluate_expression_remote_branches(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_merges(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -1232,8 +1225,8 @@ fn test_evaluate_expression_merges(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_description(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -1275,8 +1268,8 @@ fn test_evaluate_expression_description(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_author(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -1338,8 +1331,8 @@ fn test_evaluate_expression_author(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_committer(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
@ -1401,8 +1394,8 @@ fn test_evaluate_expression_committer(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_union(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1474,8 +1467,8 @@ fn test_evaluate_expression_union(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_intersection(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
@ -1514,8 +1507,8 @@ fn test_evaluate_expression_intersection(use_git: bool) {
|
|||
#[test_case(true ; "git backend")]
|
||||
fn test_evaluate_expression_difference(use_git: bool) {
|
||||
let settings = testutils::user_settings();
|
||||
let test_workspace = testutils::init_workspace(&settings, use_git);
|
||||
let repo = &test_workspace.repo;
|
||||
let test_repo = testutils::init_repo(&settings, use_git);
|
||||
let repo = &test_repo.repo;
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
|
Loading…
Reference in a new issue