Debian Codegraph @

cli/tests/test_bisect_command.rs

raw
1 // Copyright 2022 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 testutils::TestResult;
16
17 use crate::common::CommandOutput;
18 use crate::common::TestEnvironment;
19 use crate::common::TestWorkDir;
20 use crate::common::create_commit;
21 use crate::common::fake_bisector_path;
22
23 #[test]
24 fn test_bisect_run_missing_command() {
25 let test_env = TestEnvironment::default();
26 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
27 let work_dir = test_env.work_dir("repo");
28
29 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=.."]), @"
30 ------- stderr -------
31 Error: Command argument is required
32 [EOF]
33 [exit status: 2]
34 ");
35 }
36
37 #[test]
38 fn test_bisect_run_empty_revset() -> TestResult {
39 let mut test_env = TestEnvironment::default();
40 let bisector_path = fake_bisector_path();
41 let bisection_script = test_env.set_up_fake_bisector();
42 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
43 let work_dir = test_env.work_dir("repo");
44
45 std::fs::write(&bisection_script, ["fail"].join("\0"))?;
46 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=none()", &bisector_path]), @"
47 Search complete. To discard any revisions created during search, run:
48 jj op restore f63ee16f9553
49 [EOF]
50 ------- stderr -------
51 Error: Could not find the first bad revision. Was the input range empty?
52 [EOF]
53 [exit status: 1]
54 ");
55 Ok(())
56 }
57
58 #[test]
59 fn test_bisect_run() -> TestResult {
60 let mut test_env = TestEnvironment::default();
61 let bisector_path = fake_bisector_path();
62 let bisection_script = test_env.set_up_fake_bisector();
63 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
64 let work_dir = test_env.work_dir("repo");
65
66 create_commit(&work_dir, "a", &[]);
67 create_commit(&work_dir, "b", &["a"]);
68 create_commit(&work_dir, "c", &["b"]);
69 create_commit(&work_dir, "d", &["c"]);
70 create_commit(&work_dir, "e", &["d"]);
71 create_commit(&work_dir, "f", &["e"]);
72
73 std::fs::write(&bisection_script, ["fail"].join("\0"))?;
74 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", &bisector_path]), @"
75 Bisecting: 5 revisions left to test after this (roughly 3 steps)
76 Now evaluating: royxmykx dffaa0d4 c | c
77 fake-bisector testing commit dffaa0d4daccf6cee70bac3498fae3b3fd5d6b5b
78 The revision is bad.
79
80 Bisecting: 2 revisions left to test after this (roughly 2 steps)
81 Now evaluating: rlvkpnrz 7d980be7 a | a
82 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
83 The revision is bad.
84
85 Search complete. To discard any revisions created during search, run:
86 jj op restore e953363a3d33
87 The first bad revision is: rlvkpnrz 7d980be7 a | a
88 [EOF]
89 ------- stderr -------
90 Working copy (@) now at: lylxulpl 68b3a16f (empty) (no description set)
91 Parent commit (@-) : royxmykx dffaa0d4 c | c
92 Added 0 files, modified 0 files, removed 3 files
93 Working copy (@) now at: rsllmpnm 5f328bc5 (empty) (no description set)
94 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
95 Added 0 files, modified 0 files, removed 2 files
96 [EOF]
97 ");
98 insta::assert_snapshot!(get_log_output(&work_dir), @"
99 @ rsllmpnmslon 5f328bc5fde0 '' files:
100 │ ○ kmkuslswpqwq 8b67af288466 'f' files: f
101 │ ○ znkkpsqqskkl 62d30ded0e8f 'e' files: e
102 │ ○ vruxwmqvtpmx 86be7a223919 'd' files: d
103 │ ○ royxmykxtrkr dffaa0d4dacc 'c' files: c
104 │ ○ zsuskulnrvyr 123b4d91f6e5 'b' files: b
105 ├─╯
106 ○ rlvkpnrzqnoo 7d980be7a1d4 'a' files: a
107 ◆ zzzzzzzzzzzz 000000000000 '' files:
108 [EOF]
109 ");
110
111 // Try with legacy command argument
112 std::fs::write(&bisection_script, ["fail"].join("\0"))?;
113 // Testing only stderr to avoid a variable op id in the stdout.
114 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", "--command", &bisector_path]).success().stderr, @"
115 Warning: `--command` is deprecated; use positional arguments instead: `jj bisect run --range=... -- $FAKE_BISECTOR_PATH`
116 Working copy (@) now at: nkmrtpmo 1601f7b4 (empty) (no description set)
117 Parent commit (@-) : royxmykx dffaa0d4 c | c
118 Added 2 files, modified 0 files, removed 0 files
119 Working copy (@) now at: ruktrxxu fb9e625c (empty) (no description set)
120 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
121 Added 0 files, modified 0 files, removed 2 files
122 [EOF]
123 ");
124 insta::assert_snapshot!(get_log_output(&work_dir), @"
125 @ ruktrxxusqqp fb9e625c1023 '' files:
126 │ ○ kmkuslswpqwq 8b67af288466 'f' files: f
127 │ ○ znkkpsqqskkl 62d30ded0e8f 'e' files: e
128 │ ○ vruxwmqvtpmx 86be7a223919 'd' files: d
129 │ ○ royxmykxtrkr dffaa0d4dacc 'c' files: c
130 │ ○ zsuskulnrvyr 123b4d91f6e5 'b' files: b
131 ├─╯
132 ○ rlvkpnrzqnoo 7d980be7a1d4 'a' files: a
133 ◆ zzzzzzzzzzzz 000000000000 '' files:
134 [EOF]
135 ");
136 Ok(())
137 }
138
139 #[test]
140 fn test_bisect_run_find_first_good() {
141 let mut test_env = TestEnvironment::default();
142 let bisector_path = fake_bisector_path();
143 test_env.set_up_fake_bisector();
144 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
145 let work_dir = test_env.work_dir("repo");
146
147 create_commit(&work_dir, "a", &[]);
148 create_commit(&work_dir, "b", &["a"]);
149 create_commit(&work_dir, "c", &["b"]);
150 create_commit(&work_dir, "d", &["c"]);
151 create_commit(&work_dir, "e", &["d"]);
152 create_commit(&work_dir, "f", &["e"]);
153
154 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", "--find-good", &bisector_path]), @"
155 Bisecting: 5 revisions left to test after this (roughly 3 steps)
156 Now evaluating: royxmykx dffaa0d4 c | c
157 fake-bisector testing commit dffaa0d4daccf6cee70bac3498fae3b3fd5d6b5b
158 The revision is good.
159
160 Bisecting: 2 revisions left to test after this (roughly 2 steps)
161 Now evaluating: rlvkpnrz 7d980be7 a | a
162 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
163 The revision is good.
164
165 Search complete. To discard any revisions created during search, run:
166 jj op restore e953363a3d33
167 The first good revision is: rlvkpnrz 7d980be7 a | a
168 [EOF]
169 ------- stderr -------
170 Working copy (@) now at: lylxulpl 68b3a16f (empty) (no description set)
171 Parent commit (@-) : royxmykx dffaa0d4 c | c
172 Added 0 files, modified 0 files, removed 3 files
173 Working copy (@) now at: rsllmpnm 5f328bc5 (empty) (no description set)
174 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
175 Added 0 files, modified 0 files, removed 2 files
176 [EOF]
177 ");
178 insta::assert_snapshot!(get_log_output(&work_dir), @"
179 @ rsllmpnmslon 5f328bc5fde0 '' files:
180 │ ○ kmkuslswpqwq 8b67af288466 'f' files: f
181 │ ○ znkkpsqqskkl 62d30ded0e8f 'e' files: e
182 │ ○ vruxwmqvtpmx 86be7a223919 'd' files: d
183 │ ○ royxmykxtrkr dffaa0d4dacc 'c' files: c
184 │ ○ zsuskulnrvyr 123b4d91f6e5 'b' files: b
185 ├─╯
186 ○ rlvkpnrzqnoo 7d980be7a1d4 'a' files: a
187 ◆ zzzzzzzzzzzz 000000000000 '' files:
188 [EOF]
189 ");
190 }
191
192 #[test]
193 fn test_bisect_run_missing_bisector() {
194 let test_env = TestEnvironment::default();
195 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
196 let work_dir = test_env.work_dir("repo");
197
198 create_commit(&work_dir, "a", &[]);
199 create_commit(&work_dir, "b", &["a"]);
200 create_commit(&work_dir, "c", &["b"]);
201 create_commit(&work_dir, "d", &["c"]);
202 create_commit(&work_dir, "e", &["d"]);
203 create_commit(&work_dir, "f", &["e"]);
204
205 let output = work_dir.run_jj(["bisect", "run", "--range=..", "nonexistent"]);
206 if cfg!(unix) {
207 insta::assert_snapshot!(output, @r"
208 Bisecting: 5 revisions left to test after this (roughly 3 steps)
209 Now evaluating: royxmykx dffaa0d4 c | c
210 [EOF]
211 ------- stderr -------
212 Working copy (@) now at: lylxulpl 68b3a16f (empty) (no description set)
213 Parent commit (@-) : royxmykx dffaa0d4 c | c
214 Added 0 files, modified 0 files, removed 3 files
215 Error: Failed to run evaluation command
216 Caused by: No such file or directory (os error 2)
217 [EOF]
218 [exit status: 1]
219 ");
220 } else if cfg!(windows) {
221 insta::assert_snapshot!(output, @"
222 Bisecting: 5 revisions left to test after this (roughly 3 steps)
223 Now evaluating: royxmykx dffaa0d4 c | c
224 [EOF]
225 ------- stderr -------
226 Working copy (@) now at: lylxulpl 68b3a16f (empty) (no description set)
227 Parent commit (@-) : royxmykx dffaa0d4 c | c
228 Added 0 files, modified 0 files, removed 3 files
229 Error: Failed to run evaluation command
230 Caused by: program not found
231 [EOF]
232 [exit status: 1]
233 ");
234 }
235 }
236
237 #[test]
238 fn test_bisect_run_with_args() {
239 let mut test_env = TestEnvironment::default();
240 let bisector_path = fake_bisector_path();
241 test_env.set_up_fake_bisector();
242 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
243 let work_dir = test_env.work_dir("repo");
244
245 create_commit(&work_dir, "a", &[]);
246 create_commit(&work_dir, "b", &["a"]);
247 create_commit(&work_dir, "c", &["b"]);
248 create_commit(&work_dir, "d", &["c"]);
249 create_commit(&work_dir, "e", &["d"]);
250 create_commit(&work_dir, "f", &["e"]);
251
252 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", "--find-good", "--", &bisector_path, "--require-file=c"]), @"
253 Bisecting: 5 revisions left to test after this (roughly 3 steps)
254 Now evaluating: royxmykx dffaa0d4 c | c
255 fake-bisector testing commit dffaa0d4daccf6cee70bac3498fae3b3fd5d6b5b
256 The revision is good.
257
258 Bisecting: 2 revisions left to test after this (roughly 2 steps)
259 Now evaluating: rlvkpnrz 7d980be7 a | a
260 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
261 The revision is bad.
262
263 Bisecting: 1 revisions left to test after this (roughly 1 steps)
264 Now evaluating: zsuskuln 123b4d91 b | b
265 fake-bisector testing commit 123b4d91f6e5e39bfed39bae3bacf9380dc79078
266 The revision is bad.
267
268 Search complete. To discard any revisions created during search, run:
269 jj op restore e953363a3d33
270 The first good revision is: royxmykx dffaa0d4 c | c
271 [EOF]
272 ------- stderr -------
273 Working copy (@) now at: lylxulpl 68b3a16f (empty) (no description set)
274 Parent commit (@-) : royxmykx dffaa0d4 c | c
275 Added 0 files, modified 0 files, removed 3 files
276 Working copy (@) now at: rsllmpnm 5f328bc5 (empty) (no description set)
277 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
278 Added 0 files, modified 0 files, removed 2 files
279 Working copy (@) now at: zqsquwqt 042badd2 (empty) (no description set)
280 Parent commit (@-) : zsuskuln 123b4d91 b | b
281 Added 1 files, modified 0 files, removed 0 files
282 [EOF]
283 ");
284 insta::assert_snapshot!(get_log_output(&work_dir), @"
285 @ zqsquwqtrvts 042badd28c1d '' files:
286 │ ○ kmkuslswpqwq 8b67af288466 'f' files: f
287 │ ○ znkkpsqqskkl 62d30ded0e8f 'e' files: e
288 │ ○ vruxwmqvtpmx 86be7a223919 'd' files: d
289 │ ○ royxmykxtrkr dffaa0d4dacc 'c' files: c
290 ├─╯
291 ○ zsuskulnrvyr 123b4d91f6e5 'b' files: b
292 ○ rlvkpnrzqnoo 7d980be7a1d4 'a' files: a
293 ◆ zzzzzzzzzzzz 000000000000 '' files:
294 [EOF]
295 ");
296 }
297
298 #[test]
299 fn test_bisect_run_crash() -> TestResult {
300 let mut test_env = TestEnvironment::default();
301 let bisector_path = fake_bisector_path();
302 let bisection_script = test_env.set_up_fake_bisector();
303 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
304 let work_dir = test_env.work_dir("repo");
305
306 create_commit(&work_dir, "a", &[]);
307 create_commit(&work_dir, "b", &["a"]);
308 create_commit(&work_dir, "c", &["b"]);
309 create_commit(&work_dir, "d", &["c"]);
310 create_commit(&work_dir, "e", &["d"]);
311 create_commit(&work_dir, "f", &["e"]);
312
313 // bisector crash is equivalent to a failure
314 std::fs::write(&bisection_script, ["crash"].join("\0"))?;
315 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", &bisector_path]), @"
316 Bisecting: 5 revisions left to test after this (roughly 3 steps)
317 Now evaluating: royxmykx dffaa0d4 c | c
318 fake-bisector testing commit dffaa0d4daccf6cee70bac3498fae3b3fd5d6b5b
319 The revision is bad.
320
321 Bisecting: 2 revisions left to test after this (roughly 2 steps)
322 Now evaluating: rlvkpnrz 7d980be7 a | a
323 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
324 The revision is bad.
325
326 Search complete. To discard any revisions created during search, run:
327 jj op restore e953363a3d33
328 The first bad revision is: rlvkpnrz 7d980be7 a | a
329 [EOF]
330 ------- stderr -------
331 Working copy (@) now at: lylxulpl 68b3a16f (empty) (no description set)
332 Parent commit (@-) : royxmykx dffaa0d4 c | c
333 Added 0 files, modified 0 files, removed 3 files
334 Working copy (@) now at: rsllmpnm 5f328bc5 (empty) (no description set)
335 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
336 Added 0 files, modified 0 files, removed 2 files
337 [EOF]
338 ");
339 Ok(())
340 }
341
342 #[test]
343 fn test_bisect_run_abort() -> TestResult {
344 let mut test_env = TestEnvironment::default();
345 let bisector_path = fake_bisector_path();
346 let bisection_script = test_env.set_up_fake_bisector();
347 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
348 let work_dir = test_env.work_dir("repo");
349
350 create_commit(&work_dir, "a", &[]);
351 create_commit(&work_dir, "b", &["a"]);
352 create_commit(&work_dir, "c", &["b"]);
353
354 // stop immediately on failure
355 std::fs::write(&bisection_script, ["abort"].join("\0"))?;
356 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", &bisector_path]), @"
357 Bisecting: 2 revisions left to test after this (roughly 2 steps)
358 Now evaluating: rlvkpnrz 7d980be7 a | a
359 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
360 Evaluation command returned 127 (command not found) - aborting bisection.
361
362 Search complete. To discard any revisions created during search, run:
363 jj op restore 121d6ca6dd74
364 [EOF]
365 ------- stderr -------
366 Working copy (@) now at: vruxwmqv 538d9e7f (empty) (no description set)
367 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
368 Added 0 files, modified 0 files, removed 2 files
369 Error: Bisection aborted
370 [EOF]
371 [exit status: 1]
372 ");
373 Ok(())
374 }
375
376 #[test]
377 fn test_bisect_run_skip() -> TestResult {
378 let mut test_env = TestEnvironment::default();
379 let bisector_path = fake_bisector_path();
380 let bisection_script = test_env.set_up_fake_bisector();
381 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
382 let work_dir = test_env.work_dir("repo");
383
384 // head (b) is assumed to be bad, even though all revisions are skipped
385 create_commit(&work_dir, "a", &[]);
386 create_commit(&work_dir, "b", &["a"]);
387
388 std::fs::write(&bisection_script, ["skip"].join("\0"))?;
389 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", &bisector_path]), @"
390 Bisecting: 1 revisions left to test after this (roughly 1 steps)
391 Now evaluating: rlvkpnrz 7d980be7 a | a
392 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
393 It could not be determined if the revision is good or bad.
394
395 Search complete. To discard any revisions created during search, run:
396 jj op restore d67fa84fce93
397 The first bad revisions are:
398 zsuskuln 123b4d91 b | b
399 These revisions may also be bad, but couldn't be evaluated:
400 rlvkpnrz 7d980be7 a | a
401 [EOF]
402 ------- stderr -------
403 Working copy (@) now at: royxmykx 2144134b (empty) (no description set)
404 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
405 Added 0 files, modified 0 files, removed 1 files
406 [EOF]
407 ");
408 Ok(())
409 }
410
411 #[test]
412 fn test_bisect_run_multiple_results() {
413 let mut test_env = TestEnvironment::default();
414 let bisector_path = fake_bisector_path();
415 test_env.set_up_fake_bisector();
416 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
417 let work_dir = test_env.work_dir("repo");
418
419 // heads (d and b) are assumed to be bad
420 create_commit(&work_dir, "a", &[]);
421 create_commit(&work_dir, "b", &["a"]);
422 create_commit(&work_dir, "c", &["a"]);
423 create_commit(&work_dir, "d", &["c"]);
424
425 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=a|b|c|d", &bisector_path]), @"
426 Bisecting: 2 revisions left to test after this (roughly 2 steps)
427 Now evaluating: rlvkpnrz 7d980be7 a | a
428 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
429 The revision is good.
430
431 Bisecting: 1 revisions left to test after this (roughly 1 steps)
432 Now evaluating: royxmykx 991a7501 c | c
433 fake-bisector testing commit 991a7501d660abb6a80e8b00f77c651d76d845d7
434 The revision is good.
435
436 Search complete. To discard any revisions created during search, run:
437 jj op restore 8feef1d21060
438 The first bad revisions are:
439 vruxwmqv a2dbb1aa d | d
440 zsuskuln 123b4d91 b | b
441 [EOF]
442 ------- stderr -------
443 Working copy (@) now at: znkkpsqq 1b117fe7 (empty) (no description set)
444 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
445 Added 0 files, modified 0 files, removed 2 files
446 Working copy (@) now at: uuzqqzqu 6bf5f5e7 (empty) (no description set)
447 Parent commit (@-) : royxmykx 991a7501 c | c
448 Added 1 files, modified 0 files, removed 0 files
449 [EOF]
450 ");
451 }
452
453 #[test]
454 fn test_bisect_run_write_file() -> TestResult {
455 let mut test_env = TestEnvironment::default();
456 let bisector_path = fake_bisector_path();
457 let bisection_script = test_env.set_up_fake_bisector();
458 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
459 let work_dir = test_env.work_dir("repo");
460
461 create_commit(&work_dir, "a", &[]);
462 create_commit(&work_dir, "b", &["a"]);
463 create_commit(&work_dir, "c", &["b"]);
464 create_commit(&work_dir, "d", &["c"]);
465 create_commit(&work_dir, "e", &["d"]);
466
467 std::fs::write(
468 &bisection_script,
469 ["write new-file\nsome contents", "fail"].join("\0"),
470 )?;
471 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", &bisector_path]), @"
472 Bisecting: 4 revisions left to test after this (roughly 3 steps)
473 Now evaluating: zsuskuln 123b4d91 b | b
474 fake-bisector testing commit 123b4d91f6e5e39bfed39bae3bacf9380dc79078
475 The revision is bad.
476
477 Bisecting: 1 revisions left to test after this (roughly 1 steps)
478 Now evaluating: rlvkpnrz 7d980be7 a | a
479 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
480 The revision is bad.
481
482 Search complete. To discard any revisions created during search, run:
483 jj op restore 6518dc3e2579
484 The first bad revision is: rlvkpnrz 7d980be7 a | a
485 [EOF]
486 ------- stderr -------
487 Working copy (@) now at: kmkuslsw 17e2a972 (empty) (no description set)
488 Parent commit (@-) : zsuskuln 123b4d91 b | b
489 Added 0 files, modified 0 files, removed 3 files
490 Working copy (@) now at: msksykpx 2f6e298d (empty) (no description set)
491 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
492 Added 0 files, modified 0 files, removed 2 files
493 [EOF]
494 ");
495 insta::assert_snapshot!(get_log_output(&work_dir), @"
496 @ msksykpxotkr 891aeb03b623 '' files: new-file
497 │ ○ kmkuslswpqwq 2bae881dc1bc '' files: new-file
498 │ │ ○ znkkpsqqskkl 62d30ded0e8f 'e' files: e
499 │ │ ○ vruxwmqvtpmx 86be7a223919 'd' files: d
500 │ │ ○ royxmykxtrkr dffaa0d4dacc 'c' files: c
501 │ ├─╯
502 │ ○ zsuskulnrvyr 123b4d91f6e5 'b' files: b
503 ├─╯
504 ○ rlvkpnrzqnoo 7d980be7a1d4 'a' files: a
505 ◆ zzzzzzzzzzzz 000000000000 '' files:
506 [EOF]
507 ");
508
509 // No concurrent operations
510 let output = work_dir.run_jj(["op", "log", "-n=5", "-T=description"]);
511 insta::assert_snapshot!(output, @"
512 @ snapshot working copy
513 ○ Updated to revision 7d980be7a1d499e4d316ab4c01242885032f7eaf for bisection
514 ○ snapshot working copy
515 ○ Updated to revision 123b4d91f6e5e39bfed39bae3bacf9380dc79078 for bisection
516 ○ create bookmark e pointing to commit 62d30ded0e8fdf8cf87012e6223898b97977fc8e
517 [EOF]
518 ");
519 Ok(())
520 }
521
522 #[test]
523 fn test_bisect_run_jj_command() -> TestResult {
524 let mut test_env = TestEnvironment::default();
525 let bisector_path = fake_bisector_path();
526 let bisection_script = test_env.set_up_fake_bisector();
527 test_env.run_jj_in(".", ["git", "init", "repo"]).success();
528 let work_dir = test_env.work_dir("repo");
529
530 create_commit(&work_dir, "a", &[]);
531 create_commit(&work_dir, "b", &["a"]);
532 create_commit(&work_dir, "c", &["b"]);
533 create_commit(&work_dir, "d", &["c"]);
534 create_commit(&work_dir, "e", &["d"]);
535
536 std::fs::write(&bisection_script, ["jj new -mtesting", "fail"].join("\0"))?;
537 insta::assert_snapshot!(work_dir.run_jj(["bisect", "run", "--range=..", &bisector_path]), @"
538 Bisecting: 4 revisions left to test after this (roughly 3 steps)
539 Now evaluating: zsuskuln 123b4d91 b | b
540 fake-bisector testing commit 123b4d91f6e5e39bfed39bae3bacf9380dc79078
541 The revision is bad.
542
543 Bisecting: 1 revisions left to test after this (roughly 1 steps)
544 Now evaluating: rlvkpnrz 7d980be7 a | a
545 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
546 The revision is bad.
547
548 Search complete. To discard any revisions created during search, run:
549 jj op restore 6518dc3e2579
550 The first bad revision is: rlvkpnrz 7d980be7 a | a
551 [EOF]
552 ------- stderr -------
553 Working copy (@) now at: kmkuslsw 17e2a972 (empty) (no description set)
554 Parent commit (@-) : zsuskuln 123b4d91 b | b
555 Added 0 files, modified 0 files, removed 3 files
556 Working copy (@) now at: kmkuslsw/0 55b3b4a8 (divergent) (empty) testing
557 Parent commit (@-) : kmkuslsw/1 17e2a972 (divergent) (empty) (no description set)
558 Working copy (@) now at: msksykpx 2f6e298d (empty) (no description set)
559 Parent commit (@-) : rlvkpnrz 7d980be7 a | a
560 Added 0 files, modified 0 files, removed 1 files
561 Working copy (@) now at: kmkuslsw/0 2f80658c (divergent) (empty) testing
562 Parent commit (@-) : msksykpx 2f6e298d (empty) (no description set)
563 [EOF]
564 ");
565 insta::assert_snapshot!(get_log_output(&work_dir), @"
566 @ kmkuslswpqwq 2f80658c4d26 'testing' files:
567 ○ msksykpxotkr 2f6e298d59bd '' files:
568 │ ○ kmkuslswpqwq 55b3b4a8b253 'testing' files:
569 │ ○ kmkuslswpqwq 17e2a9721f61 '' files:
570 │ │ ○ znkkpsqqskkl 62d30ded0e8f 'e' files: e
571 │ │ ○ vruxwmqvtpmx 86be7a223919 'd' files: d
572 │ │ ○ royxmykxtrkr dffaa0d4dacc 'c' files: c
573 │ ├─╯
574 │ ○ zsuskulnrvyr 123b4d91f6e5 'b' files: b
575 ├─╯
576 ○ rlvkpnrzqnoo 7d980be7a1d4 'a' files: a
577 ◆ zzzzzzzzzzzz 000000000000 '' files:
578 [EOF]
579 ");
580
581 // No concurrent operations
582 let output = work_dir.run_jj(["op", "log", "-n=5", "-T=description"]);
583 insta::assert_snapshot!(output, @"
584 @ new empty commit
585 ○ Updated to revision 7d980be7a1d499e4d316ab4c01242885032f7eaf for bisection
586 ○ new empty commit
587 ○ Updated to revision 123b4d91f6e5e39bfed39bae3bacf9380dc79078 for bisection
588 ○ create bookmark e pointing to commit 62d30ded0e8fdf8cf87012e6223898b97977fc8e
589 [EOF]
590 ");
591 Ok(())
592 }
593
594 #[must_use]
595 fn get_log_output(work_dir: &TestWorkDir) -> CommandOutput {
596 let template = r#"separate(" ",
597 change_id.short(),
598 commit_id.short(),
599 "'" ++ description.first_line() ++ "'",
600 "files: " ++ diff.files().map(|e| e.path())
601 )"#;
602 work_dir.run_jj(["log", "-T", template])
603 }