tests: use jj new instead of jj merge in tests

Because `jj new` updates to the new commit, this makes them a little
simpler.
This commit is contained in:
Martin von Zweigbergk 2022-08-30 22:39:32 -07:00 committed by Martin von Zweigbergk
parent a1a980d395
commit d3286c2847
4 changed files with 26 additions and 30 deletions

View File

@ -24,11 +24,9 @@ fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, paren
} else if parents.len() == 1 {
test_env.jj_cmd_success(repo_path, &["co", parents[0]]);
} else {
let mut args = vec!["merge", "-m", name];
let mut args = vec!["new", "-m", name];
args.extend(parents);
test_env.jj_cmd_success(repo_path, &args);
test_env.jj_cmd_success(repo_path, &["co", &format!(r#"description("{name}")"#)]);
test_env.jj_cmd_success(repo_path, &["edit", "@-"]);
}
std::fs::write(repo_path.join(name), &format!("{name}\n")).unwrap();
test_env.jj_cmd_success(repo_path, &["branch", "create", name]);
@ -135,7 +133,7 @@ fn test_rebase_branch_with_merge() {
let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-b", "d", "-d", "b"]);
insta::assert_snapshot!(stdout, @r###"
Rebased 4 commits
Working copy now at: e4e31a4d89a0 (no description set)
Working copy now at: 1eb8211cd98c (no description set)
Added 1 files, modified 0 files, removed 0 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -152,7 +150,7 @@ fn test_rebase_branch_with_merge() {
let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-d", "b"]);
insta::assert_snapshot!(stdout, @r###"
Rebased 4 commits
Working copy now at: 4d6971858019 (no description set)
Working copy now at: b3f3d7a88851 (no description set)
Added 1 files, modified 0 files, removed 0 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -195,7 +193,7 @@ fn test_rebase_single_revision() {
let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-r", "b", "-d", "a"]);
insta::assert_snapshot!(stdout, @r###"
Also rebased 3 descendant commits onto parent of rebased commit
Working copy now at: 4a73870d8075 (no description set)
Working copy now at: b5ce312dacd3 (no description set)
Added 0 files, modified 0 files, removed 2 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -211,7 +209,7 @@ fn test_rebase_single_revision() {
let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-r", "c", "-d", "root"]);
insta::assert_snapshot!(stdout, @r###"
Also rebased 2 descendant commits onto parent of rebased commit
Working copy now at: 14ce5de4fe00 (no description set)
Working copy now at: 5e21ebf9fd2b (no description set)
Added 0 files, modified 0 files, removed 1 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -288,7 +286,7 @@ fn test_rebase_with_descendants() {
let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-s", "b", "-d", "a"]);
insta::assert_snapshot!(stdout, @r###"
Rebased 4 commits
Working copy now at: 3bc01d4effa7 (no description set)
Working copy now at: 114b5a1a41ca (no description set)
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@

View File

@ -84,19 +84,19 @@ fn test_squash() {
test_env.jj_cmd_success(&repo_path, &["new"]);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "d"]);
std::fs::write(repo_path.join("file2"), "d\n").unwrap();
test_env.jj_cmd_success(&repo_path, &["merge", "-m", "merge", "c", "d"]);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "e", "-r", "@+"]);
test_env.jj_cmd_success(&repo_path, &["new", "c", "d"]);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "e"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
o 7789610d8ec6 e
@ c7a11b36d333 e
|\
@ | 5658521e0f8b d
o | 5658521e0f8b d
| o 90fe0a96fc90 c
|/
o fa5efbdf533c b
o 90aeefd03044 a
o 000000000000
"###);
let stderr = test_env.jj_cmd_failure(&repo_path, &["squash", "-r", "e"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["squash"]);
insta::assert_snapshot!(stderr, @r###"
Error: Cannot squash merge commits
"###);
@ -106,11 +106,11 @@ fn test_squash() {
std::fs::write(repo_path.join("file1"), "e\n").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["squash"]);
insta::assert_snapshot!(stdout, @r###"
Working copy now at: 5cd0d6858fd0 (no description set)
Working copy now at: 959145c11426 (no description set)
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ 5cd0d6858fd0
o 5301447e4764 e
@ 959145c11426
o 80960125bb96 e
|\
o | 5658521e0f8b d
| o 90fe0a96fc90 c

View File

@ -17,7 +17,7 @@ use crate::common::TestEnvironment;
pub mod common;
#[test]
fn test_edit() {
fn test_touchup() {
let mut test_env = TestEnvironment::default();
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
let repo_path = test_env.env_root().join("repo");
@ -89,7 +89,7 @@ fn test_edit() {
}
#[test]
fn test_edit_merge() {
fn test_touchup_merge() {
let mut test_env = TestEnvironment::default();
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
let repo_path = test_env.env_root().join("repo");
@ -104,13 +104,11 @@ fn test_edit_merge() {
test_env.jj_cmd_success(&repo_path, &["new"]);
std::fs::write(repo_path.join("file1"), "c\n").unwrap();
std::fs::write(repo_path.join("file2"), "c\n").unwrap();
test_env.jj_cmd_success(&repo_path, &["merge", "@", "b", "-m", "merge"]);
// Check out the merge and resolve the conflict in file1, but leave the conflict
// in file2
test_env.jj_cmd_success(&repo_path, &["co", "@+"]);
test_env.jj_cmd_success(&repo_path, &["new", "@", "b", "-m", "merge"]);
// Resolve the conflict in file1, but leave the conflict in file2
std::fs::write(repo_path.join("file1"), "d\n").unwrap();
std::fs::write(repo_path.join("file3"), "d\n").unwrap();
test_env.jj_cmd_success(&repo_path, &["squash"]);
test_env.jj_cmd_success(&repo_path, &["new"]);
// Test the setup
let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-r", "@-", "-s"]);
insta::assert_snapshot!(stdout, @r###"
@ -128,9 +126,9 @@ fn test_edit_merge() {
.unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["touchup", "-r", "@-"]);
insta::assert_snapshot!(stdout, @r###"
Created 9fed260d03e9 merge
Created cb2b3b755c0a merge
Rebased 1 descendant commits
Working copy now at: b6c2fd3364eb (no description set)
Working copy now at: 9c86af62d473 (no description set)
Added 0 files, modified 0 files, removed 1 files
"###);
let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s", "-r", "@-"]);

View File

@ -83,19 +83,19 @@ fn test_unsquash() {
test_env.jj_cmd_success(&repo_path, &["new"]);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "d"]);
std::fs::write(repo_path.join("file2"), "d\n").unwrap();
test_env.jj_cmd_success(&repo_path, &["merge", "-m", "merge", "c", "d"]);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "e", "-r", "@+"]);
test_env.jj_cmd_success(&repo_path, &["new", "-m", "merge", "c", "d"]);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "e"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
o 7789610d8ec6 e
@ 7789610d8ec6 e
|\
@ | 5658521e0f8b d
o | 5658521e0f8b d
| o 90fe0a96fc90 c
|/
o fa5efbdf533c b
o 90aeefd03044 a
o 000000000000
"###);
let stderr = test_env.jj_cmd_failure(&repo_path, &["unsquash", "-r", "e"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["unsquash"]);
insta::assert_snapshot!(stderr, @r###"
Error: Cannot unsquash merge commits
"###);