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

tests: make fake editor scripts initially empty

I would expect `set_up_fake_[diff_]editor()` to create an empty script
but it turns out they didn't even create the files. That means that
the caller needs to write an empty script to them if they want the
fake editors to not do anything. Let's instead write the empty
scripts, for a less surprising behavior.
This commit is contained in:
Martin von Zweigbergk 2023-01-25 21:14:55 -08:00 committed by Martin von Zweigbergk
parent b9fc6d4203
commit d6622e5d42
5 changed files with 3 additions and 5 deletions

View file

@ -156,6 +156,7 @@ impl TestEnvironment {
.as_bytes(),
);
let edit_script = self.env_root().join("edit_script");
std::fs::write(&edit_script, "").unwrap();
self.add_env_var("EDIT_SCRIPT", edit_script.to_str().unwrap());
edit_script
}
@ -178,6 +179,7 @@ impl TestEnvironment {
.as_bytes(),
);
let edit_script = self.env_root().join("diff_edit_script");
std::fs::write(&edit_script, "").unwrap();
self.add_env_var("DIFF_EDIT_SCRIPT", edit_script.to_str().unwrap());
edit_script
}

View file

@ -184,7 +184,6 @@ fn test_diffedit_old_restore_interactive_tests() {
let edit_script = test_env.set_up_fake_diff_editor();
// Nothing happens if we make no changes
std::fs::write(&edit_script, "").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["diffedit", "--from", "@-"]);
insta::assert_snapshot!(stdout, @r###"
Nothing changed.

View file

@ -198,7 +198,6 @@ fn test_move_partial() {
let edit_script = test_env.set_up_fake_diff_editor();
// If we don't make any changes in the diff-editor, the whole change is moved
std::fs::write(&edit_script, "").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["move", "-i", "--from", "c"]);
insta::assert_snapshot!(stdout, @r###"
Working copy now at: 71b69e433fbc (no description set)

View file

@ -153,7 +153,6 @@ fn test_squash_partial() {
// If we don't make any changes in the diff-editor, the whole change is moved
// into the parent
let edit_script = test_env.set_up_fake_diff_editor();
std::fs::write(&edit_script, "").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["squash", "-r", "b", "-i"]);
insta::assert_snapshot!(stdout, @r###"
Rebased 1 descendant commits

View file

@ -151,7 +151,6 @@ fn test_unsquash_partial() {
// If we don't make any changes in the diff-editor, the whole change is moved
// from the parent
let edit_script = test_env.set_up_fake_diff_editor();
std::fs::write(&edit_script, "").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["unsquash", "-r", "b", "-i"]);
insta::assert_snapshot!(stdout, @r###"
Rebased 1 descendant commits
@ -170,7 +169,7 @@ fn test_unsquash_partial() {
// Can unsquash only some changes in interactive mode
test_env.jj_cmd_success(&repo_path, &["undo"]);
std::fs::write(&edit_script, "reset file1").unwrap();
std::fs::write(edit_script, "reset file1").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["unsquash", "-i"]);
insta::assert_snapshot!(stdout, @r###"
Working copy now at: a8e8fded1021 (no description set)