Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions tests/by-util/test_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand All @@ -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);
}
Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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);
}
Expand Down
Loading