From 6ebb3a62333fe72cfe0c1b0d5e9fedc09a11efd2 Mon Sep 17 00:00:00 2001 From: kingchenc Date: Sat, 18 Jul 2026 01:43:42 +0200 Subject: [PATCH] test: bound on-disk byte assertions so CI passes on Unix (0.6.2) The 0.6.1 on-disk-size change made scan/remove totals report allocated bytes, which round up to the block size on ext4/apfs. Four tests still asserted exact logical byte counts and failed on the Linux/macOS CI runners (Windows normal files report logical == on-disk, so it passed locally). Switch those to lower-bound / file-count assertions, which hold on every filesystem; logical exactness is still checked via logical_size. Release binaries are unchanged; this is a test-only fix plus a version bump. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/diskghost-core/src/lib.rs | 16 ++++++++++++---- gui/src-tauri/Cargo.lock | 4 ++-- gui/src-tauri/Cargo.toml | 2 +- gui/src-tauri/tauri.conf.json | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43bc27d..4a3227f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,7 +358,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "diskghost-cli" -version = "0.6.1" +version = "0.6.2" dependencies = [ "clap", "diskghost-core", @@ -367,7 +367,7 @@ dependencies = [ [[package]] name = "diskghost-core" -version = "0.6.1" +version = "0.6.2" dependencies = [ "blake3", "criterion", diff --git a/Cargo.toml b/Cargo.toml index a3bbe82..551a204 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ exclude = ["gui"] resolver = "2" [workspace.package] -version = "0.6.1" +version = "0.6.2" edition = "2021" license = "MIT" authors = ["kingchenc"] diff --git a/crates/diskghost-core/src/lib.rs b/crates/diskghost-core/src/lib.rs index dc3426b..a15171c 100644 --- a/crates/diskghost-core/src/lib.rs +++ b/crates/diskghost-core/src/lib.rs @@ -915,7 +915,12 @@ mod tests { ..Default::default() }; let r = scan_with_progress(&d, 20, &opts, &Progress::default()); - assert_eq!(r.total_size, 150, "junk.tmp should be excluded"); + // junk.tmp is excluded, leaving keep.bin + deeper.bin. The file count is + // the exact exclusion check; total_size is on-disk (block-rounded on some + // filesystems) so it only gets a lower bound. + assert_eq!(r.total_files, 2, "junk.tmp should be excluded"); + assert!(!r.top_files.iter().any(|f| f.path.ends_with("junk.tmp"))); + assert!(r.total_size >= 150, "total_size {}", r.total_size); // Depth 1: only the root's direct children are visited. let shallow = Options { @@ -967,7 +972,8 @@ mod tests { let r = scan_with_progress(&d, 10, &Options::default(), &p); assert_eq!(r.total_files, 2); assert_eq!(p.files(), 2); - assert_eq!(p.bytes(), 30); + // Progress bytes are on-disk (block-rounded on some filesystems). + assert!(p.bytes() >= 30, "progress bytes {}", p.bytes()); // Pre-cancelled: the walk stops immediately and sees nothing. let c = Progress::default(); @@ -1043,7 +1049,8 @@ mod tests { let rep = remove_path(&d, RemoveMode::Delete, true, &Progress::default()); assert!(rep.dry_run); assert_eq!(rep.files, 3); - assert_eq!(rep.bytes, 1700); + // Freed bytes are on-disk (block-rounded on some filesystems). + assert!(rep.bytes >= 1700, "freed bytes {}", rep.bytes); assert!(rep.dirs >= 2); // root + a + a/b (root counted by jwalk) assert!(rep.errors.is_empty()); assert!(d.exists()); // nothing was touched @@ -1070,7 +1077,8 @@ mod tests { write(&f, &[0u8; 321]); let rep = remove_path(&f, RemoveMode::Delete, false, &Progress::default()); assert_eq!(rep.files, 1); - assert_eq!(rep.bytes, 321); + // Freed bytes are on-disk (block-rounded on some filesystems). + assert!(rep.bytes >= 321, "freed bytes {}", rep.bytes); assert!(!f.exists()); assert!(d.exists()); // parent left intact std::fs::remove_dir_all(&d).ok(); diff --git a/gui/src-tauri/Cargo.lock b/gui/src-tauri/Cargo.lock index 187a936..33d2ba8 100644 --- a/gui/src-tauri/Cargo.lock +++ b/gui/src-tauri/Cargo.lock @@ -664,7 +664,7 @@ dependencies = [ [[package]] name = "diskghost-core" -version = "0.6.1" +version = "0.6.2" dependencies = [ "blake3", "fs4", @@ -678,7 +678,7 @@ dependencies = [ [[package]] name = "diskghost-gui" -version = "0.6.1" +version = "0.6.2" dependencies = [ "diskghost-core", "serde", diff --git a/gui/src-tauri/Cargo.toml b/gui/src-tauri/Cargo.toml index 6a6c9a9..35734fc 100644 --- a/gui/src-tauri/Cargo.toml +++ b/gui/src-tauri/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "diskghost-gui" -version = "0.6.1" +version = "0.6.2" edition = "2021" license = "MIT" description = "Diskghost desktop GUI (Tauri) — modern disk usage & duplicate finder." diff --git a/gui/src-tauri/tauri.conf.json b/gui/src-tauri/tauri.conf.json index 2b748c7..7dbb92a 100644 --- a/gui/src-tauri/tauri.conf.json +++ b/gui/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Diskghost", - "version": "0.6.1", + "version": "0.6.2", "identifier": "org.diskghost.app", "build": { "frontendDist": "../ui"