Skip to content

Commit 15866ba

Browse files
committed
fix mtime in tests
1 parent 8e3a1e7 commit 15866ba

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/tests/ontoenv_test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ macro_rules! setup {
4040
}
4141

4242
copy_file(&source_path, &dest_path).expect(format!("Failed to copy file from {} to {}", source_path.display(), dest_path.display()).as_str());
43+
// modify the 'last modified' time to the current time. For some reason, in the
44+
// temp_dir environment, the copy_file doesn't update the last modified time.
45+
// TODO: we are using a workaround here, but it would be better to fix the copy_file
46+
// function or figure out why the last modified time is not updated.
47+
let current_time = std::time::SystemTime::now();
48+
let dest_file = std::fs::File::open(&dest_path)
49+
.expect(format!("Failed to open file {}", dest_path.display()).as_str());
50+
dest_file.set_modified(current_time)
51+
.expect(format!("Failed to set modified time for file {}", dest_path.display()).as_str());
4352
)*
4453

4554
// Check the contents of the temporary directory

0 commit comments

Comments
 (0)