mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-28 15:26:25 +00:00
next/prev: include graph in --conflict
tests, highlighting bugs
There are several bugs in both the tests and in the implementation that are made more clear by showing the log output before and after running the command.
This commit is contained in:
parent
0a402a28a0
commit
8aeb9a8ea8
1 changed files with 72 additions and 30 deletions
|
@ -584,14 +584,25 @@ fn test_prev_conflict() {
|
||||||
std::fs::write(&file_path, "first+1").unwrap();
|
std::fs::write(&file_path, "first+1").unwrap();
|
||||||
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
|
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
|
||||||
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
|
||||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev", "--conflict"]);
|
// Test the setup
|
||||||
// We now should be a child of `fourth`.
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||||
insta::assert_snapshot!(stdout, @"");
|
@ yqosqzytrlsw conflict
|
||||||
insta::assert_snapshot!(stderr, @r###"
|
◉ royxmykxtrkr conflict fourth
|
||||||
Working copy now at: vruxwmqv b1ea981a (conflict) (empty) (no description set)
|
◉ kkmpptxzrspx conflict third
|
||||||
Parent commit : rlvkpnrz c26675ba (conflict) second
|
◉ rlvkpnrzqnoo conflict second
|
||||||
There are unresolved conflicts at these paths:
|
◉ qpvuntsmwlqt first
|
||||||
content.txt 2-sided conflict
|
◉ zzzzzzzzzzzz
|
||||||
|
"###);
|
||||||
|
test_env.jj_cmd_ok(&repo_path, &["prev", "--conflict"]);
|
||||||
|
// TODO: We now should be a child of `third`.
|
||||||
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||||
|
@ yostqsxwqrlt conflict
|
||||||
|
│ ◉ royxmykxtrkr conflict fourth
|
||||||
|
│ ◉ kkmpptxzrspx conflict third
|
||||||
|
├─╯
|
||||||
|
◉ rlvkpnrzqnoo conflict second
|
||||||
|
◉ qpvuntsmwlqt first
|
||||||
|
◉ zzzzzzzzzzzz
|
||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,14 +621,21 @@ fn test_prev_conflict_editing() {
|
||||||
test_env.jj_cmd_ok(&repo_path, &["edit", "description(first)"]);
|
test_env.jj_cmd_ok(&repo_path, &["edit", "description(first)"]);
|
||||||
std::fs::write(&file_path, "first text").unwrap();
|
std::fs::write(&file_path, "first text").unwrap();
|
||||||
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
|
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
|
||||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev", "--conflict", "--edit"]);
|
// Test the setup
|
||||||
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||||
|
@ royxmykxtrkr conflict
|
||||||
|
◉ kkmpptxzrspx conflict third
|
||||||
|
◉ rlvkpnrzqnoo second
|
||||||
|
◉ qpvuntsmwlqt first
|
||||||
|
◉ zzzzzzzzzzzz
|
||||||
|
"###);
|
||||||
|
test_env.jj_cmd_ok(&repo_path, &["prev", "--conflict", "--edit"]);
|
||||||
// We now should be editing the third commit.
|
// We now should be editing the third commit.
|
||||||
insta::assert_snapshot!(stdout, @"");
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||||
insta::assert_snapshot!(stderr, @r###"
|
@ kkmpptxzrspx conflict third
|
||||||
Working copy now at: kkmpptxz 26b1439f (conflict) third
|
◉ rlvkpnrzqnoo second
|
||||||
Parent commit : rlvkpnrz 55b5d11a (empty) second
|
◉ qpvuntsmwlqt first
|
||||||
There are unresolved conflicts at these paths:
|
◉ zzzzzzzzzzzz
|
||||||
content.txt 2-sided conflict
|
|
||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,13 +656,25 @@ fn test_next_conflict() {
|
||||||
test_env.jj_cmd_ok(&repo_path, &["new", "description(second)"]);
|
test_env.jj_cmd_ok(&repo_path, &["new", "description(second)"]);
|
||||||
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
|
||||||
test_env.jj_cmd_ok(&repo_path, &["new", "description(second)"]);
|
test_env.jj_cmd_ok(&repo_path, &["new", "description(second)"]);
|
||||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next", "--conflict"]);
|
// Test the setup
|
||||||
insta::assert_snapshot!(stdout, @"");
|
// TODO: This test doesn't seem to test what it's supposed to (we're already on
|
||||||
insta::assert_snapshot!(stderr, @r###"
|
// the second commit)
|
||||||
Working copy now at: vruxwmqv b69eca51 (conflict) (empty) (no description set)
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||||
Parent commit : rlvkpnrz fa43d820 (conflict) second
|
@ yqosqzytrlsw conflict
|
||||||
There are unresolved conflicts at these paths:
|
│ ◉ mzvwutvlkqwt conflict third
|
||||||
content.txt 2-sided conflict
|
├─╯
|
||||||
|
◉ rlvkpnrzqnoo conflict second
|
||||||
|
◉ qpvuntsmwlqt first
|
||||||
|
◉ zzzzzzzzzzzz
|
||||||
|
"###);
|
||||||
|
test_env.jj_cmd_ok(&repo_path, &["next", "--conflict"]);
|
||||||
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||||
|
@ yostqsxwqrlt conflict
|
||||||
|
│ ◉ mzvwutvlkqwt conflict third
|
||||||
|
├─╯
|
||||||
|
◉ rlvkpnrzqnoo conflict second
|
||||||
|
◉ qpvuntsmwlqt first
|
||||||
|
◉ zzzzzzzzzzzz
|
||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,18 +694,30 @@ fn test_next_conflict_editing() {
|
||||||
test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]);
|
test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]);
|
||||||
std::fs::write(&file_path, "modified second").unwrap();
|
std::fs::write(&file_path, "modified second").unwrap();
|
||||||
test_env.jj_cmd_ok(&repo_path, &["new", "@+"]);
|
test_env.jj_cmd_ok(&repo_path, &["new", "@+"]);
|
||||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next", "--conflict", "--edit"]);
|
// Test the setup
|
||||||
|
// TODO: This test doesn't seem to test what it's supposed to (we're already on
|
||||||
|
// top of the third commit)
|
||||||
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||||
|
@ mzvwutvlkqwt conflict
|
||||||
|
◉ kkmpptxzrspx conflict
|
||||||
|
◉ rlvkpnrzqnoo second
|
||||||
|
◉ qpvuntsmwlqt first
|
||||||
|
◉ zzzzzzzzzzzz
|
||||||
|
"###);
|
||||||
|
// TODO: The command should be an error since there is no conflict after the
|
||||||
|
// current one
|
||||||
|
test_env.jj_cmd_ok(&repo_path, &["next", "--conflict", "--edit"]);
|
||||||
// We now should be editing the third commit.
|
// We now should be editing the third commit.
|
||||||
insta::assert_snapshot!(stdout, @"");
|
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||||
insta::assert_snapshot!(stderr, @r###"
|
@ yqosqzytrlsw conflict
|
||||||
Working copy now at: royxmykx 08fda952 (conflict) (empty) (no description set)
|
◉ kkmpptxzrspx conflict
|
||||||
Parent commit : kkmpptxz 69ff337c (conflict) (no description set)
|
◉ rlvkpnrzqnoo second
|
||||||
There are unresolved conflicts at these paths:
|
◉ qpvuntsmwlqt first
|
||||||
content.txt 2-sided conflict
|
◉ zzzzzzzzzzzz
|
||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
|
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
|
||||||
let template = r#"separate(" ", change_id.short(), local_branches, description)"#;
|
let template = r#"separate(" ", change_id.short(), local_branches, if(conflict, "conflict"), description)"#;
|
||||||
test_env.jj_cmd_success(cwd, &["log", "-T", template])
|
test_env.jj_cmd_success(cwd, &["log", "-T", template])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue