Tweaked sort test to work on Windows

Windows doesn't have `touch`, but it does have Powershell, which can
also change timestamps. The relevant command is:

$(Get-Item name).lastwritetime=$(Get-Date "MM/DD/YYYY")
This commit is contained in:
Daniel 2019-02-04 15:24:21 -05:00 committed by Pierre Peltier
parent 82bd588a05
commit 39b73daadf

View file

@ -189,6 +189,8 @@ mod tests {
// Create the file;
let path_z = tmp_dir.path().join("zzz");
File::create(&path_z).expect("failed to create file");
#[cfg(unix)]
let success = Command::new("touch")
.arg("-t")
.arg("198511160000")
@ -196,7 +198,18 @@ mod tests {
.status()
.unwrap()
.success();
assert_eq!(true, success, "failed to exec mkfifo");
#[cfg(windows)]
let success = Command::new("powershell")
.arg("-Command")
.arg("$(Get-Item")
.arg(&path_z)
.arg(").lastwritetime=$(Get-Date \"11/16/1985\")")
.status()
.unwrap()
.success();
assert_eq!(true, success, "failed to change file timestamp");
let meta_z = Meta::from_path(&path_z).expect("failed to get meta");
let mut flags = Flags::default();