diff --git a/crates/core/tests/integration.rs b/crates/core/tests/integration.rs index 5160acc8..60e34d07 100644 --- a/crates/core/tests/integration.rs +++ b/crates/core/tests/integration.rs @@ -113,20 +113,33 @@ fn test_backup_with_dir_passes(dir_testdata: PathBuf, set_up_repo: Result = repo.list(rustic_core::FileType::Pack)?.collect(); @@ -134,14 +147,26 @@ fn test_backup_with_dir_passes(dir_testdata: PathBuf, set_up_repo: Result = repo.list(rustic_core::FileType::Pack)?.collect(); @@ -166,13 +191,34 @@ fn test_backup_with_tar_gz_passes( let opts = BackupOptions::default().as_path(PathBuf::from_str("test")?); // first backup - let first_backup = repo.backup(&opts, paths, SnapshotFile::default())?; - assert_debug_snapshot!(TestSummary(&first_backup)); - assert_eq!(first_backup.parent, None); + let first_snapshot = repo.backup(&opts, paths, SnapshotFile::default())?; + + #[cfg(windows)] + assert_debug_snapshot!( + "backup-tar-summary-first-windows", + TestSummary(&first_snapshot) + ); + + #[cfg(not(windows))] + assert_debug_snapshot!("backup-tar-summary-first-nix", TestSummary(&first_backup)); + + assert_eq!(first_snapshot.parent, None); + + // // tree of first backup + // // re-read index + // let repo = repo.to_indexed_ids()?; + // let tree = repo.node_from_path(first_snapshot.tree, Path::new("test/tests"))?; + // let tree = repo.get_tree(&tree.subtree.expect("Sub tree"))?; + + // #[cfg(windows)] + // assert_debug_snapshot!("backup-tar-tree-windows", tree); + + // #[cfg(not(windows))] + // assert_debug_snapshot!("backup-tar-tree-nix", tree); // get all snapshots and check them let all_snapshots = repo.get_all_snapshots()?; - assert_eq!(vec![first_backup.clone()], all_snapshots); + assert_eq!(vec![first_snapshot.clone()], all_snapshots); // save list of pack files let packs1: Vec<_> = repo.list(rustic_core::FileType::Pack)?.collect(); @@ -180,14 +226,25 @@ fn test_backup_with_tar_gz_passes( let repo = repo.to_indexed_ids()?; // second backup let second_snapshot = repo.backup(&opts, paths, SnapshotFile::default())?; - assert_debug_snapshot!(TestSummary(&second_snapshot)); - assert_eq!(second_snapshot.parent, Some(first_backup.id)); - assert_eq!(first_backup.tree, second_snapshot.tree); + + #[cfg(windows)] + assert_debug_snapshot!( + "backup-tar-summary-second-windows", + TestSummary(&second_snapshot) + ); + #[cfg(not(windows))] + assert_debug_snapshot!( + "backup-tar-summary-second-nix", + TestSummary(&second_snapshot) + ); + + assert_eq!(second_snapshot.parent, Some(first_snapshot.id)); + assert_eq!(first_snapshot.tree, second_snapshot.tree); // get all snapshots and check them let mut all_snapshots = repo.get_all_snapshots()?; all_snapshots.sort_unstable(); - assert_eq!(vec![first_backup, second_snapshot], all_snapshots); + assert_eq!(vec![first_snapshot, second_snapshot], all_snapshots); // pack files should be unchanged let packs2: Vec<_> = repo.list(rustic_core::FileType::Pack)?.collect(); @@ -212,7 +269,16 @@ fn test_backup_dry_run_with_tar_gz_passes( // dry-run backup let snap_dry_run = repo.backup(&opts, paths, SnapshotFile::default())?; - assert_debug_snapshot!(TestSummary(&snap_dry_run)); + + #[cfg(windows)] + assert_debug_snapshot!( + "dryrun-tar-summary-first-windows", + TestSummary(&snap_dry_run) + ); + + #[cfg(not(windows))] + assert_debug_snapshot!("dryrun-tar-summary-first-nix", TestSummary(&snap_dry_run)); + // check that repo is still empty let snaps = repo.get_all_snapshots()?; assert_eq!(snaps.len(), 0); @@ -225,12 +291,33 @@ fn test_backup_dry_run_with_tar_gz_passes( assert_eq!(snap_dry_run.tree, first_snapshot.tree); let packs: Vec<_> = repo.list(rustic_core::FileType::Pack)?.collect(); + // // tree of first backup + // // re-read index + // let repo = repo.to_indexed_ids()?; + // let tree = repo.node_from_path(first_snapshot.tree, Path::new("test/tests"))?; + // let tree = repo.get_tree(&tree.subtree.expect("Sub tree"))?; + + // #[cfg(windows)] + // assert_debug_snapshot!("dryrun-tar-tree-windows", tree); + + // #[cfg(not(windows))] + // assert_debug_snapshot!("dryrun-tar-tree-nix", tree); + // re-read index let repo = repo.to_indexed_ids()?; // second dry-run backup let opts = opts.dry_run(true); let snap_dry_run = repo.backup(&opts, paths, SnapshotFile::default())?; - assert_debug_snapshot!(TestSummary(&snap_dry_run)); + + #[cfg(windows)] + assert_debug_snapshot!( + "dryrun-tar-summary-second-windows", + TestSummary(&snap_dry_run) + ); + + #[cfg(not(windows))] + assert_debug_snapshot!("dryrun-tar-summary-second-nix", TestSummary(&snap_dry_run)); + // check that no data has been added let snaps = repo.get_all_snapshots()?; assert_eq!(snaps, vec![first_snapshot]); diff --git a/crates/core/tests/snapshots/integration__backup_with_dir_passes.snap b/crates/core/tests/snapshots/integration__backup-dir-summary-first-windows.snap similarity index 75% rename from crates/core/tests/snapshots/integration__backup_with_dir_passes.snap rename to crates/core/tests/snapshots/integration__backup-dir-summary-first-windows.snap index 6c7dfee3..6d981dbd 100644 --- a/crates/core/tests/snapshots/integration__backup_with_dir_passes.snap +++ b/crates/core/tests/snapshots/integration__backup-dir-summary-first-windows.snap @@ -1,6 +1,6 @@ --- source: crates/core/tests/integration.rs -expression: TestSummary(&first_backup) +expression: TestSummary(&first_snapshot) --- TestSnap { hostname: "", @@ -17,13 +17,13 @@ TestSnap { files_changed: 0, files_unmodified: 0, total_files_processed: 73, - total_bytes_processed: 1125676, + total_bytes_processed: 1125674, dirs_new: 5, dirs_changed: 0, dirs_unmodified: 0, total_dirs_processed: 5, data_blobs: 70, tree_blobs: 5, - data_added_files: 1125654, - data_added_files_packed: 78741, + data_added_files: 1125653, + data_added_files_packed: 78740, } diff --git a/crates/core/tests/snapshots/integration__backup_with_dir_passes-2.snap b/crates/core/tests/snapshots/integration__backup-dir-summary-second-windows.snap similarity index 86% rename from crates/core/tests/snapshots/integration__backup_with_dir_passes-2.snap rename to crates/core/tests/snapshots/integration__backup-dir-summary-second-windows.snap index 7eb5a086..88efa041 100644 --- a/crates/core/tests/snapshots/integration__backup_with_dir_passes-2.snap +++ b/crates/core/tests/snapshots/integration__backup-dir-summary-second-windows.snap @@ -1,6 +1,6 @@ --- source: crates/core/tests/integration.rs -expression: TestSummary(&snap2) +expression: TestSummary(&second_snapshot) --- TestSnap { hostname: "", @@ -17,7 +17,7 @@ TestSnap { files_changed: 0, files_unmodified: 73, total_files_processed: 73, - total_bytes_processed: 1125682, + total_bytes_processed: 1125674, dirs_new: 0, dirs_changed: 0, dirs_unmodified: 5, diff --git a/crates/core/tests/snapshots/integration__backup-dir-tree-windows.snap b/crates/core/tests/snapshots/integration__backup-dir-tree-windows.snap new file mode 100644 index 00000000..ee1c4702 --- /dev/null +++ b/crates/core/tests/snapshots/integration__backup-dir-tree-windows.snap @@ -0,0 +1,129 @@ +--- +source: crates/core/tests/integration.rs +expression: tree +--- +Tree { + nodes: [ + Node { + name: "empty-file", + node_type: File, + meta: Metadata { + mode: None, + mtime: Some( + 2014-11-30T16:03:11+01:00, + ), + atime: Some( + 2014-11-30T16:03:11+01:00, + ), + ctime: Some( + 2024-03-12T22:32:55+01:00, + ), + uid: None, + gid: None, + user: None, + group: None, + inode: 0, + device_id: 0, + size: 0, + links: 0, + extended_attributes: [], + }, + content: Some( + [], + ), + subtree: None, + }, + Node { + name: "testfile", + node_type: File, + meta: Metadata { + mode: None, + mtime: Some( + 2014-08-09T14:14:20+02:00, + ), + atime: Some( + 2014-08-09T14:14:20+02:00, + ), + ctime: Some( + 2024-03-12T22:32:55+01:00, + ), + uid: None, + gid: None, + user: None, + group: None, + inode: 0, + device_id: 0, + size: 21, + links: 0, + extended_attributes: [], + }, + content: Some( + [ + 649b8b471e7d7bc175eec758a7006ac693c434c8297c07db15286788c837154a, + ], + ), + subtree: None, + }, + Node { + name: "testfile-hardlink", + node_type: File, + meta: Metadata { + mode: None, + mtime: Some( + 2014-08-09T14:14:20+02:00, + ), + atime: Some( + 2014-08-09T14:14:20+02:00, + ), + ctime: Some( + 2024-03-12T22:32:55+01:00, + ), + uid: None, + gid: None, + user: None, + group: None, + inode: 0, + device_id: 0, + size: 21, + links: 0, + extended_attributes: [], + }, + content: Some( + [ + 649b8b471e7d7bc175eec758a7006ac693c434c8297c07db15286788c837154a, + ], + ), + subtree: None, + }, + Node { + name: "testfile-symlink", + node_type: Symlink { + linktarget: "testfile", + linktarget_raw: None, + }, + meta: Metadata { + mode: None, + mtime: Some( + 2024-03-12T22:32:55.218816+01:00, + ), + atime: Some( + 2024-03-12T22:32:55.218816+01:00, + ), + ctime: Some( + 2024-03-12T22:32:55.218816+01:00, + ), + uid: None, + gid: None, + user: None, + group: None, + inode: 0, + device_id: 0, + size: 0, + links: 0, + extended_attributes: [], + }, + content: None, + subtree: None, + }, + ], +} diff --git a/crates/core/tests/snapshots/integration__backup_with_tar_gz_passes.snap b/crates/core/tests/snapshots/integration__backup-tar-summary-first-windows.snap similarity index 92% rename from crates/core/tests/snapshots/integration__backup_with_tar_gz_passes.snap rename to crates/core/tests/snapshots/integration__backup-tar-summary-first-windows.snap index 4f80bc50..fbf264a3 100644 --- a/crates/core/tests/snapshots/integration__backup_with_tar_gz_passes.snap +++ b/crates/core/tests/snapshots/integration__backup-tar-summary-first-windows.snap @@ -1,6 +1,6 @@ --- source: crates/core/tests/integration.rs -expression: TestSummary(&first_backup) +expression: TestSummary(&first_snapshot) --- TestSnap { hostname: "", diff --git a/crates/core/tests/snapshots/integration__backup_with_tar_gz_passes-2.snap b/crates/core/tests/snapshots/integration__backup-tar-summary-second-windows.snap similarity index 100% rename from crates/core/tests/snapshots/integration__backup_with_tar_gz_passes-2.snap rename to crates/core/tests/snapshots/integration__backup-tar-summary-second-windows.snap diff --git a/crates/core/tests/snapshots/integration__backup_dry_run_with_tar_gz_passes.snap b/crates/core/tests/snapshots/integration__dryrun-tar-summary-first-windows.snap similarity index 100% rename from crates/core/tests/snapshots/integration__backup_dry_run_with_tar_gz_passes.snap rename to crates/core/tests/snapshots/integration__dryrun-tar-summary-first-windows.snap diff --git a/crates/core/tests/snapshots/integration__backup_dry_run_with_tar_gz_passes-2.snap b/crates/core/tests/snapshots/integration__dryrun-tar-summary-second-windows.snap similarity index 93% rename from crates/core/tests/snapshots/integration__backup_dry_run_with_tar_gz_passes-2.snap rename to crates/core/tests/snapshots/integration__dryrun-tar-summary-second-windows.snap index 632d04ee..ba72d6a9 100644 --- a/crates/core/tests/snapshots/integration__backup_dry_run_with_tar_gz_passes-2.snap +++ b/crates/core/tests/snapshots/integration__dryrun-tar-summary-second-windows.snap @@ -17,7 +17,7 @@ TestSnap { files_changed: 0, files_unmodified: 73, total_files_processed: 73, - total_bytes_processed: 1125682, + total_bytes_processed: 1125674, dirs_new: 0, dirs_changed: 0, dirs_unmodified: 6,