parallelize: include parents in template for all tests

Should make it easier to understand the graph shape when there are
lots of crossing lines.
This commit is contained in:
Martin von Zweigbergk 2024-04-18 10:04:34 -07:00 committed by Martin von Zweigbergk
parent fe57602b03
commit 860b39b80f

View file

@ -27,29 +27,29 @@ fn test_parallelize_no_descendants() {
} }
test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=6"]); test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=6"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ b911505e443e 6 @ b911505e443e 6 parents: 5
2e00cb15c7b6 5 2e00cb15c7b6 5 parents: 4
9df3c87db1a2 4 9df3c87db1a2 4 parents: 3
9f5b59fa4622 3 9f5b59fa4622 3 parents: 2
d826910d21fb 2 d826910d21fb 2 parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
test_env.jj_cmd_ok(&workspace_path, &["parallelize", "description(1)::"]); test_env.jj_cmd_ok(&workspace_path, &["parallelize", "description(1)::"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 6c7b60a45eb6 6 @ 6c7b60a45eb6 6 parents:
296f48966777 5 296f48966777 5 parents:
524062469789 4 524062469789 4 parents:
a9334ecaa379 3 a9334ecaa379 3 parents:
3a7b37ebe843 2 3a7b37ebe843 2 parents:
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -65,13 +65,13 @@ fn test_parallelize_with_descendants_simple() {
} }
test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=6"]); test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=6"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ b911505e443e 6 @ b911505e443e 6 parents: 5
2e00cb15c7b6 5 2e00cb15c7b6 5 parents: 4
9df3c87db1a2 4 9df3c87db1a2 4 parents: 3
9f5b59fa4622 3 9f5b59fa4622 3 parents: 2
d826910d21fb 2 d826910d21fb 2 parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
test_env.jj_cmd_ok( test_env.jj_cmd_ok(
@ -79,17 +79,17 @@ fn test_parallelize_with_descendants_simple() {
&["parallelize", "description(1)::description(4)"], &["parallelize", "description(1)::description(4)"],
); );
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 259d624373d7 6 @ 259d624373d7 6 parents: 5
60d419591c77 5 60d419591c77 5 parents: 1 2 3 4
524062469789 4 524062469789 4 parents:
a9334ecaa379 3 a9334ecaa379 3 parents:
3a7b37ebe843 2 3a7b37ebe843 2 parents:
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -108,32 +108,32 @@ fn test_parallelize_where_interior_has_non_target_children() {
test_env.jj_cmd_ok(&workspace_path, &["new", "description(2)", "-m=2c"]); test_env.jj_cmd_ok(&workspace_path, &["new", "description(2)", "-m=2c"]);
test_env.jj_cmd_ok(&workspace_path, &["new", "description(5)", "-m=6"]); test_env.jj_cmd_ok(&workspace_path, &["new", "description(5)", "-m=6"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ d27ee705f7a9 6 @ d27ee705f7a9 6 parents: 5
2e00cb15c7b6 5 2e00cb15c7b6 5 parents: 4
9df3c87db1a2 4 9df3c87db1a2 4 parents: 3
9f5b59fa4622 3 9f5b59fa4622 3 parents: 2
9c8865930f3c 2c 9c8865930f3c 2c parents: 2
d826910d21fb 2 d826910d21fb 2 parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
test_env.jj_cmd_ok(&workspace_path, &["parallelize", "dc0::9df"]); test_env.jj_cmd_ok(&workspace_path, &["parallelize", "dc0::9df"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ a42de3959cae 6 @ a42de3959cae 6 parents: 5
d907c901bad0 5 d907c901bad0 5 parents: 1 2 3 4
b8f977c12383 4 b8f977c12383 4 parents:
7be8374575b9 3 7be8374575b9 3 parents:
2a4c3dab2a50 2c 2a4c3dab2a50 2c parents: 1 2
96ce11389312 2 96ce11389312 2 parents:
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -149,29 +149,29 @@ fn test_parallelize_where_root_has_non_target_children() {
test_env.jj_cmd_ok(&workspace_path, &["new", "description(1)", "-m=1c"]); test_env.jj_cmd_ok(&workspace_path, &["new", "description(1)", "-m=1c"]);
test_env.jj_cmd_ok(&workspace_path, &["new", "description(3)", "-m=4"]); test_env.jj_cmd_ok(&workspace_path, &["new", "description(3)", "-m=4"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 7636b3f489f4 4 @ 7636b3f489f4 4 parents: 3
9f5b59fa4622 3 9f5b59fa4622 3 parents: 2
d826910d21fb 2 d826910d21fb 2 parents: 1
50e2ced81124 1c 50e2ced81124 1c parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
test_env.jj_cmd_ok( test_env.jj_cmd_ok(
&workspace_path, &workspace_path,
&["parallelize", "description(1)::description(3)"], &["parallelize", "description(1)::description(3)"],
); );
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ d024344469c3 4 @ d024344469c3 4 parents: 1 2 3
5bd049136a7c 3 5bd049136a7c 3 parents:
60f737a5a4a7 2 60f737a5a4a7 2 parents:
50e2ced81124 1c 50e2ced81124 1c parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -193,15 +193,15 @@ fn test_parallelize_with_merge_commit_child() {
); );
test_env.jj_cmd_ok(&workspace_path, &["new", "description(3)", "-m", "4"]); test_env.jj_cmd_ok(&workspace_path, &["new", "description(3)", "-m", "4"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 90a65779e2ec 4 @ 90a65779e2ec 4 parents: 3
9f5b59fa4622 3 9f5b59fa4622 3 parents: 2
a01c1fad8506 2a-c a01c1fad8506 2a-c parents: 2 a
1eb902150bb9 a 1eb902150bb9 a parents:
d826910d21fb 2 d826910d21fb 2 parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
// After this finishes, child-2a will have three parents: "1", "2", and "a". // After this finishes, child-2a will have three parents: "1", "2", and "a".
@ -210,18 +210,18 @@ fn test_parallelize_with_merge_commit_child() {
&["parallelize", "description(1)::description(3)"], &["parallelize", "description(1)::description(3)"],
); );
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 6107429ab54b 4 @ 6107429ab54b 4 parents: 1 2 3
a9334ecaa379 3 a9334ecaa379 3 parents:
a386386b94bc 2a-c a386386b94bc 2a-c parents: 1 2 a
1eb902150bb9 a 1eb902150bb9 a parents:
3a7b37ebe843 2 3a7b37ebe843 2 parents:
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -236,10 +236,10 @@ fn test_parallelize_failure_disconnected_target_commits() {
} }
test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=3"]); test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=3"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 9f5b59fa4622 3 @ 9f5b59fa4622 3 parents: 2
d826910d21fb 2 d826910d21fb 2 parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
insta::assert_snapshot!(test_env.jj_cmd_failure( insta::assert_snapshot!(test_env.jj_cmd_failure(
@ -264,15 +264,15 @@ fn test_parallelize_head_is_a_merge() {
&["new", "description(2)", "description(b)", "-m=merged-head"], &["new", "description(2)", "description(b)", "-m=merged-head"],
); );
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ f2087b66e475 merged-head @ f2087b66e475 merged-head parents: 2 b
5164ab888473 b 5164ab888473 b parents: a
f16fe8ac5ce9 a f16fe8ac5ce9 a parents:
fe79412860e8 2 fe79412860e8 2 parents: 1
a915696cf0ad 1 a915696cf0ad 1 parents: 0
a56846756248 0 a56846756248 0 parents:
000000000000 000000000000 parents:
"###); "###);
insta::assert_snapshot!(test_env.jj_cmd_failure(&workspace_path,&["parallelize", "description(1)::"]), insta::assert_snapshot!(test_env.jj_cmd_failure(&workspace_path,&["parallelize", "description(1)::"]),
@ -295,14 +295,14 @@ fn test_parallelize_interior_target_is_a_merge() {
); );
test_env.jj_cmd_ok(&workspace_path, &["new", "-m=3"]); test_env.jj_cmd_ok(&workspace_path, &["new", "-m=3"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ a6321093e3d3 3 @ a6321093e3d3 3 parents: 2
705c32f67ce1 2 705c32f67ce1 2 parents: 1 a
427890ea3f2b a 427890ea3f2b a parents:
a915696cf0ad 1 a915696cf0ad 1 parents: 0
a56846756248 0 a56846756248 0 parents:
000000000000 000000000000 parents:
"###); "###);
insta::assert_snapshot!(test_env.jj_cmd_failure(&workspace_path,&["parallelize", "description(1)::"]), insta::assert_snapshot!(test_env.jj_cmd_failure(&workspace_path,&["parallelize", "description(1)::"]),
@ -325,14 +325,14 @@ fn test_parallelize_root_is_a_merge() {
test_env.jj_cmd_ok(&workspace_path, &["new", "-m=2"]); test_env.jj_cmd_ok(&workspace_path, &["new", "-m=2"]);
test_env.jj_cmd_ok(&workspace_path, &["new", "-m=3"]); test_env.jj_cmd_ok(&workspace_path, &["new", "-m=3"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 9f66b50aa1f2 3 @ 9f66b50aa1f2 3 parents: 2
dd995ce87f21 2 dd995ce87f21 2 parents: 1
4b4941342e06 1 4b4941342e06 1 parents: y x
4035b23c8f72 x 4035b23c8f72 x parents:
f3ec359cf9ff y f3ec359cf9ff y parents:
000000000000 000000000000 parents:
"###); "###);
test_env.jj_cmd_ok( test_env.jj_cmd_ok(
@ -340,16 +340,16 @@ fn test_parallelize_root_is_a_merge() {
&["parallelize", "description(1)::description(2)"], &["parallelize", "description(1)::description(2)"],
); );
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ d6df04b236b0 3 @ d6df04b236b0 3 parents: 1 2
38945baf55f4 2 38945baf55f4 2 parents: y x
4b4941342e06 1 4b4941342e06 1 parents: y x
4035b23c8f72 x 4035b23c8f72 x parents:
f3ec359cf9ff y f3ec359cf9ff y parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -362,21 +362,21 @@ fn test_parallelize_multiple_heads() {
test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=1"]); test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=1"]);
test_env.jj_cmd_ok(&workspace_path, &["new", "description(0)", "-m=2"]); test_env.jj_cmd_ok(&workspace_path, &["new", "description(0)", "-m=2"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 8314addde180 2 @ 8314addde180 2 parents: 0
a915696cf0ad 1 a915696cf0ad 1 parents: 0
a56846756248 0 a56846756248 0 parents:
000000000000 000000000000 parents:
"###); "###);
test_env.jj_cmd_ok(&workspace_path, &["parallelize", "description(0)::"]); test_env.jj_cmd_ok(&workspace_path, &["parallelize", "description(0)::"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ e84481c26195 2 @ e84481c26195 2 parents:
2047527ade93 1 2047527ade93 1 parents:
a56846756248 0 a56846756248 0 parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -392,11 +392,11 @@ fn test_parallelize_multiple_heads_with_and_without_children() {
test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=1"]); test_env.jj_cmd_ok(&workspace_path, &["describe", "-m=1"]);
test_env.jj_cmd_ok(&workspace_path, &["new", "description(0)", "-m=2"]); test_env.jj_cmd_ok(&workspace_path, &["new", "description(0)", "-m=2"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 8314addde180 2 @ 8314addde180 2 parents: 0
a915696cf0ad 1 a915696cf0ad 1 parents: 0
a56846756248 0 a56846756248 0 parents:
000000000000 000000000000 parents:
"###); "###);
test_env.jj_cmd_ok( test_env.jj_cmd_ok(
@ -404,11 +404,11 @@ fn test_parallelize_multiple_heads_with_and_without_children() {
&["parallelize", "description(0)", "description(1)"], &["parallelize", "description(0)", "description(1)"],
); );
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
2047527ade93 1 2047527ade93 1 parents:
@ 8314addde180 2 @ 8314addde180 2 parents: 0
a56846756248 0 a56846756248 0 parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -425,26 +425,26 @@ fn test_parallelize_multiple_roots() {
); );
test_env.jj_cmd_ok(&workspace_path, &["new", "-m=3"]); test_env.jj_cmd_ok(&workspace_path, &["new", "-m=3"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 299099c22761 3 @ 299099c22761 3 parents: 2
0c4da981fc0a 2 0c4da981fc0a 2 parents: 1 a
6d37472c632c a 6d37472c632c a parents:
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
// Succeeds because the roots have the same parents. // Succeeds because the roots have the same parents.
test_env.jj_cmd_ok(&workspace_path, &["parallelize", "root().."]); test_env.jj_cmd_ok(&workspace_path, &["parallelize", "root().."]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 3c90598481cd 3 @ 3c90598481cd 3 parents:
b96aa55582e5 2 b96aa55582e5 2 parents:
6d37472c632c a 6d37472c632c a parents:
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
} }
@ -461,15 +461,15 @@ fn test_parallelize_failure_multiple_heads_with_different_children() {
test_env.jj_cmd_ok(&workspace_path, &["commit", "-m=b"]); test_env.jj_cmd_ok(&workspace_path, &["commit", "-m=b"]);
test_env.jj_cmd_ok(&workspace_path, &["commit", "-m=c"]); test_env.jj_cmd_ok(&workspace_path, &["commit", "-m=c"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 9b5fa4b364d4 @ 9b5fa4b364d4 parents: c
7b095ae9b21f c 7b095ae9b21f c parents: b
5164ab888473 b 5164ab888473 b parents: a
f16fe8ac5ce9 a f16fe8ac5ce9 a parents:
9f5b59fa4622 3 9f5b59fa4622 3 parents: 2
d826910d21fb 2 d826910d21fb 2 parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
insta::assert_snapshot!( insta::assert_snapshot!(
@ -500,14 +500,14 @@ fn test_parallelize_failure_multiple_roots_with_different_parents() {
&["new", "description(2)", "description(b)", "-m=merged-head"], &["new", "description(2)", "description(b)", "-m=merged-head"],
); );
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 1a8db14a8cf0 merged-head @ 1a8db14a8cf0 merged-head parents: 2 b
401e43e9461f b 401e43e9461f b parents: a
66ea2ab19a70 a 66ea2ab19a70 a parents:
d826910d21fb 2 d826910d21fb 2 parents: 1
dc0e5d6135ce 1 dc0e5d6135ce 1 parents:
000000000000 000000000000 parents:
"###); "###);
insta::assert_snapshot!( insta::assert_snapshot!(
@ -532,7 +532,7 @@ fn test_parallelize_complex_nonlinear_target() {
test_env.jj_cmd_ok(&workspace_path, &["new", "-m=1c", "description(1)"]); test_env.jj_cmd_ok(&workspace_path, &["new", "-m=1c", "description(1)"]);
test_env.jj_cmd_ok(&workspace_path, &["new", "-m=2c", "description(2)"]); test_env.jj_cmd_ok(&workspace_path, &["new", "-m=2c", "description(2)"]);
test_env.jj_cmd_ok(&workspace_path, &["new", "-m=3c", "description(3)"]); test_env.jj_cmd_ok(&workspace_path, &["new", "-m=3c", "description(3)"]);
insta::assert_snapshot!(get_log_output_with_parents(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ b043eb81416c 3c parents: 3 @ b043eb81416c 3c parents: 3
48277ee9afe0 4 parents: 3 2 1 48277ee9afe0 4 parents: 3 2 1
@ -558,7 +558,7 @@ fn test_parallelize_complex_nonlinear_target() {
Parent commit : rlvkpnrz 745bea80 (empty) 0 Parent commit : rlvkpnrz 745bea80 (empty) 0
Parent commit : mzvwutvl cb944786 (empty) 3 Parent commit : mzvwutvl cb944786 (empty) 3
"###); "###);
insta::assert_snapshot!(get_log_output_with_parents(&test_env, &workspace_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ 59a216e537c4 3c parents: 0 3 @ 59a216e537c4 3c parents: 0 3
cb9447869bf0 3 parents: cb9447869bf0 3 parents:
@ -578,7 +578,7 @@ fn test_parallelize_complex_nonlinear_target() {
"###) "###)
} }
fn get_log_output_with_parents(test_env: &TestEnvironment, cwd: &Path) -> String { fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
let template = r#" let template = r#"
separate(" ", separate(" ",
commit_id.short(), commit_id.short(),
@ -588,8 +588,3 @@ fn get_log_output_with_parents(test_env: &TestEnvironment, cwd: &Path) -> String
)"#; )"#;
test_env.jj_cmd_success(cwd, &["log", "-T", template]) test_env.jj_cmd_success(cwd, &["log", "-T", template])
} }
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
let template = r#"separate(" ", commit_id.short(), local_branches, description)"#;
test_env.jj_cmd_success(cwd, &["log", "-T", template])
}