diff --git a/tests/smoke_test.rs b/tests/smoke_test.rs index a5da9446e..20da902e3 100644 --- a/tests/smoke_test.rs +++ b/tests/smoke_test.rs @@ -52,11 +52,13 @@ fn smoke_test() { // Add a commit description let stdout = test_env.jj_cmd_success(&repo_path, &["describe", "-m", "add some files"]); - insta::assert_snapshot!(stdout, @"Working copy now at: 701b3d5a2eb3 add some files -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: 701b3d5a2eb3 add some files + "###); // Close the commit let stdout = test_env.jj_cmd_success(&repo_path, &["close"]); - insta::assert_snapshot!(stdout, @"Working copy now at: a13f828fab1a -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: a13f828fab1a + "###); } diff --git a/tests/test_describe_command.rs b/tests/test_describe_command.rs index 92a3010f9..82027d310 100644 --- a/tests/test_describe_command.rs +++ b/tests/test_describe_command.rs @@ -26,20 +26,23 @@ fn test_describe() { // Set a description using `-m` flag let stdout = test_env.jj_cmd_success(&repo_path, &["describe", "-m", "description from CLI"]); - insta::assert_snapshot!(stdout, @"Working copy now at: 7e0db3b0ad17 description from CLI -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: 7e0db3b0ad17 description from CLI + "###); // Test making no changes std::fs::write(&edit_script, "").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["describe"]); - insta::assert_snapshot!(stdout, @"Working copy now at: 45bfa10db64d description from CLI -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: 45bfa10db64d description from CLI + "###); // Set a description in editor std::fs::write(&edit_script, "write\ndescription from editor").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["describe"]); - insta::assert_snapshot!(stdout, @"Working copy now at: f2ce8f1ad8fa description from editor -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: f2ce8f1ad8fa description from editor + "###); // Lines in editor starting with "JJ: " are ignored std::fs::write( @@ -48,8 +51,9 @@ fn test_describe() { ) .unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["describe"]); - insta::assert_snapshot!(stdout, @"Working copy now at: 95664f6316ae description among comment -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: 95664f6316ae description among comment + "###); // Fails if the editor fails std::fs::write(&edit_script, "fail").unwrap(); diff --git a/tests/test_edit_command.rs b/tests/test_edit_command.rs index 25da66e75..cea2bcfb2 100644 --- a/tests/test_edit_command.rs +++ b/tests/test_edit_command.rs @@ -38,8 +38,9 @@ fn test_edit() { ) .unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["edit"]); - insta::assert_snapshot!(stdout, @"Nothing changed. -"); + insta::assert_snapshot!(stdout, @r###" + Nothing changed. + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); insta::assert_snapshot!(stdout, @r###" R file1 @@ -49,8 +50,9 @@ fn test_edit() { // Nothing happens if the diff-editor exits with an error std::fs::write(&edit_script, "rm file2\0fail").unwrap(); let stderr = test_env.jj_cmd_failure(&repo_path, &["edit"]); - insta::assert_snapshot!(stderr, @"Error: Failed to edit diff: The diff tool exited with a non-zero code -"); + insta::assert_snapshot!(stderr, @r###" + Error: Failed to edit diff: The diff tool exited with a non-zero code + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); insta::assert_snapshot!(stdout, @r###" R file1 @@ -66,8 +68,9 @@ fn test_edit() { Added 0 files, modified 1 files, removed 0 files "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); - insta::assert_snapshot!(stdout, @"R file1 -"); + insta::assert_snapshot!(stdout, @r###" + R file1 + "###); // Changes to a commit are propagated to descendants test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -80,8 +83,9 @@ fn test_edit() { Added 0 files, modified 1 files, removed 0 files "###); let contents = String::from_utf8(std::fs::read(repo_path.join("file3")).unwrap()).unwrap(); - insta::assert_snapshot!(contents, @"modified -"); + insta::assert_snapshot!(contents, @r###" + modified + "###); } #[test] diff --git a/tests/test_git_push.rs b/tests/test_git_push.rs index 892329c88..da2106102 100644 --- a/tests/test_git_push.rs +++ b/tests/test_git_push.rs @@ -30,8 +30,9 @@ fn test_git_push() { // No branches to push yet let stdout = test_env.jj_cmd_success(&workspace_root, &["git", "push"]); - insta::assert_snapshot!(stdout, @"Nothing changed. -"); + insta::assert_snapshot!(stdout, @r###" + Nothing changed. + "###); // When pushing everything, won't push an open commit even if there's a branch // on it @@ -45,8 +46,9 @@ fn test_git_push() { // When pushing a specific branch, won't push it if it points to an open commit let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push", "--branch", "my-branch"]); - insta::assert_snapshot!(stderr, @"Error: Won't push open commit -"); + insta::assert_snapshot!(stderr, @r###" + Error: Won't push open commit + "###); // Try pushing a conflict std::fs::write(workspace_root.join("file"), "first").unwrap(); @@ -58,6 +60,7 @@ fn test_git_push() { test_env.jj_cmd_success(&workspace_root, &["branch", "my-branch"]); test_env.jj_cmd_success(&workspace_root, &["close", "-m", "third"]); let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push"]); - insta::assert_snapshot!(stderr, @"Error: Won't push commit 28b5642cb786 since it has conflicts -"); + insta::assert_snapshot!(stderr, @r###" + Error: Won't push commit 28b5642cb786 since it has conflicts + "###); } diff --git a/tests/test_global_opts.rs b/tests/test_global_opts.rs index 351acd1b3..3ab6253cc 100644 --- a/tests/test_global_opts.rs +++ b/tests/test_global_opts.rs @@ -51,16 +51,18 @@ fn test_no_commit_working_copy() { fn test_repo_arg_with_init() { let test_env = TestEnvironment::default(); let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["init", "-R=.", "repo"]); - insta::assert_snapshot!(stderr, @"Error: '--repository' cannot be used with 'init' -"); + insta::assert_snapshot!(stderr, @r###" + Error: '--repository' cannot be used with 'init' + "###); } #[test] fn test_repo_arg_with_git_clone() { let test_env = TestEnvironment::default(); let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["git", "clone", "-R=.", "remote"]); - insta::assert_snapshot!(stderr, @"Error: '--repository' cannot be used with 'git clone' -"); + insta::assert_snapshot!(stderr, @r###" + Error: '--repository' cannot be used with 'git clone' + "###); } #[test] @@ -97,8 +99,9 @@ fn test_invalid_config() { test_env.add_config(b"[section]key = value-missing-quotes"); let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["init", "repo"]); - insta::assert_snapshot!(stderr.replace('\\', "/"), @"Invalid config: expected newline, found an identifier at line 1 column 10 in config/config0001.toml -"); + insta::assert_snapshot!(stderr.replace('\\', "/"), @r###" + Invalid config: expected newline, found an identifier at line 1 column 10 in config/config0001.toml + "###); } #[test] diff --git a/tests/test_init_command.rs b/tests/test_init_command.rs index 869f4815e..0d482abb2 100644 --- a/tests/test_init_command.rs +++ b/tests/test_init_command.rs @@ -50,8 +50,9 @@ fn init_git_repo(git_repo_path: &PathBuf) { fn test_init_git_internal() { let test_env = TestEnvironment::default(); let stdout = test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]); - insta::assert_snapshot!(stdout, @r###"Initialized repo in "repo" -"###); + insta::assert_snapshot!(stdout, @r###" + Initialized repo in "repo" + "###); let workspace_root = test_env.env_root().join("repo"); let jj_path = workspace_root.join(".jj"); @@ -117,8 +118,9 @@ fn test_init_git_colocated() { let workspace_root = test_env.env_root().join("repo"); init_git_repo(&workspace_root); let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]); - insta::assert_snapshot!(stdout, @r###"Initialized repo in "." -"###); + insta::assert_snapshot!(stdout, @r###" + Initialized repo in "." + "###); let jj_path = workspace_root.join(".jj"); let repo_path = jj_path.join("repo"); @@ -145,8 +147,9 @@ fn test_init_git_colocated() { fn test_init_local() { let test_env = TestEnvironment::default(); let stdout = test_env.jj_cmd_success(test_env.env_root(), &["init", "repo"]); - insta::assert_snapshot!(stdout, @r###"Initialized repo in "repo" -"###); + insta::assert_snapshot!(stdout, @r###" + Initialized repo in "repo" + "###); let workspace_root = test_env.env_root().join("repo"); let jj_path = workspace_root.join(".jj"); diff --git a/tests/test_move_command.rs b/tests/test_move_command.rs index fc4a9e6cd..bc73b87e8 100644 --- a/tests/test_move_command.rs +++ b/tests/test_move_command.rs @@ -77,8 +77,9 @@ fn test_move() { "###); // Errors out if source and destination are the same let stderr = test_env.jj_cmd_failure(&repo_path, &["move", "--to", "@"]); - insta::assert_snapshot!(stderr, @"Error: Source and destination cannot be the same. -"); + insta::assert_snapshot!(stderr, @r###" + Error: Source and destination cannot be the same. + "###); // Can move from sibling, which results in the source being abandoned let stdout = test_env.jj_cmd_success(&repo_path, &["move", "--from", "c"]); @@ -97,18 +98,21 @@ fn test_move() { "###); // The change from the source has been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); // File `file2`, which was not changed in source, is unchanged let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); - insta::assert_snapshot!(stdout, @"f -"); + insta::assert_snapshot!(stdout, @r###" + f + "###); // Can move from ancestor test_env.jj_cmd_success(&repo_path, &["undo"]); let stdout = test_env.jj_cmd_success(&repo_path, &["move", "--from", "@--"]); - insta::assert_snapshot!(stdout, @"Working copy now at: c8d83075e8c2 -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: c8d83075e8c2 + "###); // The change has been removed from the source (the change pointed to by 'd' // became empty and was abandoned) insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @@ -123,8 +127,9 @@ fn test_move() { // The change from the source has been applied (the file contents were already // "f", as is typically the case when moving changes from an ancestor) let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); - insta::assert_snapshot!(stdout, @"f -"); + insta::assert_snapshot!(stdout, @r###" + f + "###); // Can move from descendant test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -146,8 +151,9 @@ fn test_move() { "###); // The change from the source has been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "d"]); - insta::assert_snapshot!(stdout, @"e -"); + insta::assert_snapshot!(stdout, @r###" + e + "###); } #[test] @@ -205,15 +211,18 @@ fn test_move_partial() { "###); // The changes from the source has been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); // File `file3`, which was not changed in source, is unchanged let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); - insta::assert_snapshot!(stdout, @"d -"); + insta::assert_snapshot!(stdout, @r###" + d + "###); // Can move only part of the change in interactive mode test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -233,16 +242,19 @@ fn test_move_partial() { "###); // The selected change from the source has been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); // The unselected change from the source has not been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); - insta::assert_snapshot!(stdout, @"a -"); + insta::assert_snapshot!(stdout, @r###" + a + "###); // File `file3`, which was changed in source's parent, is unchanged let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); - insta::assert_snapshot!(stdout, @"d -"); + insta::assert_snapshot!(stdout, @r###" + d + "###); // Can move only part of the change from a sibling in non-interactive mode test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -263,16 +275,19 @@ fn test_move_partial() { "###); // The selected change from the source has been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); // The unselected change from the source has not been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2"]); - insta::assert_snapshot!(stdout, @"a -"); + insta::assert_snapshot!(stdout, @r###" + a + "###); // File `file3`, which was changed in source's parent, is unchanged let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file3"]); - insta::assert_snapshot!(stdout, @"d -"); + insta::assert_snapshot!(stdout, @r###" + d + "###); // Can move only part of the change from a descendant in non-interactive mode test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -280,8 +295,9 @@ fn test_move_partial() { std::fs::write(&edit_script, "").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["move", "--from", "c", "--to", "b", "file1"]); - insta::assert_snapshot!(stdout, @"Rebased 1 descendant commits -"); + insta::assert_snapshot!(stdout, @r###" + Rebased 1 descendant commits + "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" o 21253406d416 c o e1cf08aae711 b @@ -292,12 +308,14 @@ fn test_move_partial() { "###); // The selected change from the source has been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); // The unselected change from the source has not been applied let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); - insta::assert_snapshot!(stdout, @"a -"); + insta::assert_snapshot!(stdout, @r###" + a + "###); } fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String { diff --git a/tests/test_operations.rs b/tests/test_operations.rs index aec97013d..3c49de2d6 100644 --- a/tests/test_operations.rs +++ b/tests/test_operations.rs @@ -35,8 +35,9 @@ fn test_op_log() { let initialize_repo_id = stdout.lines().nth(2).unwrap()[2..14].to_string(); // Can load the repo at a specific operation ID - insta::assert_snapshot!(get_log_output(&test_env, &repo_path, &initialize_repo_id), @"o 0000000000000000000000000000000000000000 -"); + insta::assert_snapshot!(get_log_output(&test_env, &repo_path, &initialize_repo_id), @r###" + o 0000000000000000000000000000000000000000 + "###); insta::assert_snapshot!(get_log_output(&test_env, &repo_path, &add_workspace_id), @r###" @ 230dd059e1b059aefc0da06a2e5a7dbf22362f22 o 0000000000000000000000000000000000000000 @@ -52,17 +53,21 @@ fn test_op_log() { "###); // We get a reasonable message if an invalid operation ID is specified - insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "foo"]), @r###"Error: Operation ID "foo" is not a valid hexadecimal prefix -"###); + insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "foo"]), @r###" + Error: Operation ID "foo" is not a valid hexadecimal prefix + "###); // Odd length - insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "123456789"]), @r###"Error: No operation ID matching "123456789" -"###); + insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "123456789"]), @r###" + Error: No operation ID matching "123456789" + "###); // Even length - insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "0123456789"]), @r###"Error: No operation ID matching "0123456789" -"###); + insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "0123456789"]), @r###" + Error: No operation ID matching "0123456789" + "###); // Empty ID - insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", ""]), @r###"Error: Operation ID "" is not a valid hexadecimal prefix -"###); + insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", ""]), @r###" + Error: Operation ID "" is not a valid hexadecimal prefix + "###); test_env.jj_cmd_success(&repo_path, &["describe", "-m", "description 1"]); test_env.jj_cmd_success( @@ -75,11 +80,13 @@ fn test_op_log() { &add_workspace_id, ], ); - insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "@-"]), @r###"Error: The "@-" expression resolved to more than one operation -"###); + insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "@-"]), @r###" + Error: The "@-" expression resolved to more than one operation + "###); test_env.jj_cmd_success(&repo_path, &["st"]); - insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "@-"]), @r###"Error: The "@-" expression resolved to more than one operation -"###); + insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["log", "--at-op", "@-"]), @r###" + Error: The "@-" expression resolved to more than one operation + "###); } fn get_log_output(test_env: &TestEnvironment, repo_path: &Path, op_id: &str) -> String { diff --git a/tests/test_print_command.rs b/tests/test_print_command.rs index c0c3ae8cf..f9e2bc7f3 100644 --- a/tests/test_print_command.rs +++ b/tests/test_print_command.rs @@ -29,25 +29,30 @@ fn test_print() { std::fs::write(repo_path.join("dir").join("file2"), "c\n").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "@-"]); - insta::assert_snapshot!(stdout, @"a -"); + insta::assert_snapshot!(stdout, @r###" + a + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); let subdir_file = if cfg!(unix) { "dir/file2" } else { "dir\\file2" }; let stdout = test_env.jj_cmd_success(&repo_path, &["print", subdir_file]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); let stderr = test_env.jj_cmd_failure(&repo_path, &["print", "non-existent"]); - insta::assert_snapshot!(stderr, @"Error: No such path -"); + insta::assert_snapshot!(stderr, @r###" + Error: No such path + "###); let stderr = test_env.jj_cmd_failure(&repo_path, &["print", "dir"]); - insta::assert_snapshot!(stderr, @"Error: Path exists but is not a file -"); + insta::assert_snapshot!(stderr, @r###" + Error: Path exists but is not a file + "###); // Can print a conflict test_env.jj_cmd_success(&repo_path, &["new"]); diff --git a/tests/test_rebase_command.rs b/tests/test_rebase_command.rs index 485b6ee11..4748267b9 100644 --- a/tests/test_rebase_command.rs +++ b/tests/test_rebase_command.rs @@ -64,13 +64,15 @@ fn test_rebase_invalid() { // Rebase onto descendant with -r let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-r", "a", "-d", "b"]); - insta::assert_snapshot!(stderr, @"Error: Cannot rebase 247da0ddee3d onto descendant 18db23c14b3c -"); + insta::assert_snapshot!(stderr, @r###" + Error: Cannot rebase 247da0ddee3d onto descendant 18db23c14b3c + "###); // Rebase onto descendant with -s let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-s", "a", "-d", "b"]); - insta::assert_snapshot!(stderr, @"Error: Cannot rebase 247da0ddee3d onto descendant 18db23c14b3c -"); + insta::assert_snapshot!(stderr, @r###" + Error: Cannot rebase 247da0ddee3d onto descendant 18db23c14b3c + "###); } #[test] @@ -99,8 +101,9 @@ fn test_rebase_branch() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-b", "c", "-d", "e"]); - insta::assert_snapshot!(stdout, @"Rebased 3 commits -"); + insta::assert_snapshot!(stdout, @r###" + Rebased 3 commits + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-T", "branches"]); insta::assert_snapshot!(stdout, @r###" o d diff --git a/tests/test_restore_command.rs b/tests/test_restore_command.rs index 74c8c55b7..d84a0d687 100644 --- a/tests/test_restore_command.rs +++ b/tests/test_restore_command.rs @@ -49,8 +49,9 @@ fn test_restore() { Added 1 files, modified 0 files, removed 2 files "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); - insta::assert_snapshot!(stdout, @"R file2 -"); + insta::assert_snapshot!(stdout, @r###" + R file2 + "###); // Can restore into other revision test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -95,8 +96,9 @@ fn test_restore() { Added 0 files, modified 1 files, removed 1 files "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); - insta::assert_snapshot!(stdout, @"R file1 -"); + insta::assert_snapshot!(stdout, @r###" + R file1 + "###); } #[test] @@ -117,8 +119,9 @@ fn test_restore_interactive() { // Nothing happens if we make no changes std::fs::write(&edit_script, "").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["restore", "-i"]); - insta::assert_snapshot!(stdout, @"Nothing changed. -"); + insta::assert_snapshot!(stdout, @r###" + Nothing changed. + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); insta::assert_snapshot!(stdout, @r###" R file1 @@ -129,8 +132,9 @@ fn test_restore_interactive() { // Nothing happens if the diff-editor exits with an error std::fs::write(&edit_script, "rm file2\0fail").unwrap(); let stderr = test_env.jj_cmd_failure(&repo_path, &["restore", "-i"]); - insta::assert_snapshot!(stderr, @"Error: Failed to edit diff: The diff tool exited with a non-zero code -"); + insta::assert_snapshot!(stderr, @r###" + Error: Failed to edit diff: The diff tool exited with a non-zero code + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); insta::assert_snapshot!(stdout, @r###" R file1 @@ -147,8 +151,9 @@ fn test_restore_interactive() { Added 0 files, modified 1 files, removed 1 files "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); - insta::assert_snapshot!(stdout, @"R file1 -"); + insta::assert_snapshot!(stdout, @r###" + R file1 + "###); // Can make unrelated edits test_env.jj_cmd_success(&repo_path, &["undo"]); diff --git a/tests/test_sparse_command.rs b/tests/test_sparse_command.rs index 2b447e4be..be6fa2080 100644 --- a/tests/test_sparse_command.rs +++ b/tests/test_sparse_command.rs @@ -29,13 +29,15 @@ fn test_sparse_manage_patterns() { // By default, all files are tracked let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--list"]); - insta::assert_snapshot!(stdout, @". -"); + insta::assert_snapshot!(stdout, @r###" + . + "###); // Can stop tracking all files let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--remove", "."]); - insta::assert_snapshot!(stdout, @"Added 0 files, modified 0 files, removed 3 files -"); + insta::assert_snapshot!(stdout, @r###" + Added 0 files, modified 0 files, removed 3 files + "###); // The list is now empty let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--list"]); insta::assert_snapshot!(stdout, @""); @@ -54,8 +56,9 @@ fn test_sparse_manage_patterns() { // Can `--add` a few files let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--add", "file2", "--add", "file3"]); - insta::assert_snapshot!(stdout, @"Added 2 files, modified 0 files, removed 0 files -"); + insta::assert_snapshot!(stdout, @r###" + Added 2 files, modified 0 files, removed 0 files + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--list"]); insta::assert_snapshot!(stdout, @r###" file2 @@ -72,33 +75,39 @@ fn test_sparse_manage_patterns() { "sparse", "--add", "file1", "--remove", "file2", "--remove", "file3", ], ); - insta::assert_snapshot!(stdout, @"Added 1 files, modified 0 files, removed 2 files -"); + insta::assert_snapshot!(stdout, @r###" + Added 1 files, modified 0 files, removed 2 files + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--list"]); - insta::assert_snapshot!(stdout, @"file1 -"); + insta::assert_snapshot!(stdout, @r###" + file1 + "###); assert!(repo_path.join("file1").exists()); assert!(!repo_path.join("file2").exists()); assert!(!repo_path.join("file3").exists()); // Can use `--clear` and `--add` let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--clear", "--add", "file2"]); - insta::assert_snapshot!(stdout, @"Added 1 files, modified 0 files, removed 1 files -"); + insta::assert_snapshot!(stdout, @r###" + Added 1 files, modified 0 files, removed 1 files + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--list"]); - insta::assert_snapshot!(stdout, @"file2 -"); + insta::assert_snapshot!(stdout, @r###" + file2 + "###); assert!(!repo_path.join("file1").exists()); assert!(repo_path.join("file2").exists()); assert!(!repo_path.join("file3").exists()); // Can reset back to all files let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--reset"]); - insta::assert_snapshot!(stdout, @"Added 2 files, modified 0 files, removed 0 files -"); + insta::assert_snapshot!(stdout, @r###" + Added 2 files, modified 0 files, removed 0 files + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["sparse", "--list"]); - insta::assert_snapshot!(stdout, @". -"); + insta::assert_snapshot!(stdout, @r###" + . + "###); assert!(repo_path.join("file1").exists()); assert!(repo_path.join("file2").exists()); assert!(repo_path.join("file3").exists()); diff --git a/tests/test_split_command.rs b/tests/test_split_command.rs index bc25aef29..74cfa0905 100644 --- a/tests/test_split_command.rs +++ b/tests/test_split_command.rs @@ -49,8 +49,9 @@ fn test_split() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s", "-r", "@-"]); - insta::assert_snapshot!(stdout, @"A file2 -"); + insta::assert_snapshot!(stdout, @r###" + A file2 + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["diff", "-s"]); insta::assert_snapshot!(stdout, @r###" A file1 diff --git a/tests/test_squash_command.rs b/tests/test_squash_command.rs index 193439c17..a49fc6e99 100644 --- a/tests/test_squash_command.rs +++ b/tests/test_squash_command.rs @@ -42,8 +42,9 @@ fn test_squash() { // Squashes the working copy into the parent by default let stdout = test_env.jj_cmd_success(&repo_path, &["squash"]); - insta::assert_snapshot!(stdout, @"Working copy now at: 6ca29c9d2e7c -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: 6ca29c9d2e7c + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-T", template]); insta::assert_snapshot!(stdout, @r###" @ 6ca29c9d2e7c b c @@ -51,8 +52,9 @@ fn test_squash() { o 000000000000 "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); // Can squash a given commit into its parent test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -68,11 +70,13 @@ fn test_squash() { o 000000000000 "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); - insta::assert_snapshot!(stdout, @"c -"); + insta::assert_snapshot!(stdout, @r###" + c + "###); // Cannot squash a merge commit (because it's unclear which parent it should go // into) @@ -95,15 +99,17 @@ fn test_squash() { o 000000000000 "###); let stderr = test_env.jj_cmd_failure(&repo_path, &["squash", "-r", "e"]); - insta::assert_snapshot!(stderr, @"Error: Cannot squash merge commits -"); + insta::assert_snapshot!(stderr, @r###" + Error: Cannot squash merge commits + "###); // Can squash into a merge commit test_env.jj_cmd_success(&repo_path, &["co", "e"]); std::fs::write(repo_path.join("file1"), "e\n").unwrap(); let stdout = test_env.jj_cmd_success(&repo_path, &["squash"]); - insta::assert_snapshot!(stdout, @"Working copy now at: 626d78245205 -"); + insta::assert_snapshot!(stdout, @r###" + Working copy now at: 626d78245205 + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-T", template]); insta::assert_snapshot!(stdout, @r###" @ 626d78245205 @@ -117,8 +123,9 @@ fn test_squash() { o 000000000000 "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "e"]); - insta::assert_snapshot!(stdout, @"e -"); + insta::assert_snapshot!(stdout, @r###" + e + "###); } #[test] @@ -164,8 +171,9 @@ fn test_squash_partial() { o 000000000000 "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "a"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); // Can squash only some changes in interactive mode test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -183,17 +191,21 @@ fn test_squash_partial() { o 000000000000 "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "a"]); - insta::assert_snapshot!(stdout, @"a -"); + insta::assert_snapshot!(stdout, @r###" + a + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "a"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); // Can squash only some changes in non-interactive mode test_env.jj_cmd_success(&repo_path, &["undo"]); @@ -212,15 +224,19 @@ fn test_squash_partial() { o 000000000000 "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "a"]); - insta::assert_snapshot!(stdout, @"a -"); + insta::assert_snapshot!(stdout, @r###" + a + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "a"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1", "-r", "b"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file2", "-r", "b"]); - insta::assert_snapshot!(stdout, @"b -"); + insta::assert_snapshot!(stdout, @r###" + b + "###); } diff --git a/tests/test_untrack_command.rs b/tests/test_untrack_command.rs index 6bc54ac95..061923641 100644 --- a/tests/test_untrack_command.rs +++ b/tests/test_untrack_command.rs @@ -40,8 +40,9 @@ fn test_untrack() { // Errors out when not run at the head operation let stderr = test_env.jj_cmd_failure(&repo_path, &["untrack", "file1", "--at-op", "@-"]); - insta::assert_snapshot!(stderr.replace("jj.exe", "jj"), @"Error: Refusing to commit working copy (maybe because you're using --at-op) -"); + insta::assert_snapshot!(stderr.replace("jj.exe", "jj"), @r###" + Error: Refusing to commit working copy (maybe because you're using --at-op) + "###); // Errors out when no path is specified let stderr = test_env.jj_cmd_failure(&repo_path, &["untrack"]); insta::assert_snapshot!(stderr.replace("jj.exe", "jj"), @r###" @@ -114,6 +115,7 @@ fn test_untrack_sparse() { let stdout = test_env.jj_cmd_success(&repo_path, &["untrack", "file2"]); insta::assert_snapshot!(stdout, @""); let stdout = test_env.jj_cmd_success(&repo_path, &["files"]); - insta::assert_snapshot!(stdout, @"file1 -"); + insta::assert_snapshot!(stdout, @r###" + file1 + "###); } diff --git a/tests/test_workspaces.rs b/tests/test_workspaces.rs index a83c5e3c8..c3ad40da0 100644 --- a/tests/test_workspaces.rs +++ b/tests/test_workspaces.rs @@ -32,8 +32,9 @@ fn test_workspaces_add_second_workspace() { test_env.jj_cmd_success(&main_path, &["close", "-m", "initial"]); let stdout = test_env.jj_cmd_success(&main_path, &["workspace", "list"]); - insta::assert_snapshot!(stdout, @"default: 988d8c1dca7e -"); + insta::assert_snapshot!(stdout, @r###" + default: 988d8c1dca7e + "###); let stdout = test_env.jj_cmd_success( &main_path, @@ -141,13 +142,15 @@ fn test_workspaces_forget() { // When listing workspaces, only the secondary workspace shows up let stdout = test_env.jj_cmd_success(&main_path, &["workspace", "list"]); - insta::assert_snapshot!(stdout, @"secondary: 39a6d6c6f295 -"); + insta::assert_snapshot!(stdout, @r###" + secondary: 39a6d6c6f295 + "###); // `jj status` tells us that there's no working copy here let stdout = test_env.jj_cmd_success(&main_path, &["st"]); - insta::assert_snapshot!(stdout, @"No working copy -"); + insta::assert_snapshot!(stdout, @r###" + No working copy + "###); // The old checkout doesn't get an "@" in the log output // TODO: We should abandon the empty working copy commit @@ -164,14 +167,16 @@ fn test_workspaces_forget() { // Revision "@" cannot be used let stderr = test_env.jj_cmd_failure(&main_path, &["log", "-r", "@"]); - insta::assert_snapshot!(stderr, @r###"Error: Revision "@" doesn't exist -"###); + insta::assert_snapshot!(stderr, @r###" + Error: Revision "@" doesn't exist + "###); // Try to add back the workspace // TODO: We should make this just add it back instead of failing let stderr = test_env.jj_cmd_failure(&main_path, &["workspace", "add", "."]); - insta::assert_snapshot!(stderr, @"Error: Workspace already exists -"); + insta::assert_snapshot!(stderr, @r###" + Error: Workspace already exists + "###); // Forget the secondary workspace let stdout = test_env.jj_cmd_success(&main_path, &["workspace", "forget", "secondary"]);