1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

cp: assume --reflink=always on no value (#3992)

* Set reflink to auto by default
This commit is contained in:
Emil Suleymanov 2022-10-03 20:20:55 +02:00 committed by GitHub
parent a437cf0187
commit a7b637b1eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View file

@ -426,6 +426,10 @@ pub fn uu_app<'a>() -> Command<'a> {
.takes_value(true)
.value_name("WHEN")
.overrides_with_all(MODE_ARGS)
.require_equals(true)
.default_missing_value("always")
.value_parser(["auto", "always", "never"])
.min_values(0)
.help("control clone/CoW copies. See below"),
)
.arg(

View file

@ -1334,6 +1334,24 @@ fn test_cp_reflink_auto() {
assert_eq!(at.read(TEST_EXISTING_FILE), "Hello, World!\n");
}
#[test]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
fn test_cp_reflink_none() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd
.arg("--reflink")
.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_EXISTING_FILE)
.run();
if result.succeeded() {
// Check the content of the destination file
assert_eq!(at.read(TEST_EXISTING_FILE), "Hello, World!\n");
} else {
// Older Linux versions do not support cloning.
}
}
#[test]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
fn test_cp_reflink_never() {
@ -1356,7 +1374,7 @@ fn test_cp_reflink_bad() {
.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_EXISTING_FILE)
.fails()
.stderr_contains("invalid argument");
.stderr_contains("error: \"bad\" isn't a valid value for '--reflink[=<WHEN>...]'");
}
#[test]