Skip to content

Commit 5c57c6b

Browse files
committed
Add test for file metadata handling with extreme values
1 parent dfb7b0f commit 5c57c6b

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
# The largest-possible date for Ext4, nanos are special there, but ont usually on other filesystems
5+
touch -d "2446-05-10 22:38:55.111111111" future
6+
# The smallest-possible date for Ext4, nanos are special there, but ont usually on other filesystems
7+
touch -d "1901-12-13 20:45:52.222222222" past
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
file_metadata.tar.xz

gix-index/tests/index/fs.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
mod metadata {
2+
use gix_index::fs::Metadata;
3+
4+
#[test]
5+
fn from_path_no_follow() -> crate::Result {
6+
let root = gix_testtools::scripted_fixture_read_only_standalone("file_metadata.sh")?;
7+
8+
// For now, don't assert on the values of the metadata as these depends on the filesystem,
9+
// which might truncate it, or fail entirely.
10+
for filename in ["future", "past"] {
11+
let meta = Metadata::from_path_no_follow(&root.join(filename))?;
12+
assert!(meta.created().is_some());
13+
assert!(meta.modified().is_some());
14+
assert_eq!(meta.len(), 0);
15+
}
16+
Ok(())
17+
}
18+
}

gix-index/tests/index/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use gix_hash::ObjectId;
55
mod access;
66
mod entry;
77
mod file;
8+
mod fs;
89
mod init;
910

1011
pub fn hex_to_id(hex: &str) -> ObjectId {

0 commit comments

Comments
 (0)