mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 16:53:25 +00:00
tests: add additional test case for jj simplify-parents
This test shows that the current implementation of `jj simplify-parents` perform unnecessary rebases of descendant commits.
This commit is contained in:
parent
c6bb019d41
commit
1ae8f0c77a
1 changed files with 75 additions and 1 deletions
|
@ -157,7 +157,6 @@ fn test_simplify_parents_redundant_parent(args: &[&str]) {
|
|||
◆
|
||||
"###);
|
||||
}
|
||||
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, args);
|
||||
insta::allow_duplicates! {
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
|
@ -178,3 +177,78 @@ fn test_simplify_parents_redundant_parent(args: &[&str]) {
|
|||
"###);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simplify_parents_multiple_redundant_parents() {
|
||||
let (test_env, repo_path) = create_repo();
|
||||
|
||||
create_commit(&test_env, &repo_path, "a", &["root()"]);
|
||||
create_commit(&test_env, &repo_path, "b", &["a"]);
|
||||
create_commit(&test_env, &repo_path, "c", &["a", "b"]);
|
||||
create_commit(&test_env, &repo_path, "d", &["c"]);
|
||||
create_commit(&test_env, &repo_path, "e", &["d"]);
|
||||
create_commit(&test_env, &repo_path, "f", &["d", "e"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "all()", "-T", "description"]);
|
||||
insta::assert_snapshot!(stdout, @r#"
|
||||
@ f
|
||||
├─╮
|
||||
│ ○ e
|
||||
├─╯
|
||||
○ d
|
||||
○ c
|
||||
├─╮
|
||||
│ ○ b
|
||||
├─╯
|
||||
○ a
|
||||
◆
|
||||
"#);
|
||||
let setup_opid = test_env.current_operation_id(&repo_path);
|
||||
|
||||
// Test with `-r`.
|
||||
let (stdout, stderr) =
|
||||
test_env.jj_cmd_ok(&repo_path, &["simplify-parents", "-r", "c", "-r", "f"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
// TODO: The output should indicate that edges were removed from 2 commits
|
||||
// (c, f) and 2 descendant commits were rebased (d, e).
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Removed 2 edges from 2 out of 2 commits.
|
||||
Rebased 3 descendant commits
|
||||
Working copy now at: kmkuslsw 8cc01e1b f | f
|
||||
Parent commit : znkkpsqq 040ae3a6 e | e
|
||||
"#);
|
||||
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "all()", "-T", "description"]);
|
||||
insta::assert_snapshot!(stdout, @r#"
|
||||
@ f
|
||||
○ e
|
||||
○ d
|
||||
○ c
|
||||
○ b
|
||||
○ a
|
||||
◆
|
||||
"#);
|
||||
|
||||
// Test with `-s`.
|
||||
test_env.jj_cmd_ok(&repo_path, &["op", "restore", &setup_opid]);
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["simplify-parents", "-s", "c"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
// TODO: The output should indicate that edges were removed from 2 commits
|
||||
// (c, f) and 2 descendant commits were rebased (d, e).
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Removed 2 edges from 2 out of 4 commits.
|
||||
Rebased 3 descendant commits
|
||||
Working copy now at: kmkuslsw 70a39dff f | f
|
||||
Parent commit : znkkpsqq a021fee9 e | e
|
||||
"#);
|
||||
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "all()", "-T", "description"]);
|
||||
insta::assert_snapshot!(stdout, @r#"
|
||||
@ f
|
||||
○ e
|
||||
○ d
|
||||
○ c
|
||||
○ b
|
||||
○ a
|
||||
◆
|
||||
"#);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue