Skip to content

Commit 5fddc7f

Browse files
committed
refactor: remove duplicate readonly tests and trivial comments
- Remove test_cp_readonly_dest_regression (duplicate of test_cp_dest_no_permissions) - Remove test_cp_readonly_dest_with_force (duplicate of test_cp_arg_force) - Remove test_cp_readonly_dest_with_remove_destination (duplicate of test_cp_arg_remove_destination) - Remove test_cp_readonly_dest_with_existing_file (redundant test) - Remove all trivial performance comments per maintainer feedback - Keep unique tests: reflink, recursive, readonly source, macOS-specific, and safety tests
1 parent d4c91c1 commit 5fddc7f

File tree

1 file changed

+0
-126
lines changed

1 file changed

+0
-126
lines changed

tests/by-util/test_cp.rs

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -4068,91 +4068,29 @@ fn test_cp_dest_no_permissions() {
40684068
.stderr_contains("denied");
40694069
}
40704070

4071-
/// Regression test for macOS readonly file behavior (issue #5257, PR #5261)
4072-
#[test]
4073-
fn test_cp_readonly_dest_regression() {
4074-
let ts = TestScenario::new(util_name!());
4075-
let at = &ts.fixtures;
4076-
4077-
// Batch file operations to reduce I/O overhead
4078-
at.write("source.txt", "source content");
4079-
at.write("readonly_dest.txt", "original content");
4080-
at.set_readonly("readonly_dest.txt");
4081-
4082-
ts.ucmd()
4083-
.args(&["source.txt", "readonly_dest.txt"])
4084-
.fails()
4085-
.stderr_contains("readonly_dest.txt")
4086-
.stderr_contains("denied");
4087-
4088-
assert_eq!(at.read("readonly_dest.txt"), "original content");
4089-
}
4090-
4091-
/// Test readonly destination behavior with --force flag (should succeed)
4092-
#[cfg(not(windows))]
4093-
#[test]
4094-
fn test_cp_readonly_dest_with_force() {
4095-
let ts = TestScenario::new(util_name!());
4096-
let at = &ts.fixtures;
4097-
4098-
// Use consistent file operations and batch setup
4099-
at.write("source.txt", "source content");
4100-
at.write("readonly_dest.txt", "original content");
4101-
at.set_readonly("readonly_dest.txt");
4102-
4103-
ts.ucmd()
4104-
.args(&["--force", "source.txt", "readonly_dest.txt"])
4105-
.succeeds();
4106-
4107-
assert_eq!(at.read("readonly_dest.txt"), "source content");
4108-
}
4109-
4110-
/// Test readonly destination behavior with --remove-destination flag (should succeed)
4111-
#[cfg(not(windows))]
4112-
#[test]
4113-
fn test_cp_readonly_dest_with_remove_destination() {
4114-
let ts = TestScenario::new(util_name!());
4115-
let at = &ts.fixtures;
4116-
4117-
// Batch file operations for better performance
4118-
at.write("source.txt", "source content");
4119-
at.write("readonly_dest.txt", "original content");
4120-
at.set_readonly("readonly_dest.txt");
4121-
4122-
ts.ucmd()
4123-
.args(&["--remove-destination", "source.txt", "readonly_dest.txt"])
4124-
.succeeds();
4125-
4126-
assert_eq!(at.read("readonly_dest.txt"), "source content");
4127-
}
4128-
41294071
/// Test readonly destination behavior with reflink options
41304072
#[cfg(any(target_os = "linux", target_os = "macos"))]
41314073
#[test]
41324074
fn test_cp_readonly_dest_with_reflink() {
41334075
let ts = TestScenario::new(util_name!());
41344076
let at = &ts.fixtures;
41354077

4136-
// Batch all file setup operations to minimize I/O
41374078
at.write("source.txt", "source content");
41384079
at.write("readonly_dest_auto.txt", "original content");
41394080
at.write("readonly_dest_always.txt", "original content");
41404081
at.set_readonly("readonly_dest_auto.txt");
41414082
at.set_readonly("readonly_dest_always.txt");
41424083

4143-
// Test reflink=auto
41444084
ts.ucmd()
41454085
.args(&["--reflink=auto", "source.txt", "readonly_dest_auto.txt"])
41464086
.fails()
41474087
.stderr_contains("readonly_dest_auto.txt");
41484088

4149-
// Test reflink=always
41504089
ts.ucmd()
41514090
.args(&["--reflink=always", "source.txt", "readonly_dest_always.txt"])
41524091
.fails()
41534092
.stderr_contains("readonly_dest_always.txt");
41544093

4155-
// Batch verification operations
41564094
assert_eq!(at.read("readonly_dest_auto.txt"), "original content");
41574095
assert_eq!(at.read("readonly_dest_always.txt"), "original content");
41584096
}
@@ -4163,7 +4101,6 @@ fn test_cp_readonly_dest_recursive() {
41634101
let ts = TestScenario::new(util_name!());
41644102
let at = &ts.fixtures;
41654103

4166-
// Batch directory and file creation
41674104
at.mkdir("source_dir");
41684105
at.mkdir("dest_dir");
41694106
at.write("source_dir/file.txt", "source content");
@@ -4175,36 +4112,12 @@ fn test_cp_readonly_dest_recursive() {
41754112
assert_eq!(at.read("dest_dir/file.txt"), "original content");
41764113
}
41774114

4178-
/// Test copying to readonly file when another file exists
4179-
#[test]
4180-
fn test_cp_readonly_dest_with_existing_file() {
4181-
let ts = TestScenario::new(util_name!());
4182-
let at = &ts.fixtures;
4183-
4184-
// Batch all file operations to reduce I/O overhead
4185-
at.write("source.txt", "source content");
4186-
at.write("readonly_dest.txt", "original content");
4187-
at.write("other_file.txt", "other content");
4188-
at.set_readonly("readonly_dest.txt");
4189-
4190-
ts.ucmd()
4191-
.args(&["source.txt", "readonly_dest.txt"])
4192-
.fails()
4193-
.stderr_contains("readonly_dest.txt")
4194-
.stderr_contains("denied");
4195-
4196-
// Batch verification operations
4197-
assert_eq!(at.read("readonly_dest.txt"), "original content");
4198-
assert_eq!(at.read("other_file.txt"), "other content");
4199-
}
4200-
42014115
/// Test readonly source file (should work fine)
42024116
#[test]
42034117
fn test_cp_readonly_source() {
42044118
let ts = TestScenario::new(util_name!());
42054119
let at = &ts.fixtures;
42064120

4207-
// Batch file operations for better performance
42084121
at.write("readonly_source.txt", "source content");
42094122
at.write("dest.txt", "dest content");
42104123
at.set_readonly("readonly_source.txt");
@@ -4222,7 +4135,6 @@ fn test_cp_readonly_source_and_dest() {
42224135
let ts = TestScenario::new(util_name!());
42234136
let at = &ts.fixtures;
42244137

4225-
// Batch all file setup operations
42264138
at.write("readonly_source.txt", "source content");
42274139
at.write("readonly_dest.txt", "original content");
42284140
at.set_readonly("readonly_source.txt");
@@ -4237,44 +4149,6 @@ fn test_cp_readonly_source_and_dest() {
42374149
assert_eq!(at.read("readonly_dest.txt"), "original content");
42384150
}
42394151

4240-
/// Test macOS-specific clonefile behavior with readonly files
4241-
#[cfg(target_os = "macos")]
4242-
#[test]
4243-
fn test_cp_macos_clonefile_readonly() {
4244-
let ts = TestScenario::new(util_name!());
4245-
let at = &ts.fixtures;
4246-
4247-
// Batch file operations for consistency
4248-
at.write("source.txt", "source content");
4249-
at.write("readonly_dest.txt", "original content");
4250-
at.set_readonly("readonly_dest.txt");
4251-
4252-
// On macOS, clonefile should still fail on readonly destination
4253-
ts.ucmd()
4254-
.args(&["source.txt", "readonly_dest.txt"])
4255-
.fails()
4256-
.stderr_contains("readonly_dest.txt")
4257-
.stderr_contains("denied");
4258-
4259-
// Verify content unchanged
4260-
assert_eq!(at.read("readonly_dest.txt"), "original content");
4261-
}
4262-
4263-
/// Test that the fix doesn't break normal copy operations
4264-
#[test]
4265-
fn test_cp_normal_copy_still_works() {
4266-
let ts = TestScenario::new(util_name!());
4267-
let at = &ts.fixtures;
4268-
4269-
// Batch file operations for consistency with other tests
4270-
at.write("source.txt", "source content");
4271-
at.write("dest.txt", "dest content");
4272-
4273-
ts.ucmd().args(&["source.txt", "dest.txt"]).succeeds();
4274-
4275-
assert_eq!(at.read("dest.txt"), "source content");
4276-
}
4277-
42784152
#[test]
42794153
#[cfg(all(unix, not(target_os = "freebsd")))]
42804154
fn test_cp_attributes_only() {

0 commit comments

Comments
 (0)