Skip to content

Commit

Permalink
rebase: add tests of rebasing empty sets
Browse files Browse the repository at this point in the history
As these tests show, we sometimes print an error when trying to rebase
an empty set, and sometimes we don't say anything at all. It seems to
me like we should say "Nothing changed" in all of these cases.
  • Loading branch information
martinvonz committed Dec 11, 2024
1 parent c2b8619 commit 942d105
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cli/tests/test_rebase_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,29 @@ fn test_rebase_invalid() {
"###);
}

#[test]
fn test_rebase_empty_sets() {
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");

create_commit(&test_env, &repo_path, "a", &[]);
create_commit(&test_env, &repo_path, "b", &["a"]);

// TODO: Make all of these say "Nothing changed"?
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-r=none()", "-d=b"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-s=none()", "-d=b"]);
insta::assert_snapshot!(stderr, @r###"Error: Revset "none()" didn't resolve to any revisions"###);
let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-b=none()", "-d=b"]);
insta::assert_snapshot!(stderr, @r###"Error: Revset "none()" didn't resolve to any revisions"###);
// Empty because "b..a" is empty
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-b=a", "-d=b"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
}

#[test]
fn test_rebase_bookmark() {
let test_env = TestEnvironment::default();
Expand Down

0 comments on commit 942d105

Please sign in to comment.