Skip to content

Commit b68ba95

Browse files
committed
Improve has_granular_times() as suggested in review
- Decrease n=100 to n=50, which remains decisively enough on all platforms being tested (including Windows). - Slightly streamline iteration by cloning the first iterator so its values need not be collected into a `Vec`. - Make it so that if the CI+macOS high-granularity assertion ever fails, the message explains the significance of the failing `assert_eq!` comparison. (This condenses an added comment and makes it an assertion message instead.) Suggested-by: Sebastian Thiel <[email protected]>
1 parent d1b0d1c commit b68ba95

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

gix-fs/tests/fs/snapshot.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ fn do_journey() -> Result<(), Box<dyn std::error::Error>> {
4949
}
5050

5151
fn has_granular_times(root: &Path) -> std::io::Result<bool> {
52-
let n = 100;
52+
let n = 50;
5353

54-
let names: Vec<_> = (0..n).map(|i| format!("{i:03}")).collect();
55-
for name in &names {
56-
std::fs::write(root.join(name), name)?;
54+
let names = (0..n).map(|i| format!("{i:03}"));
55+
for name in names.clone() {
56+
std::fs::write(root.join(&name), name)?;
5757
}
5858
let mut times = Vec::new();
5959
for name in names {
@@ -64,9 +64,12 @@ fn has_granular_times(root: &Path) -> std::io::Result<bool> {
6464

6565
// This could be wrongly false if a filesystem has very precise timings yet is ridiculously
6666
// fast. Then the `journey` test wouldn't run, though it could. But that's OK, and unlikely.
67-
// However, for now, on CI, on macOS only, we assert the expectation of high granularity.
6867
if cfg!(target_os = "macos") && is_ci::cached() {
69-
assert_eq!(times.len(), n);
68+
assert_eq!(
69+
times.len(),
70+
n,
71+
"should have very granular timestamps at least on macOS on CI"
72+
);
7073
}
7174
Ok(times.len() == n)
7275
}

0 commit comments

Comments
 (0)