From f9d9c9c224186902a2940760547e6e43242c71cb Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 6 Oct 2024 20:00:49 -0700 Subject: [PATCH] templates: Demo bug where operation summary is printed w/o color in `jj undo` --- cli/tests/test_operations.rs | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/cli/tests/test_operations.rs b/cli/tests/test_operations.rs index 793f6fb0b..556bc9609 100644 --- a/cli/tests/test_operations.rs +++ b/cli/tests/test_operations.rs @@ -781,6 +781,70 @@ fn test_op_recover_from_bad_gc() { "###); } +#[test] +fn test_op_summary_diff_template() { + 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"); + + // Tests in color (easier to read with `less -R`) + test_env.jj_cmd_ok(&repo_path, &["new", "--no-edit", "-m=scratch"]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "undo", "--color=always"]); + insta::assert_snapshot!(&stdout, @""); + // BUG!! (Fixed in next commit) + insta::assert_snapshot!(&stderr, @r#" + Undid operation ac20a4ff4791 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 new empty commit + "#); + let stdout = test_env.jj_cmd_success( + &repo_path, + &[ + "op", + "diff", + "--from", + "0000000", + "--to", + "@", + "--color=always", + ], + ); + insta::assert_snapshot!(&stdout, @r#" + From operation 000000000000 root() + To operation e3792fce5b1f 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 undo operation ac20a4ff47914da9a2e43677b94455b86383bfb9227374d6531ecee85b9ff9230eeb96416a24bb27e7477aa18d50c01810e97c6a008b5c584224650846f4c05b + + Changed commits: + ○ Change qpvuntsmwlqt + + qpvuntsm 230dd059 (empty) (no description set) + "#); + + // Tests with templates + test_env.jj_cmd_ok(&repo_path, &["new", "--no-edit", "-m=scratch"]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "undo", "--color=debug"]); + insta::assert_snapshot!(&stdout, @""); + insta::assert_snapshot!(&stderr, @r#" + Undid operation <> <