Merge pull request #9623 from ChrisDryden/cp_coverage

cp: Adding test to cover no dereference when copying symlinks
This commit is contained in:
Daniel Hofstetter 2025-12-10 09:01:26 +01:00 committed by GitHub
commit 47045a2011
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7118,6 +7118,25 @@ fn test_cp_no_dereference_symlink_with_parents() {
assert_eq!(at.resolve_link("x/symlink-to-directory"), "directory");
}
#[test]
#[cfg(unix)]
fn test_cp_recursive_no_dereference_symlink_to_directory() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.mkdir("source_dir");
at.touch("source_dir/file.txt");
at.symlink_file("source_dir", "symlink_to_dir");
// Copy with -r --no-dereference (or -rP): should copy the symlink, not the directory contents
ts.ucmd()
.args(&["-r", "--no-dereference", "symlink_to_dir", "dest"])
.succeeds();
assert!(at.is_symlink("dest"));
assert_eq!(at.resolve_link("dest"), "source_dir");
}
#[test]
#[cfg(unix)]
fn test_cp_recursive_files_ending_in_backslash() {