@@ -4101,72 +4101,13 @@ fn test_cp_dest_no_permissions() {
41014101 . stderr_contains ( "denied" ) ;
41024102}
41034103
4104- /// Regression test for macOS readonly file behavior (issue #5257, PR #5261)
4105- #[ test]
4106- fn test_cp_readonly_dest_regression ( ) {
4107- let ts = TestScenario :: new ( util_name ! ( ) ) ;
4108- let at = & ts. fixtures ;
4109-
4110- // Batch file operations to reduce I/O overhead
4111- at. write ( "source.txt" , "source content" ) ;
4112- at. write ( "readonly_dest.txt" , "original content" ) ;
4113- at. set_readonly ( "readonly_dest.txt" ) ;
4114-
4115- ts. ucmd ( )
4116- . args ( & [ "source.txt" , "readonly_dest.txt" ] )
4117- . fails ( )
4118- . stderr_contains ( "readonly_dest.txt" )
4119- . stderr_contains ( "denied" ) ;
4120-
4121- assert_eq ! ( at. read( "readonly_dest.txt" ) , "original content" ) ;
4122- }
4123-
4124- /// Test readonly destination behavior with --force flag (should succeed)
4125- #[ cfg( not( windows) ) ]
4126- #[ test]
4127- fn test_cp_readonly_dest_with_force ( ) {
4128- let ts = TestScenario :: new ( util_name ! ( ) ) ;
4129- let at = & ts. fixtures ;
4130-
4131- // Use consistent file operations and batch setup
4132- at. write ( "source.txt" , "source content" ) ;
4133- at. write ( "readonly_dest.txt" , "original content" ) ;
4134- at. set_readonly ( "readonly_dest.txt" ) ;
4135-
4136- ts. ucmd ( )
4137- . args ( & [ "--force" , "source.txt" , "readonly_dest.txt" ] )
4138- . succeeds ( ) ;
4139-
4140- assert_eq ! ( at. read( "readonly_dest.txt" ) , "source content" ) ;
4141- }
4142-
4143- /// Test readonly destination behavior with --remove-destination flag (should succeed)
4144- #[ cfg( not( windows) ) ]
4145- #[ test]
4146- fn test_cp_readonly_dest_with_remove_destination ( ) {
4147- let ts = TestScenario :: new ( util_name ! ( ) ) ;
4148- let at = & ts. fixtures ;
4149-
4150- // Batch file operations for better performance
4151- at. write ( "source.txt" , "source content" ) ;
4152- at. write ( "readonly_dest.txt" , "original content" ) ;
4153- at. set_readonly ( "readonly_dest.txt" ) ;
4154-
4155- ts. ucmd ( )
4156- . args ( & [ "--remove-destination" , "source.txt" , "readonly_dest.txt" ] )
4157- . succeeds ( ) ;
4158-
4159- assert_eq ! ( at. read( "readonly_dest.txt" ) , "source content" ) ;
4160- }
4161-
41624104/// Test readonly destination behavior with reflink options
41634105#[ cfg( any( target_os = "linux" , target_os = "macos" ) ) ]
41644106#[ test]
41654107fn test_cp_readonly_dest_with_reflink ( ) {
41664108 let ts = TestScenario :: new ( util_name ! ( ) ) ;
41674109 let at = & ts. fixtures ;
41684110
4169- // Batch all file setup operations to minimize I/O
41704111 at. write ( "source.txt" , "source content" ) ;
41714112 at. write ( "readonly_dest_auto.txt" , "original content" ) ;
41724113 at. write ( "readonly_dest_always.txt" , "original content" ) ;
@@ -4185,7 +4126,6 @@ fn test_cp_readonly_dest_with_reflink() {
41854126 . fails ( )
41864127 . stderr_contains ( "readonly_dest_always.txt" ) ;
41874128
4188- // Batch verification operations
41894129 assert_eq ! ( at. read( "readonly_dest_auto.txt" ) , "original content" ) ;
41904130 assert_eq ! ( at. read( "readonly_dest_always.txt" ) , "original content" ) ;
41914131}
@@ -4196,7 +4136,6 @@ fn test_cp_readonly_dest_recursive() {
41964136 let ts = TestScenario :: new ( util_name ! ( ) ) ;
41974137 let at = & ts. fixtures ;
41984138
4199- // Batch directory and file creation
42004139 at. mkdir ( "source_dir" ) ;
42014140 at. mkdir ( "dest_dir" ) ;
42024141 at. write ( "source_dir/file.txt" , "source content" ) ;
@@ -4214,7 +4153,6 @@ fn test_cp_readonly_dest_with_existing_file() {
42144153 let ts = TestScenario :: new ( util_name ! ( ) ) ;
42154154 let at = & ts. fixtures ;
42164155
4217- // Batch all file operations to reduce I/O overhead
42184156 at. write ( "source.txt" , "source content" ) ;
42194157 at. write ( "readonly_dest.txt" , "original content" ) ;
42204158 at. write ( "other_file.txt" , "other content" ) ;
@@ -4226,7 +4164,6 @@ fn test_cp_readonly_dest_with_existing_file() {
42264164 . stderr_contains ( "readonly_dest.txt" )
42274165 . stderr_contains ( "denied" ) ;
42284166
4229- // Batch verification operations
42304167 assert_eq ! ( at. read( "readonly_dest.txt" ) , "original content" ) ;
42314168 assert_eq ! ( at. read( "other_file.txt" ) , "other content" ) ;
42324169}
@@ -4237,7 +4174,6 @@ fn test_cp_readonly_source() {
42374174 let ts = TestScenario :: new ( util_name ! ( ) ) ;
42384175 let at = & ts. fixtures ;
42394176
4240- // Batch file operations for better performance
42414177 at. write ( "readonly_source.txt" , "source content" ) ;
42424178 at. write ( "dest.txt" , "dest content" ) ;
42434179 at. set_readonly ( "readonly_source.txt" ) ;
@@ -4255,7 +4191,6 @@ fn test_cp_readonly_source_and_dest() {
42554191 let ts = TestScenario :: new ( util_name ! ( ) ) ;
42564192 let at = & ts. fixtures ;
42574193
4258- // Batch all file setup operations
42594194 at. write ( "readonly_source.txt" , "source content" ) ;
42604195 at. write ( "readonly_dest.txt" , "original content" ) ;
42614196 at. set_readonly ( "readonly_source.txt" ) ;
@@ -4270,44 +4205,6 @@ fn test_cp_readonly_source_and_dest() {
42704205 assert_eq ! ( at. read( "readonly_dest.txt" ) , "original content" ) ;
42714206}
42724207
4273- /// Test macOS-specific clonefile behavior with readonly files
4274- #[ cfg( target_os = "macos" ) ]
4275- #[ test]
4276- fn test_cp_macos_clonefile_readonly ( ) {
4277- let ts = TestScenario :: new ( util_name ! ( ) ) ;
4278- let at = & ts. fixtures ;
4279-
4280- // Batch file operations for consistency
4281- at. write ( "source.txt" , "source content" ) ;
4282- at. write ( "readonly_dest.txt" , "original content" ) ;
4283- at. set_readonly ( "readonly_dest.txt" ) ;
4284-
4285- // On macOS, clonefile should still fail on readonly destination
4286- ts. ucmd ( )
4287- . args ( & [ "source.txt" , "readonly_dest.txt" ] )
4288- . fails ( )
4289- . stderr_contains ( "readonly_dest.txt" )
4290- . stderr_contains ( "denied" ) ;
4291-
4292- // Verify content unchanged
4293- assert_eq ! ( at. read( "readonly_dest.txt" ) , "original content" ) ;
4294- }
4295-
4296- /// Test that the fix doesn't break normal copy operations
4297- #[ test]
4298- fn test_cp_normal_copy_still_works ( ) {
4299- let ts = TestScenario :: new ( util_name ! ( ) ) ;
4300- let at = & ts. fixtures ;
4301-
4302- // Batch file operations for consistency with other tests
4303- at. write ( "source.txt" , "source content" ) ;
4304- at. write ( "dest.txt" , "dest content" ) ;
4305-
4306- ts. ucmd ( ) . args ( & [ "source.txt" , "dest.txt" ] ) . succeeds ( ) ;
4307-
4308- assert_eq ! ( at. read( "dest.txt" ) , "source content" ) ;
4309- }
4310-
43114208#[ test]
43124209#[ cfg( all( unix, not( target_os = "freebsd" ) , not( target_os = "openbsd" ) ) ) ]
43134210fn test_cp_attributes_only ( ) {
0 commit comments