diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index 5bae6d980c..35c0ddc490 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -4,8 +4,6 @@ // file that was distributed with this source code. // spell-checker:ignore (words) helloworld nodir objdump n'source nconfined testdir -#[cfg(not(target_os = "openbsd"))] -use filetime::FileTime; use std::env::current_exe; use std::fs; #[cfg(target_os = "linux")] @@ -516,7 +514,12 @@ fn test_install_compare_preserve_timestamps() { at.write(source, "data"); at.write(dest, "data"); let old = std::time::SystemTime::UNIX_EPOCH + Duration::from_secs(1_000_000); - filetime::set_file_mtime(at.plus(source), FileTime::from_system_time(old)).unwrap(); + fs::OpenOptions::new() + .write(true) + .open(at.plus(source)) + .unwrap() + .set_modified(old) + .unwrap(); // With --preserve-timestamps, the timestamp difference forces the copy so // the destination ends up with the source's modification time. @@ -725,7 +728,7 @@ fn test_install_copy_then_compare_file() { .no_stderr(); let mut file2_meta = at.metadata(file2); - let before = FileTime::from_last_modification_time(&file2_meta); + let before = file2_meta.modified().unwrap(); scene .ucmd() @@ -736,7 +739,7 @@ fn test_install_copy_then_compare_file() { .no_stderr(); file2_meta = at.metadata(file2); - let after = FileTime::from_last_modification_time(&file2_meta); + let after = file2_meta.modified().unwrap(); assert_eq!(before, after); } @@ -760,7 +763,7 @@ fn test_install_copy_then_compare_file_with_extra_mode() { .no_stderr(); let mut file2_meta = at.metadata(file2); - let before = FileTime::from_last_modification_time(&file2_meta); + let before = file2_meta.modified().unwrap(); sleep(std::time::Duration::from_millis(100)); scene @@ -776,7 +779,7 @@ fn test_install_copy_then_compare_file_with_extra_mode() { ); file2_meta = at.metadata(file2); - let after_install_sticky = FileTime::from_last_modification_time(&file2_meta); + let after_install_sticky = file2_meta.modified().unwrap(); assert_ne!(before, after_install_sticky); @@ -792,7 +795,7 @@ fn test_install_copy_then_compare_file_with_extra_mode() { .no_stderr(); file2_meta = at.metadata(file2); - let after_install_sticky_again = FileTime::from_last_modification_time(&file2_meta); + let after_install_sticky_again = file2_meta.modified().unwrap(); assert_ne!(after_install_sticky, after_install_sticky_again); }