Debian Codegraph @

cli/tests/test_arrange_command.rs

raw
1 // Copyright 2026 The Jujutsu Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 use crate::common::TestEnvironment;
16 use crate::common::create_commit;
17
18 #[test]
19 fn test_arrange_bad_revisions() {
20 let test_env = TestEnvironment::default();
21 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
22 let work_dir = test_env.work_dir("repo");
23
24 create_commit(&work_dir, "a", &[]);
25 create_commit(&work_dir, "b", &["a"]);
26 create_commit(&work_dir, "c", &["b"]);
27
28 let output = work_dir.run_jj(["arrange", "none()"]);
29 insta::assert_snapshot!(output, @r"
30 ------- stderr -------
31 No revisions to arrange.
32 [EOF]
33 ");
34
35 // Multiple ways to specify what to arrange:
36 // Positional arguments
37 let output = work_dir.run_jj(["arrange", "a", "c"]);
38 insta::assert_snapshot!(output, @r"
39 ------- stderr -------
40 Error: Cannot arrange revset with gaps in.
41 Hint: Revision 123b4d91f6e5 would need to be in the set.
42 [EOF]
43 [exit status: 1]
44 ");
45
46 // Option arguments
47 let output = work_dir.run_jj(["arrange", "-r=a", "-r=c"]);
48 insta::assert_snapshot!(output, @r"
49 ------- stderr -------
50 Error: Cannot arrange revset with gaps in.
51 Hint: Revision 123b4d91f6e5 would need to be in the set.
52 [EOF]
53 [exit status: 1]
54 ");
55
56 // Both
57 let output = work_dir.run_jj(["arrange", "-r=a", "c"]);
58 insta::assert_snapshot!(output, @r"
59 ------- stderr -------
60 Error: Cannot arrange revset with gaps in.
61 Hint: Revision 123b4d91f6e5 would need to be in the set.
62 [EOF]
63 [exit status: 1]
64 ");
65
66 // Configuration value
67 let output = work_dir.run_jj(["arrange", "--config=revsets.arrange='a|c'"]);
68 insta::assert_snapshot!(output, @r"
69 ------- stderr -------
70 Error: Cannot arrange revset with gaps in.
71 Hint: Revision 123b4d91f6e5 would need to be in the set.
72 [EOF]
73 [exit status: 1]
74 ");
75 }