@@ -303,67 +303,26 @@ fn dangling_symlinks_can_be_created() -> crate::Result {
303
303
return Ok ( ( ) ) ;
304
304
}
305
305
306
- let ( _source_tree, destination, _index, outcome) =
307
- checkout_index_in_tmp_dir ( opts. clone ( ) , "make_dangling_symlink" , None ) ?;
308
- let worktree_files = dir_structure ( & destination) ;
309
- let worktree_files_stripped = stripped_prefix ( & destination, & worktree_files) ;
310
-
311
- assert_eq ! ( worktree_files_stripped, paths( [ "dangling" ] ) ) ;
312
- let symlink_path = & worktree_files[ 0 ] ;
313
- assert ! ( symlink_path
314
- . symlink_metadata( )
315
- . expect( "dangling symlink is on disk" )
316
- . is_symlink( ) ) ;
317
- assert_eq ! ( std:: fs:: read_link( symlink_path) ?, Path :: new( "non-existing-target" ) ) ;
318
- assert ! ( outcome. collisions. is_empty( ) ) ;
319
- Ok ( ( ) )
320
- }
321
-
322
- #[ test]
323
- fn dangling_symlink_to_windows_invalid_target_can_be_created ( ) -> crate :: Result {
324
- let opts = opts_from_probe ( ) ;
325
- if !opts. fs . symlink {
326
- eprintln ! ( "Skipping dangling symlink test on filesystem that doesn't support it" ) ;
327
- return Ok ( ( ) ) ;
328
- }
329
-
330
- let ( _source_tree, destination, _index, outcome) =
331
- checkout_index_in_tmp_dir ( opts. clone ( ) , "make_dangling_symlink_to_windows_invalid" , None ) ?;
332
- let worktree_files = dir_structure ( & destination) ;
333
- let worktree_files_stripped = stripped_prefix ( & destination, & worktree_files) ;
334
-
335
- assert_eq ! ( worktree_files_stripped, paths( [ "dangling-qmarks-symlink" ] ) ) ;
336
- let symlink_path = & worktree_files[ 0 ] ;
337
- assert ! ( symlink_path
338
- . symlink_metadata( )
339
- . expect( "dangling symlink is on disk" )
340
- . is_symlink( ) ) ;
341
- assert_eq ! ( std:: fs:: read_link( symlink_path) ?, Path :: new( "???" ) ) ;
342
- assert ! ( outcome. collisions. is_empty( ) ) ;
343
- Ok ( ( ) )
344
- }
345
-
346
- #[ test]
347
- fn dangling_symlink_to_windows_reserved_target_can_be_created ( ) -> crate :: Result {
348
- let opts = opts_from_probe ( ) ;
349
- if !opts. fs . symlink {
350
- eprintln ! ( "Skipping dangling symlink test on filesystem that doesn't support it" ) ;
351
- return Ok ( ( ) ) ;
306
+ for ( fixture, symlink_name, target_name) in [
307
+ ( "make_dangling_symlink" , "dangling" , "non-existing-target" ) ,
308
+ ( "make_dangling_symlink_to_windows_invalid" , "dangling-qmarks-symlink" , "???" ) ,
309
+ ( "make_dangling_symlink_to_windows_reserved" , "dangling-con-symlink" , "CON" ) ,
310
+ ] {
311
+ let ( _source_tree, destination, _index, outcome) =
312
+ checkout_index_in_tmp_dir ( opts. clone ( ) , fixture, None ) ?;
313
+ let worktree_files = dir_structure ( & destination) ;
314
+ let worktree_files_stripped = stripped_prefix ( & destination, & worktree_files) ;
315
+
316
+ assert_eq ! ( worktree_files_stripped, paths( [ symlink_name] ) ) ;
317
+ let symlink_path = & worktree_files[ 0 ] ;
318
+ assert ! ( symlink_path
319
+ . symlink_metadata( )
320
+ . expect( "dangling symlink is on disk" )
321
+ . is_symlink( ) ) ;
322
+ assert_eq ! ( std:: fs:: read_link( symlink_path) ?, Path :: new( target_name) ) ;
323
+ assert ! ( outcome. collisions. is_empty( ) ) ;
352
324
}
353
325
354
- let ( _source_tree, destination, _index, outcome) =
355
- checkout_index_in_tmp_dir ( opts. clone ( ) , "make_dangling_symlink_to_windows_reserved" , None ) ?;
356
- let worktree_files = dir_structure ( & destination) ;
357
- let worktree_files_stripped = stripped_prefix ( & destination, & worktree_files) ;
358
-
359
- assert_eq ! ( worktree_files_stripped, paths( [ "dangling-con-symlink" ] ) ) ;
360
- let symlink_path = & worktree_files[ 0 ] ;
361
- assert ! ( symlink_path
362
- . symlink_metadata( )
363
- . expect( "dangling symlink is on disk" )
364
- . is_symlink( ) ) ;
365
- assert_eq ! ( std:: fs:: read_link( symlink_path) ?, Path :: new( "CON" ) ) ;
366
- assert ! ( outcome. collisions. is_empty( ) ) ;
367
326
Ok ( ( ) )
368
327
}
369
328
0 commit comments