mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 19:56:17 +00:00
touch: add --ref as an alias (#2641)
This commit is contained in:
parent
2170d81621
commit
ed258e3c9c
2 changed files with 18 additions and 9 deletions
|
@ -6,6 +6,7 @@ use self::touch::filetime::{self, FileTime};
|
|||
extern crate time;
|
||||
|
||||
use crate::common::util::*;
|
||||
use std::fs::remove_file;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn get_file_times(at: &AtPath, path: &str) -> (FileTime, FileTime) {
|
||||
|
@ -323,7 +324,8 @@ fn test_touch_no_dereference() {
|
|||
|
||||
#[test]
|
||||
fn test_touch_reference() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let scenario = TestScenario::new("touch");
|
||||
let (at, mut _ucmd) = (scenario.fixtures.clone(), scenario.ucmd());
|
||||
let file_a = "test_touch_reference_a";
|
||||
let file_b = "test_touch_reference_b";
|
||||
let start_of_year = str_to_filetime("%Y%m%d%H%M", "201501010000");
|
||||
|
@ -331,15 +333,21 @@ fn test_touch_reference() {
|
|||
at.touch(file_a);
|
||||
set_file_times(&at, file_a, start_of_year, start_of_year);
|
||||
assert!(at.file_exists(file_a));
|
||||
for &opt in &["-r", "--ref", "--reference"] {
|
||||
scenario
|
||||
.ccmd("touch")
|
||||
.args(&[opt, file_a, file_b])
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
ucmd.args(&["-r", file_a, file_b]).succeeds().no_stderr();
|
||||
assert!(at.file_exists(file_b));
|
||||
|
||||
assert!(at.file_exists(file_b));
|
||||
|
||||
let (atime, mtime) = get_file_times(&at, file_b);
|
||||
assert_eq!(atime, mtime);
|
||||
assert_eq!(atime, start_of_year);
|
||||
assert_eq!(mtime, start_of_year);
|
||||
let (atime, mtime) = get_file_times(&at, file_b);
|
||||
assert_eq!(atime, mtime);
|
||||
assert_eq!(atime, start_of_year);
|
||||
assert_eq!(mtime, start_of_year);
|
||||
let _ = remove_file(file_b);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue