@@ -32,6 +32,23 @@ fn test_bisect_run_missing_command() {
3232    " ) ; 
3333} 
3434
35+ #[ test]  
36+ fn  test_bisect_run_empty_revset ( )  { 
37+     let  test_env = TestEnvironment :: default ( ) ; 
38+     test_env. run_jj_in ( "." ,  [ "git" ,  "init" ,  "repo" ] ) . success ( ) ; 
39+     let  work_dir = test_env. work_dir ( "repo" ) ; 
40+ 
41+     insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" ,  "run" ,  "--range=none()" ,  "false" ] ) ,  @r" 
42+     Search complete. To discard any revisions created during search, run: 
43+       jj op restore 8f47435a3990 
44+     [EOF] 
45+     ------- stderr ------- 
46+     Error: Could not find the first bad revision. Was the input range empty? 
47+     [EOF] 
48+     [exit status: 1] 
49+     " ) ; 
50+ } 
51+ 
3552#[ test]  
3653fn  test_bisect_run ( )  { 
3754    let  test_env = TestEnvironment :: default ( ) ; 
@@ -214,6 +231,100 @@ fn test_bisect_run_with_args() {
214231    " ) ; 
215232} 
216233
234+ #[ test]  
235+ fn  test_bisect_run_abort ( )  { 
236+     let  mut  test_env = TestEnvironment :: default ( ) ; 
237+     let  bisector_path = fake_bisector_path ( ) ; 
238+     let  bisection_script = test_env. set_up_fake_bisector ( ) ; 
239+     test_env. run_jj_in ( "." ,  [ "git" ,  "init" ,  "repo" ] ) . success ( ) ; 
240+     let  work_dir = test_env. work_dir ( "repo" ) ; 
241+ 
242+     create_commit ( & work_dir,  "a" ,  & [ ] ) ; 
243+     create_commit ( & work_dir,  "b" ,  & [ "a" ] ) ; 
244+     create_commit ( & work_dir,  "c" ,  & [ "b" ] ) ; 
245+ 
246+     // stop immediately on failure 
247+     std:: fs:: write ( & bisection_script,  [ "abort" ] . join ( "\0 " ) ) . unwrap ( ) ; 
248+     insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" ,  "run" ,  "--range=.." ,  & bisector_path] ) ,  @r" 
249+     Now evaluating: rlvkpnrz 7d980be7 a | a 
250+     fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf 
251+     [EOF] 
252+     ------- stderr ------- 
253+     Working copy  (@) now at: vruxwmqv 538d9e7f (empty) (no description set) 
254+     Parent commit (@-)      : rlvkpnrz 7d980be7 a | a 
255+     Added 0 files, modified 0 files, removed 2 files 
256+     Error: Evaluation command returned 127 (command not found) - aborting bisection. 
257+     [EOF] 
258+     [exit status: 1] 
259+     " ) ; 
260+ } 
261+ 
262+ #[ test]  
263+ fn  test_bisect_run_skip ( )  { 
264+     let  mut  test_env = TestEnvironment :: default ( ) ; 
265+     let  bisector_path = fake_bisector_path ( ) ; 
266+     let  bisection_script = test_env. set_up_fake_bisector ( ) ; 
267+     test_env. run_jj_in ( "." ,  [ "git" ,  "init" ,  "repo" ] ) . success ( ) ; 
268+     let  work_dir = test_env. work_dir ( "repo" ) ; 
269+ 
270+     // head (b) is assumed to be bad, even though all revisions are skipped 
271+     create_commit ( & work_dir,  "a" ,  & [ ] ) ; 
272+     create_commit ( & work_dir,  "b" ,  & [ "a" ] ) ; 
273+ 
274+     std:: fs:: write ( & bisection_script,  [ "skip" ] . join ( "\0 " ) ) . unwrap ( ) ; 
275+     insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" ,  "run" ,  "--range=.." ,  & bisector_path] ) ,  @r" 
276+     Now evaluating: rlvkpnrz 7d980be7 a | a 
277+     fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf 
278+     It could not be determined if the revision is good or bad. 
279+ 
280+     Search complete. To discard any revisions created during search, run: 
281+       jj op restore 9cc40e5398a9 
282+     The first bad revision is: zsuskuln 123b4d91 b | b 
283+     [EOF] 
284+     ------- stderr ------- 
285+     Working copy  (@) now at: royxmykx 2144134b (empty) (no description set) 
286+     Parent commit (@-)      : rlvkpnrz 7d980be7 a | a 
287+     Added 0 files, modified 0 files, removed 1 files 
288+     [EOF] 
289+     " ) ; 
290+ } 
291+ 
292+ #[ test]  
293+ fn  test_bisect_run_multiple_results ( )  { 
294+     let  test_env = TestEnvironment :: default ( ) ; 
295+     test_env. run_jj_in ( "." ,  [ "git" ,  "init" ,  "repo" ] ) . success ( ) ; 
296+     let  work_dir = test_env. work_dir ( "repo" ) ; 
297+ 
298+     // heads (d and b) are assumed to be bad 
299+     create_commit ( & work_dir,  "a" ,  & [ ] ) ; 
300+     create_commit ( & work_dir,  "b" ,  & [ "a" ] ) ; 
301+     create_commit ( & work_dir,  "c" ,  & [ "a" ] ) ; 
302+     create_commit ( & work_dir,  "d" ,  & [ "c" ] ) ; 
303+ 
304+     insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" ,  "run" ,  "--range=a|b|c|d" ,  "true" ] ) ,  @r" 
305+     Now evaluating: rlvkpnrz 7d980be7 a | a 
306+     The revision is good. 
307+ 
308+     Now evaluating: royxmykx 991a7501 c | c 
309+     The revision is good. 
310+ 
311+     Search complete. To discard any revisions created during search, run: 
312+       jj op restore d750de12e02a 
313+     The first bad revisions are: 
314+     vruxwmqv a2dbb1aa d | d 
315+     zsuskuln 123b4d91 b | b 
316+     [EOF] 
317+     ------- stderr ------- 
318+     Working copy  (@) now at: znkkpsqq 1b117fe7 (empty) (no description set) 
319+     Parent commit (@-)      : rlvkpnrz 7d980be7 a | a 
320+     Added 0 files, modified 0 files, removed 2 files 
321+     Working copy  (@) now at: uuzqqzqu 6bf5f5e7 (empty) (no description set) 
322+     Parent commit (@-)      : royxmykx 991a7501 c | c 
323+     Added 1 files, modified 0 files, removed 0 files 
324+     [EOF] 
325+     " ) ; 
326+ } 
327+ 
217328#[ test]  
218329fn  test_bisect_run_write_file ( )  { 
219330    let  mut  test_env = TestEnvironment :: default ( ) ; 
0 commit comments