ok/jj
1
0
Fork 0
forked from mirrors/jj

tests: re-run with insta crate version b9d99e87065b

This commit is contained in:
Martin von Zweigbergk 2022-04-28 16:32:18 -07:00 committed by Martin von Zweigbergk
parent 57ba9a9409
commit 8ef00a3498
16 changed files with 270 additions and 180 deletions

View file

@ -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
"###);
}

View file

@ -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();

View file

@ -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]

View file

@ -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
"###);
}

View file

@ -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]

View file

@ -50,7 +50,8 @@ 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");
@ -117,7 +118,8 @@ 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");
@ -145,7 +147,8 @@ 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");

View file

@ -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 {

View file

@ -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,16 +53,20 @@ 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"]);
@ -75,10 +80,12 @@ 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
"###);
}

View file

@ -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"]);

View file

@ -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

View file

@ -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"]);

View file

@ -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());

View file

@ -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

View file

@ -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
"###);
}

View file

@ -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
"###);
}

View file

@ -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"]);