mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
touch: use an ArgGroup for sources and turn macros into functions (#1813)
* touch: use arggroup for sources * tests/touch: add tests for multiple sources * touch: turn macros into functions * test/touch: fmt * touch: constant for the sources ArgGroup
This commit is contained in:
parent
cd4003007f
commit
fd5ec099d0
2 changed files with 67 additions and 37 deletions
|
@ -203,6 +203,53 @@ fn test_touch_set_only_mtime_failed() {
|
|||
ucmd.args(&["-t", "2015010112342", "-m", file]).fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_touch_set_both_time_and_reference() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let ref_file = "test_touch_reference";
|
||||
let file = "test_touch_set_both_time_and_reference";
|
||||
|
||||
let start_of_year = str_to_filetime("%Y%m%d%H%M", "201501010000");
|
||||
|
||||
at.touch(ref_file);
|
||||
set_file_times(&at, ref_file, start_of_year, start_of_year);
|
||||
assert!(at.file_exists(ref_file));
|
||||
|
||||
ucmd.args(&["-t", "2015010112342", "-r", ref_file, file])
|
||||
.fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_touch_set_both_date_and_reference() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let ref_file = "test_touch_reference";
|
||||
let file = "test_touch_set_both_date_and_reference";
|
||||
|
||||
let start_of_year = str_to_filetime("%Y%m%d%H%M", "201501010000");
|
||||
|
||||
at.touch(ref_file);
|
||||
set_file_times(&at, ref_file, start_of_year, start_of_year);
|
||||
assert!(at.file_exists(ref_file));
|
||||
|
||||
ucmd.args(&["-d", "Thu Jan 01 12:34:00 2015", "-r", ref_file, file])
|
||||
.fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_touch_set_both_time_and_date() {
|
||||
let (_at, mut ucmd) = at_and_ucmd!();
|
||||
let file = "test_touch_set_both_time_and_date";
|
||||
|
||||
ucmd.args(&[
|
||||
"-t",
|
||||
"2015010112342",
|
||||
"-d",
|
||||
"Thu Jan 01 12:34:00 2015",
|
||||
file,
|
||||
])
|
||||
.fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_touch_set_only_mtime() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue