mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
sync: make fail like GNU - tests/misc/sync.sh
This commit is contained in:
parent
e523a56dab
commit
fc1c7755b9
2 changed files with 12 additions and 0 deletions
|
@ -169,6 +169,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.map(|v| v.map(ToString::to_string).collect())
|
.map(|v| v.map(ToString::to_string).collect())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
if matches.is_present(options::DATA) && files.is_empty() {
|
||||||
|
return Err(USimpleError::new(1, "--data needs at least one argument"));
|
||||||
|
}
|
||||||
|
|
||||||
for f in &files {
|
for f in &files {
|
||||||
if !Path::new(&f).exists() {
|
if !Path::new(&f).exists() {
|
||||||
return Err(USimpleError::new(
|
return Err(USimpleError::new(
|
||||||
|
|
|
@ -44,3 +44,11 @@ fn test_sync_no_existing_files() {
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_contains("cannot stat");
|
.stderr_contains("cannot stat");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_sync_data_but_not_file() {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--data")
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("sync: --data needs at least one argument");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue