File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,38 @@ fn test_permission_denied() {
375375 . stderr_is ( "chmod: 'd/no-x/y': Permission denied\n " ) ;
376376}
377377
378+ #[ test]
379+ #[ allow( clippy:: unreadable_literal) ]
380+ fn test_chmod_recursive_correct_exit_code ( ) {
381+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
382+
383+ // create 3 folders to test on
384+ at. mkdir ( "a" ) ;
385+ at. mkdir ( "a/b" ) ;
386+ at. mkdir ( "z" ) ;
387+
388+ // remove read permissions for folder a so the chmod command for a/b fails
389+ let mut perms = at. metadata ( "a" ) . permissions ( ) ;
390+ perms. set_mode ( 0o000 ) ;
391+ set_permissions ( at. plus_as_string ( "a" ) , perms) . unwrap ( ) ;
392+
393+ #[ cfg( not( target_os = "linux" ) ) ]
394+ let err_msg = "chmod: Permission denied\n " ;
395+ #[ cfg( target_os = "linux" ) ]
396+ let err_msg = "chmod: 'a': Permission denied\n " ;
397+
398+ // order of command is a, a/b then c
399+ // command is expected to fail and not just take the last exit code
400+ ucmd. arg ( "-R" )
401+ . arg ( "--verbose" )
402+ . arg ( "a+w" )
403+ . arg ( "a" )
404+ . arg ( "z" )
405+ . umask ( 0 )
406+ . fails ( )
407+ . stderr_is ( err_msg) ;
408+ }
409+
378410#[ test]
379411#[ allow( clippy:: unreadable_literal) ]
380412fn test_chmod_recursive ( ) {
You can’t perform that action at this time.
0 commit comments