@@ -525,6 +525,69 @@ fn test_cp_archive() {
525525}
526526
527527
528+ #[ test]
529+ fn test_cp_archive_recursive ( ) {
530+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
531+ let cwd = env:: current_dir ( ) . unwrap ( ) ;
532+
533+ // creates
534+ // dir/1
535+ // dir/1.link => dir/1
536+ // dir/2
537+ // dir/2.link => dir/2
538+
539+ let file_1 = at. subdir . join ( TEST_COPY_TO_FOLDER ) . join ( "1" ) ;
540+ let file_1_link = at. subdir . join ( TEST_COPY_TO_FOLDER ) . join ( "1.link" ) ;
541+ let file_2 = at. subdir . join ( TEST_COPY_TO_FOLDER ) . join ( "2" ) ;
542+ let file_2_link = at. subdir . join ( TEST_COPY_TO_FOLDER ) . join ( "2.link" ) ;
543+
544+ at. touch ( & file_1. to_string_lossy ( ) ) ;
545+ at. touch ( & file_2. to_string_lossy ( ) ) ;
546+
547+ // Change the cwd to have a correct symlink
548+ assert ! ( env:: set_current_dir( & at. subdir. join( TEST_COPY_TO_FOLDER ) ) . is_ok( ) ) ;
549+
550+ #[ cfg( not( windows) ) ]
551+ {
552+ let _r = fs:: symlink ( "1" , & file_1_link) ;
553+ let _r = fs:: symlink ( "2" , & file_2_link) ;
554+ }
555+ #[ cfg( windows) ]
556+ {
557+ let _r = symlink_file ( "1" , & file_1_link) ;
558+ let _r = symlink_file ( "2" , & file_2_link) ;
559+ }
560+ // Back to the initial cwd (breaks the other tests)
561+ assert ! ( env:: set_current_dir( & cwd) . is_ok( ) ) ;
562+
563+ let resultg = ucmd
564+ . arg ( "--archive" )
565+ . arg ( TEST_COPY_TO_FOLDER )
566+ . arg ( TEST_COPY_TO_FOLDER_NEW )
567+ . run ( ) ;
568+
569+ let scene2 = TestScenario :: new ( "ls" ) ;
570+ let result = scene2. cmd ( "ls" ) . arg ( "-al" ) . arg ( & at. subdir . join ( TEST_COPY_TO_FOLDER ) ) . run ( ) ;
571+
572+ println ! ( "ls dest {}" , result. stdout) ;
573+
574+ let scene2 = TestScenario :: new ( "ls" ) ;
575+ let result = scene2. cmd ( "ls" ) . arg ( "-al" ) . arg ( & at. subdir . join ( TEST_COPY_TO_FOLDER_NEW ) ) . run ( ) ;
576+
577+ println ! ( "ls dest {}" , result. stdout) ;
578+ assert ! ( at. file_exists( & at. subdir. join( TEST_COPY_TO_FOLDER_NEW ) . join( "1.link" ) . to_string_lossy( ) ) ) ;
579+ assert ! ( at. file_exists( & at. subdir. join( TEST_COPY_TO_FOLDER_NEW ) . join( "2.link" ) . to_string_lossy( ) ) ) ;
580+ assert ! ( at. file_exists( & at. subdir. join( TEST_COPY_TO_FOLDER_NEW ) . join( "1" ) . to_string_lossy( ) ) ) ;
581+ assert ! ( at. file_exists( & at. subdir. join( TEST_COPY_TO_FOLDER_NEW ) . join( "2" ) . to_string_lossy( ) ) ) ;
582+
583+ assert ! ( at. is_symlink( & at. subdir. join( TEST_COPY_TO_FOLDER_NEW ) . join( "1.link" ) . to_string_lossy( ) ) ) ;
584+ assert ! ( at. is_symlink( & at. subdir. join( TEST_COPY_TO_FOLDER_NEW ) . join( "2.link" ) . to_string_lossy( ) ) ) ;
585+
586+ // fails for now
587+ assert ! ( resultg. success) ;
588+ }
589+
590+
528591#[ test]
529592fn test_cp_preserve_timestamps ( ) {
530593 let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
0 commit comments