From f318bb88eb1a52fbfe3ceb94a275cf6a3a83110c Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 17 Jul 2025 17:42:40 +0700 Subject: [PATCH 1/5] test: fix windows --- tests/usual_cli.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/usual_cli.rs b/tests/usual_cli.rs index f9b0f3b7..d27b635f 100644 --- a/tests/usual_cli.rs +++ b/tests/usual_cli.rs @@ -8,7 +8,7 @@ use parallel_disk_usage::{ bytes_format::BytesFormat, data_tree::DataTree, fs_tree_builder::FsTreeBuilder, - get_size::{GetApparentSize, GetBlockCount, GetBlockSize}, + get_size::GetApparentSize, os_string_display::OsStringDisplay, reporter::{ErrorOnlyReporter, ErrorReport}, visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, @@ -17,6 +17,9 @@ use pipe_trait::Pipe; use pretty_assertions::assert_eq; use std::process::{Command, Stdio}; +#[cfg(unix)] +use parallel_disk_usage::get_size::{GetBlockCount, GetBlockSize}; + fn stdio(command: Command) -> Command { command .with_stdin(Stdio::null()) @@ -443,7 +446,7 @@ fn bytes_format_plain() { let actual = Command::new(PDU) .with_current_dir(&workspace) .with_arg("--total-width=100") - .with_arg("--quantity=block-size") + .with_arg("--quantity=apparent-size") .with_arg("--bytes-format=plain") .pipe(stdio) .output() @@ -453,7 +456,7 @@ fn bytes_format_plain() { let builder = FsTreeBuilder { root: workspace.to_path_buf(), - size_getter: GetBlockSize, + size_getter: GetApparentSize, reporter: ErrorOnlyReporter::new(ErrorReport::SILENT), max_depth: 10, }; @@ -482,7 +485,7 @@ fn bytes_format_metric() { let actual = Command::new(PDU) .with_current_dir(&workspace) .with_arg("--total-width=100") - .with_arg("--quantity=block-size") + .with_arg("--quantity=apparent-size") .with_arg("--bytes-format=metric") .pipe(stdio) .output() @@ -492,7 +495,7 @@ fn bytes_format_metric() { let builder = FsTreeBuilder { root: workspace.to_path_buf(), - size_getter: GetBlockSize, + size_getter: GetApparentSize, reporter: ErrorOnlyReporter::new(ErrorReport::SILENT), max_depth: 10, }; @@ -521,7 +524,7 @@ fn bytes_format_binary() { let actual = Command::new(PDU) .with_current_dir(&workspace) .with_arg("--total-width=100") - .with_arg("--quantity=block-size") + .with_arg("--quantity=apparent-size") .with_arg("--bytes-format=binary") .pipe(stdio) .output() @@ -531,7 +534,7 @@ fn bytes_format_binary() { let builder = FsTreeBuilder { root: workspace.to_path_buf(), - size_getter: GetBlockSize, + size_getter: GetApparentSize, reporter: ErrorOnlyReporter::new(ErrorReport::SILENT), max_depth: 10, }; From 614f945f4b6924ee93657a5872e1e2252ed83112 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 17 Jul 2025 17:49:19 +0700 Subject: [PATCH 2/5] test: fix windows --- tests/fs_tree_builder.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/fs_tree_builder.rs b/tests/fs_tree_builder.rs index df360eb2..52789662 100644 --- a/tests/fs_tree_builder.rs +++ b/tests/fs_tree_builder.rs @@ -1,13 +1,13 @@ pub mod _utils; pub use _utils::*; -use parallel_disk_usage::{ - get_size::{GetApparentSize, GetBlockCount, GetBlockSize}, - size::Bytes, -}; +use parallel_disk_usage::{get_size::GetApparentSize, size::Bytes}; #[cfg(unix)] -use parallel_disk_usage::size::Blocks; +use parallel_disk_usage::{ + get_size::{GetBlockCount, GetBlockSize}, + size::Blocks, +}; #[test] fn len_as_bytes() { From 7e04ed5d9bcf187ffafaba6fdcee8b00011a9e2e Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 17 Jul 2025 18:00:41 +0700 Subject: [PATCH 3/5] test: fix windows --- tests/data_tree_reflection.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/data_tree_reflection.rs b/tests/data_tree_reflection.rs index 04bbe9c7..b21da8f1 100644 --- a/tests/data_tree_reflection.rs +++ b/tests/data_tree_reflection.rs @@ -136,7 +136,14 @@ fn display_excessive_children() { .par_try_into_tree() .expect_err("create error") .to_string(); - let expected = r#"ExcessiveChildren: "root/b/0" (Bytes(321)) is less than a child named "def" (Bytes(456))"#; + let expected = if cfg!(unix) { + r#"ExcessiveChildren: "root/b/0" (Bytes(321)) is less than a child named "def" (Bytes(456))"# + } else if cfg!(windows) { + r#"ExcessiveChildren: "root\b\0" (Bytes(321)) is less than a child named "def" (Bytes(456))"# + } else { + eprintln!("ACTUAL: {actual}"); + panic!("This platform isn't supported!"); + }; assert_eq!(actual, expected); } From 22819ecb4eda977190b4e88ebf53e37f54796f56 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 17 Jul 2025 18:11:23 +0700 Subject: [PATCH 4/5] test: fix windows --- tests/data_tree_reflection.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/data_tree_reflection.rs b/tests/data_tree_reflection.rs index b21da8f1..12f1ba57 100644 --- a/tests/data_tree_reflection.rs +++ b/tests/data_tree_reflection.rs @@ -139,7 +139,8 @@ fn display_excessive_children() { let expected = if cfg!(unix) { r#"ExcessiveChildren: "root/b/0" (Bytes(321)) is less than a child named "def" (Bytes(456))"# } else if cfg!(windows) { - r#"ExcessiveChildren: "root\b\0" (Bytes(321)) is less than a child named "def" (Bytes(456))"# + // TODO: stop using debug format + r#"ExcessiveChildren: "root\\b\\0" (Bytes(321)) is less than a child named "def" (Bytes(456))"# } else { eprintln!("ACTUAL: {actual}"); panic!("This platform isn't supported!"); From c5cbca688abb94660b7ee2eee952595eea80133c Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 17 Jul 2025 18:15:46 +0700 Subject: [PATCH 5/5] test: fix windows --- tests/cli_errors.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/cli_errors.rs b/tests/cli_errors.rs index c31f2b4c..4b7e92b0 100644 --- a/tests/cli_errors.rs +++ b/tests/cli_errors.rs @@ -4,7 +4,14 @@ pub mod _utils; pub use _utils::*; use command_extra::CommandExtra; +use pipe_trait::Pipe; +use pretty_assertions::assert_eq; +use std::process::{Command, Output, Stdio}; +use text_block_macros::text_block; + +#[cfg(unix)] use maplit::btreeset; +#[cfg(unix)] use parallel_disk_usage::{ bytes_format::BytesFormat, data_tree::DataTree, @@ -14,14 +21,8 @@ use parallel_disk_usage::{ reporter::{ErrorOnlyReporter, ErrorReport}, visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, }; -use pipe_trait::Pipe; -use pretty_assertions::assert_eq; -use std::{ - collections::BTreeSet, - path::Path, - process::{Command, Output, Stdio}, -}; -use text_block_macros::text_block; +#[cfg(unix)] +use std::{collections::BTreeSet, path::Path}; fn stdio(command: Command) -> Command { command