@@ -1395,15 +1395,13 @@ fn test_mv_errors() {
13951395 // $ at.mkdir dir && at.touch file
13961396 // $ mv dir file
13971397 // err == mv: cannot overwrite non-directory 'file' with directory 'dir'
1398- assert ! (
1399- !scene
1400- . ucmd( )
1401- . arg( dir)
1402- . arg( file_a)
1403- . fails( )
1404- . stderr_str( )
1405- . is_empty( )
1406- ) ;
1398+ assert ! ( !scene
1399+ . ucmd( )
1400+ . arg( dir)
1401+ . arg( file_a)
1402+ . fails( )
1403+ . stderr_str( )
1404+ . is_empty( ) ) ;
14071405}
14081406
14091407#[ test]
@@ -1468,17 +1466,15 @@ fn test_mv_interactive_error() {
14681466 // $ at.mkdir dir && at.touch file
14691467 // $ mv -i dir file
14701468 // err == mv: cannot overwrite non-directory 'file' with directory 'dir'
1471- assert ! (
1472- !scene
1473- . ucmd( )
1474- . arg( "-i" )
1475- . arg( dir)
1476- . arg( file_a)
1477- . pipe_in( "y" )
1478- . fails( )
1479- . stderr_str( )
1480- . is_empty( )
1481- ) ;
1469+ assert ! ( !scene
1470+ . ucmd( )
1471+ . arg( "-i" )
1472+ . arg( dir)
1473+ . arg( file_a)
1474+ . pipe_in( "y" )
1475+ . fails( )
1476+ . stderr_str( )
1477+ . is_empty( ) ) ;
14821478}
14831479
14841480#[ test]
@@ -1603,17 +1599,13 @@ fn test_mv_seen_file() {
16031599 let result = ts. ucmd ( ) . arg ( "a/f" ) . arg ( "b/f" ) . arg ( "c" ) . fails ( ) ;
16041600
16051601 #[ cfg( not( unix) ) ]
1606- assert ! (
1607- result
1608- . stderr_str( )
1609- . contains( "will not overwrite just-created 'c\\ f' with 'b/f'" )
1610- ) ;
1602+ assert ! ( result
1603+ . stderr_str( )
1604+ . contains( "will not overwrite just-created 'c\\ f' with 'b/f'" ) ) ;
16111605 #[ cfg( unix) ]
1612- assert ! (
1613- result
1614- . stderr_str( )
1615- . contains( "will not overwrite just-created 'c/f' with 'b/f'" )
1616- ) ;
1606+ assert ! ( result
1607+ . stderr_str( )
1608+ . contains( "will not overwrite just-created 'c/f' with 'b/f'" ) ) ;
16171609
16181610 // a/f has been moved into c/f
16191611 assert ! ( at. plus( "c" ) . join( "f" ) . exists( ) ) ;
@@ -1637,17 +1629,13 @@ fn test_mv_seen_multiple_files_to_directory() {
16371629
16381630 let result = ts. ucmd ( ) . arg ( "a/f" ) . arg ( "b/f" ) . arg ( "b/g" ) . arg ( "c" ) . fails ( ) ;
16391631 #[ cfg( not( unix) ) ]
1640- assert ! (
1641- result
1642- . stderr_str( )
1643- . contains( "will not overwrite just-created 'c\\ f' with 'b/f'" )
1644- ) ;
1632+ assert ! ( result
1633+ . stderr_str( )
1634+ . contains( "will not overwrite just-created 'c\\ f' with 'b/f'" ) ) ;
16451635 #[ cfg( unix) ]
1646- assert ! (
1647- result
1648- . stderr_str( )
1649- . contains( "will not overwrite just-created 'c/f' with 'b/f'" )
1650- ) ;
1636+ assert ! ( result
1637+ . stderr_str( )
1638+ . contains( "will not overwrite just-created 'c/f' with 'b/f'" ) ) ;
16511639
16521640 assert ! ( !at. plus( "a" ) . join( "f" ) . exists( ) ) ;
16531641 assert ! ( at. plus( "b" ) . join( "f" ) . exists( ) ) ;
@@ -1785,7 +1773,7 @@ fn test_move_should_not_fallback_to_copy() {
17851773#[ cfg( target_os = "linux" ) ]
17861774mod inter_partition_copying {
17871775 use std:: fs:: { read_to_string, set_permissions, write} ;
1788- use std:: os:: unix:: fs:: { PermissionsExt , symlink } ;
1776+ use std:: os:: unix:: fs:: { symlink , PermissionsExt } ;
17891777 use tempfile:: TempDir ;
17901778 use uutests:: util:: TestScenario ;
17911779 use uutests:: util_name;
@@ -2518,7 +2506,7 @@ fn test_mv_exchange_verbose() {
25182506 . arg ( "file1" )
25192507 . arg ( "file2" )
25202508 . succeeds ( )
2521- . stdout_contains ( "file1 <-> file2" ) ;
2509+ . stdout_contains ( "exchanged ' file1' <-> ' file2' " ) ;
25222510}
25232511
25242512#[ test]
@@ -2625,3 +2613,26 @@ fn test_mv_exchange_not_supported() {
26252613 . fails ( )
26262614 . stderr_contains ( "--exchange is not supported on this system" ) ;
26272615}
2616+
2617+ #[ test]
2618+ #[ cfg( target_os = "linux" ) ]
2619+ fn test_mv_exchange_with_no_target_directory ( ) {
2620+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2621+
2622+ at. mkdir ( "d1" ) ;
2623+ at. mkdir ( "d2" ) ;
2624+ at. write ( "d1/file1" , "content1" ) ;
2625+ at. write ( "d2/file2" , "content2" ) ;
2626+
2627+ ucmd. arg ( "-T" )
2628+ . arg ( "--exchange" )
2629+ . arg ( "d1" )
2630+ . arg ( "d2" )
2631+ . succeeds ( ) ;
2632+
2633+ // after exchange, d1 should contain file2 and d2 should contain file1
2634+ assert_eq ! ( at. read( "d1/file2" ) , "content2" ) ;
2635+ assert_eq ! ( at. read( "d2/file1" ) , "content1" ) ;
2636+ assert ! ( !at. file_exists( "d1/file1" ) ) ;
2637+ assert ! ( !at. file_exists( "d2/file2" ) ) ;
2638+ }
0 commit comments