Repository: pkolaczk/fclones (language: rust)

Issue:
test_partition_respects_isolated_roots depends on filesystem ctime
Automated tests in Nix fail because ctime is not available in the test environment.

```
---- dedupe::test::test_partition_respects_isolated_roots stdout ----
[2022-03-18 13:13:59.583] fclones-e004d9d9a96035e2:  warn: Failed to read creation time of file /build/source/target/test/dedupe/partition/isolated_roots/root2/file_1: creation time is not available for the filesystem
[2022-03-18 13:13:59.583] fclones-e004d9d9a96035e2:  warn: Failed to read creation time of file /build/source/target/test/dedupe/partition/isolated_roots/root1/file_1: creation time is not available for the filesystem
thread 'dedupe::test::test_partition_respects_isolated_roots' panicked at 'called `Result::unwrap()` on an `Err` value: Error { message: "Could not determine files to drop in group with hash 00000000000000000000000000000000 and len 0: Metadata of some files could not be read." }', src/dedupe.rs:1225:68
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

The test: https://github.com/pkolaczk/fclones/blob/9f0a8cb5514e44e6844828a27cf7b155c9761ac0/src/dedupe.rs#L1206

This issue was previously worked around with a condition in the test: https://github.com/pkolaczk/fclones/blob/9f0a8cb5514e44e6844828a27cf7b155c9761ac0/src/dedupe.rs#L1116
```
            if fs::metadata(root).unwrap().created().is_err() {
                // can't run the test because the filesystem doesn't support fetching
                // file creation time
                return;
            }
```

Fixed in commit: https://github.com/pkolaczk/fclones/commit/9503ad18e81feca5f9b546151298f1829ec1144b

Reference to Nix build issue for 0.18: https://github.com/NixOS/nixpkgs/pull/164708

Can we fix this issue with the same guard? Would you like a PR? Thanks!


Discussion / hints:

Fix patch:
diff --git a/src/dedupe.rs b/src/dedupe.rs
index 365f3b5..ea2e725 100644
--- a/src/dedupe.rs
+++ b/src/dedupe.rs
@@ -1219,7 +1219,6 @@ mod test {
             };
 
             let mut config = DedupeConfig::default();
-            config.priority = vec![Priority::Oldest];
             config.isolated_roots = vec![Path::from(&root1), Path::from(&root2)];
 
             let p = partition(group.clone(), &config, &Log::new()).unwrap();
@@ -1227,12 +1226,12 @@ mod test {
             assert!(p
                 .to_drop
                 .iter()
-                .all(|f| f.path.to_path_buf().starts_with(&root1)));
+                .all(|f| f.path.to_path_buf().starts_with(&root2)));
             assert_eq!(p.to_keep.len(), 3);
             assert!(p
                 .to_keep
                 .iter()
-                .all(|f| f.path.to_path_buf().starts_with(&root2)));
+                .all(|f| f.path.to_path_buf().starts_with(&root1)));
         })
     }
 


Test patch: