Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jj split tests to show what happens to branches #3420

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions cli/tests/test_split_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::path::Path;
use crate::common::TestEnvironment;

fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
let template = r#"separate(" ", change_id.short(), empty, description)"#;
let template = r#"separate(" ", change_id.short(), empty, description, local_branches)"#;
test_env.jj_cmd_success(cwd, &["log", "-T", template])
}

Expand Down Expand Up @@ -213,6 +213,11 @@ fn test_split_with_default_description() {

std::fs::write(workspace_path.join("file1"), "foo\n").unwrap();
std::fs::write(workspace_path.join("file2"), "bar\n").unwrap();

// Create a branch pointing to the commit. It will be moved to the second
// commit after the split.
test_env.jj_cmd_ok(&workspace_path, &["branch", "create", "test_branch"]);

let edit_script = test_env.set_up_fake_editor();
std::fs::write(
edit_script,
Expand All @@ -239,7 +244,7 @@ JJ: Lines starting with "JJ: " (like this one) will be removed.
);
assert!(!test_env.env_root().join("editor2").exists());
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ rlvkpnrzqnoo false
@ kkmpptxzrspx false test_branch
◉ qpvuntsmwlqt false TESTED=TODO
◉ zzzzzzzzzzzz true
"###);
Expand All @@ -256,6 +261,15 @@ fn test_split_siblings_no_descendants() {

std::fs::write(workspace_path.join("file1"), "foo\n").unwrap();
std::fs::write(workspace_path.join("file2"), "bar\n").unwrap();

// Create a branch pointing to the commit. It will be moved to the second
// commit after the split.
test_env.jj_cmd_ok(&workspace_path, &["branch", "create", "test_branch"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ qpvuntsmwlqt false test_branch
◉ zzzzzzzzzzzz true
"###);

let edit_script = test_env.set_up_fake_editor();
std::fs::write(
edit_script,
Expand All @@ -282,7 +296,7 @@ JJ: Lines starting with "JJ: " (like this one) will be removed.
);
assert!(!test_env.env_root().join("editor2").exists());
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ rlvkpnrzqnoo false
@ zsuskulnrvyr false test_branch
│ ◉ qpvuntsmwlqt false TESTED=TODO
├─╯
◉ zzzzzzzzzzzz true
Expand Down