Skip to content

Commit

Permalink
test_abandon_command: show change ids in get_log_output
Browse files Browse the repository at this point in the history
Branches move around a little confusigly with `abandon`. We do want to keep
them, to test their behavior, but we can show the change id to make things
clearer.
  • Loading branch information
ilyagr committed Dec 2, 2023
1 parent a0cbe7c commit 0634dc5
Showing 1 changed file with 42 additions and 35 deletions.
77 changes: 42 additions & 35 deletions cli/tests/test_abandon_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ fn test_basics() {
create_commit(&test_env, &repo_path, "e", &["a", "d"]);
// Test the setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ e
@ [znk] e
├─╮
│ ◉ d
│ ◉ c
│ │ ◉ b
│ ◉ [vru] d
│ ◉ [roy] c
│ │ ◉ [zsu] b
├───╯
◉ │ a
◉ │ [rlv] a
├─╯
[zzz]
"###);

let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["abandon", "d"]);
Expand All @@ -65,14 +65,14 @@ fn test_basics() {
Added 0 files, modified 0 files, removed 1 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ e
@ [znk] e
├─╮
│ ◉ c d
│ │ ◉ b
│ ◉ [roy] c d
│ │ ◉ [zsu] b
├───╯
◉ │ a
◉ │ [rlv] a
├─╯
[zzz]
"###);

test_env.jj_cmd_ok(&repo_path, &["undo"]);
Expand All @@ -85,14 +85,14 @@ fn test_basics() {
Added 0 files, modified 0 files, removed 3 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@
│ ◉ b
@ [nkm]
│ ◉ [zsu] b
├─╯
◉ a e??
│ ◉ d e??
│ ◉ c
[rlv] a e??
│ ◉ [vru] d e??
│ ◉ [roy] c
├─╯
[zzz]
"###);

// Abandoning `a` would normally result in its descendant merge commit, `e`,
Expand All @@ -109,12 +109,12 @@ fn test_basics() {
Added 0 files, modified 0 files, removed 1 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ e
◉ d
◉ c
│ ◉ b
@ [znk] e
[vru] d
[roy] c
│ ◉ [zsu] b
├─╯
◉ a
[zzz] a
"###);

test_env.jj_cmd_ok(&repo_path, &["undo"]);
Expand All @@ -130,11 +130,11 @@ fn test_basics() {
Added 0 files, modified 0 files, removed 3 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@
│ ◉ b
@ [wvu]
│ ◉ [zsu] b
├─╯
◉ a e??
◉ c d e??
[rlv] a e??
[zzz] c d e??
"###);

// Test abandoning the same commit twice directly
Expand All @@ -145,13 +145,13 @@ fn test_basics() {
Abandoned commit zsuskuln 1394f625 b | b
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ e
@ [znk] e
├─╮
│ ◉ d
│ ◉ c
◉ │ a b
│ ◉ [vru] d
│ ◉ [roy] c
◉ │ [rlv] a b
├─╯
[zzz]
"###);

// Test abandoning the same commit twice indirectly
Expand All @@ -169,10 +169,10 @@ fn test_basics() {
Added 0 files, modified 0 files, removed 4 files
"###);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@
│ ◉ c d e??
@ [oup]
│ ◉ [roy] c d e??
├─╯
◉ a b e??
[zzz] a b e??
"###);
}

Expand Down Expand Up @@ -213,5 +213,12 @@ fn test_double_abandon() {
}

fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String {
test_env.jj_cmd_success(repo_path, &["log", "-T", "branches"])
test_env.jj_cmd_success(
repo_path,
&[
"log",
"-T",
r#"separate(" ", "[" ++ change_id.short(3) ++ "]", branches)"#,
],
)
}

0 comments on commit 0634dc5

Please sign in to comment.