-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update unittests for conflict hinting update.
- Loading branch information
Showing
1 changed file
with
216 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,7 @@ fn test_status_filtered() { | |
|
||
// See <https://github.com/martinvonz/jj/issues/3108> | ||
#[test] | ||
fn test_status_display_rebase_instructions() { | ||
fn test_status_display_rebase_instructions_if_working_commit_has_conflict() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); | ||
|
||
|
@@ -143,7 +143,7 @@ fn test_status_display_rebase_instructions() { | |
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "boom-cont"]); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "boom-cont-2"]); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "::@"]); | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "root()::"]); | ||
|
||
insta::assert_snapshot!(stdout, @r###" | ||
@ yqosqzyt [email protected] 2001-02-03 08:05:13 65143fef conflict | ||
|
@@ -177,6 +177,220 @@ fn test_status_display_rebase_instructions() { | |
"###); | ||
} | ||
|
||
#[test] | ||
fn test_status_working_commit_noconflict_parent_noconflict() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); | ||
|
||
let repo_path = test_env.env_root().join("repo"); | ||
let conflicted_path = repo_path.join("conflicted.txt"); | ||
|
||
// PARENT: Write the initial file | ||
std::fs::write(&conflicted_path, "initial contents").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["describe", "--message", "Initial contents"]); | ||
|
||
// CHILD1: New commit on top of <PARENT> | ||
test_env.jj_cmd_ok( | ||
&repo_path, | ||
&["new", "--message", "First part of conflicting change"], | ||
); | ||
std::fs::write(&conflicted_path, "Child 1").unwrap(); | ||
|
||
// CHILD2: New commit also on top of <PARENT> | ||
test_env.jj_cmd_ok( | ||
&repo_path, | ||
&[ | ||
"new", | ||
"--message", | ||
"Second part of conflicting change", | ||
"@-", | ||
], | ||
); | ||
std::fs::write(&conflicted_path, "Child 2").unwrap(); | ||
|
||
// CONFLICT: New commit that is conflicted by merging <CHILD1> and <CHILD2> | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "boom", "all:(@-)+"]); | ||
|
||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "boom-cont"]); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "fixed 1"]); | ||
std::fs::write(&conflicted_path, "first commit to fix conflict").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "fixed 2"]); | ||
std::fs::write(&conflicted_path, "edit not conflict").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["status"]); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "root()::"]); | ||
|
||
insta::assert_snapshot!(stdout, @r###" | ||
@ vruxwmqv [email protected] 2001-02-03 08:05:15 376a25f2 | ||
│ fixed 2 | ||
○ yqosqzyt [email protected] 2001-02-03 08:05:14 f10a05bb | ||
│ fixed 1 | ||
× royxmykx [email protected] 2001-02-03 08:05:12 a4e88714 conflict | ||
│ (empty) boom-cont | ||
× mzvwutvl [email protected] 2001-02-03 08:05:11 538415e7 conflict | ||
├─╮ (empty) boom | ||
│ ○ kkmpptxz [email protected] 2001-02-03 08:05:10 1e8c2956 | ||
│ │ First part of conflicting change | ||
○ │ zsuskuln [email protected] 2001-02-03 08:05:11 2c8b19fd | ||
├─╯ Second part of conflicting change | ||
○ qpvuntsm [email protected] 2001-02-03 08:05:08 aade7195 | ||
│ Initial contents | ||
◆ zzzzzzzz root() 00000000 | ||
"###); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["status"]); | ||
|
||
insta::assert_snapshot!(stdout, @r###" | ||
Working copy changes: | ||
M conflicted.txt | ||
Working copy : vruxwmqv 376a25f2 fixed 2 | ||
Parent commit: yqosqzyt f10a05bb fixed 1 | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_status_working_commit_noconflict_parent_conflict() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); | ||
|
||
let repo_path = test_env.env_root().join("repo"); | ||
let conflicted_path = repo_path.join("conflicted.txt"); | ||
|
||
// PARENT: Write the initial file | ||
std::fs::write(&conflicted_path, "initial contents").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["describe", "--message", "Initial contents"]); | ||
|
||
// CHILD1: New commit on top of <PARENT> | ||
test_env.jj_cmd_ok( | ||
&repo_path, | ||
&["new", "--message", "First part of conflicting change"], | ||
); | ||
std::fs::write(&conflicted_path, "Child 1").unwrap(); | ||
|
||
// CHILD2: New commit also on top of <PARENT> | ||
test_env.jj_cmd_ok( | ||
&repo_path, | ||
&[ | ||
"new", | ||
"--message", | ||
"Second part of conflicting change", | ||
"@-", | ||
], | ||
); | ||
std::fs::write(&conflicted_path, "Child 2").unwrap(); | ||
|
||
// CONFLICT: New commit that is conflicted by merging <CHILD1> and <CHILD2> | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "boom", "all:(@-)+"]); | ||
|
||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "boom-cont"]); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "fixed 1"]); | ||
std::fs::write(&conflicted_path, "first commit to fix conflict").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "fixed 2"]); | ||
std::fs::write(&conflicted_path, "edit not conflict").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["edit", "@-"]); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "root()::"]); | ||
|
||
insta::assert_snapshot!(stdout, @r###" | ||
○ vruxwmqv [email protected] 2001-02-03 08:05:15 376a25f2 | ||
│ fixed 2 | ||
@ yqosqzyt [email protected] 2001-02-03 08:05:14 f10a05bb | ||
│ fixed 1 | ||
× royxmykx [email protected] 2001-02-03 08:05:12 a4e88714 conflict | ||
│ (empty) boom-cont | ||
× mzvwutvl [email protected] 2001-02-03 08:05:11 538415e7 conflict | ||
├─╮ (empty) boom | ||
│ ○ kkmpptxz [email protected] 2001-02-03 08:05:10 1e8c2956 | ||
│ │ First part of conflicting change | ||
○ │ zsuskuln [email protected] 2001-02-03 08:05:11 2c8b19fd | ||
├─╯ Second part of conflicting change | ||
○ qpvuntsm [email protected] 2001-02-03 08:05:08 aade7195 | ||
│ Initial contents | ||
◆ zzzzzzzz root() 00000000 | ||
"###); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["status"]); | ||
|
||
insta::assert_snapshot!(stdout, @r###" | ||
Working copy changes: | ||
M conflicted.txt | ||
Working copy : yqosqzyt f10a05bb fixed 1 | ||
Parent commit: royxmykx a4e88714 (conflict) (empty) boom-cont | ||
Conflict in parent commit has been resolved in working copy | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_status_tree_conflict_working_commit_noconflict() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); | ||
|
||
let repo_path = test_env.env_root().join("repo"); | ||
let conflicted_path = repo_path.join("conflicted.txt"); | ||
|
||
// PARENT: Write the initial file | ||
std::fs::write(&conflicted_path, "initial contents").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["describe", "--message", "Initial contents"]); | ||
|
||
// CHILD1: New commit on top of <PARENT> | ||
test_env.jj_cmd_ok( | ||
&repo_path, | ||
&["new", "--message", "First part of conflicting change"], | ||
); | ||
std::fs::write(&conflicted_path, "Child 1").unwrap(); | ||
|
||
// CHILD2: New commit also on top of <PARENT> | ||
test_env.jj_cmd_ok( | ||
&repo_path, | ||
&[ | ||
"new", | ||
"--message", | ||
"Second part of conflicting change", | ||
"@-", | ||
], | ||
); | ||
std::fs::write(&conflicted_path, "Child 2").unwrap(); | ||
|
||
// CONFLICT: New commit that is conflicted by merging <CHILD1> and <CHILD2> | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "boom", "all:(@-)+"]); | ||
|
||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "boom-cont"]); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "fixed 1"]); | ||
std::fs::write(&conflicted_path, "first commit to fix conflict").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "--message", "fixed 2"]); | ||
std::fs::write(&conflicted_path, "edit not conflict").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["edit", "root()+"]); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "root()::"]); | ||
|
||
insta::assert_snapshot!(stdout, @r###" | ||
○ vruxwmqv [email protected] 2001-02-03 08:05:15 376a25f2 | ||
│ fixed 2 | ||
○ yqosqzyt [email protected] 2001-02-03 08:05:14 f10a05bb | ||
│ fixed 1 | ||
× royxmykx [email protected] 2001-02-03 08:05:12 a4e88714 conflict | ||
│ (empty) boom-cont | ||
× mzvwutvl [email protected] 2001-02-03 08:05:11 538415e7 conflict | ||
├─╮ (empty) boom | ||
│ ○ kkmpptxz [email protected] 2001-02-03 08:05:10 1e8c2956 | ||
│ │ First part of conflicting change | ||
○ │ zsuskuln [email protected] 2001-02-03 08:05:11 2c8b19fd | ||
├─╯ Second part of conflicting change | ||
@ qpvuntsm [email protected] 2001-02-03 08:05:08 aade7195 | ||
│ Initial contents | ||
◆ zzzzzzzz root() 00000000 | ||
"###); | ||
|
||
let stdout = test_env.jj_cmd_success(&repo_path, &["status"]); | ||
|
||
insta::assert_snapshot!(stdout, @r###" | ||
Working copy changes: | ||
A conflicted.txt | ||
Working copy : qpvuntsm aade7195 Initial contents | ||
Parent commit: zzzzzzzz 00000000 (empty) (no description set) | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_status_simplify_conflict_sides() { | ||
let test_env = TestEnvironment::default(); | ||
|