Skip to content

Commit b32c72d

Browse files
authored
test: fix windows (#293)
1 parent ffc35a7 commit b32c72d

4 files changed

Lines changed: 33 additions & 21 deletions

File tree

tests/cli_errors.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ pub mod _utils;
44
pub use _utils::*;
55

66
use command_extra::CommandExtra;
7+
use pipe_trait::Pipe;
8+
use pretty_assertions::assert_eq;
9+
use std::process::{Command, Output, Stdio};
10+
use text_block_macros::text_block;
11+
12+
#[cfg(unix)]
713
use maplit::btreeset;
14+
#[cfg(unix)]
815
use parallel_disk_usage::{
916
bytes_format::BytesFormat,
1017
data_tree::DataTree,
@@ -14,14 +21,8 @@ use parallel_disk_usage::{
1421
reporter::{ErrorOnlyReporter, ErrorReport},
1522
visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer},
1623
};
17-
use pipe_trait::Pipe;
18-
use pretty_assertions::assert_eq;
19-
use std::{
20-
collections::BTreeSet,
21-
path::Path,
22-
process::{Command, Output, Stdio},
23-
};
24-
use text_block_macros::text_block;
24+
#[cfg(unix)]
25+
use std::{collections::BTreeSet, path::Path};
2526

2627
fn stdio(command: Command) -> Command {
2728
command

tests/data_tree_reflection.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,15 @@ fn display_excessive_children() {
136136
.par_try_into_tree()
137137
.expect_err("create error")
138138
.to_string();
139-
let expected = r#"ExcessiveChildren: "root/b/0" (Bytes(321)) is less than a child named "def" (Bytes(456))"#;
139+
let expected = if cfg!(unix) {
140+
r#"ExcessiveChildren: "root/b/0" (Bytes(321)) is less than a child named "def" (Bytes(456))"#
141+
} else if cfg!(windows) {
142+
// TODO: stop using debug format
143+
r#"ExcessiveChildren: "root\\b\\0" (Bytes(321)) is less than a child named "def" (Bytes(456))"#
144+
} else {
145+
eprintln!("ACTUAL: {actual}");
146+
panic!("This platform isn't supported!");
147+
};
140148
assert_eq!(actual, expected);
141149
}
142150

tests/fs_tree_builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
pub mod _utils;
22
pub use _utils::*;
33

4-
use parallel_disk_usage::{
5-
get_size::{GetApparentSize, GetBlockCount, GetBlockSize},
6-
size::Bytes,
7-
};
4+
use parallel_disk_usage::{get_size::GetApparentSize, size::Bytes};
85

96
#[cfg(unix)]
10-
use parallel_disk_usage::size::Blocks;
7+
use parallel_disk_usage::{
8+
get_size::{GetBlockCount, GetBlockSize},
9+
size::Blocks,
10+
};
1111

1212
#[test]
1313
fn len_as_bytes() {

tests/usual_cli.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use parallel_disk_usage::{
88
bytes_format::BytesFormat,
99
data_tree::DataTree,
1010
fs_tree_builder::FsTreeBuilder,
11-
get_size::{GetApparentSize, GetBlockCount, GetBlockSize},
11+
get_size::GetApparentSize,
1212
os_string_display::OsStringDisplay,
1313
reporter::{ErrorOnlyReporter, ErrorReport},
1414
visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer},
@@ -17,6 +17,9 @@ use pipe_trait::Pipe;
1717
use pretty_assertions::assert_eq;
1818
use std::process::{Command, Stdio};
1919

20+
#[cfg(unix)]
21+
use parallel_disk_usage::get_size::{GetBlockCount, GetBlockSize};
22+
2023
fn stdio(command: Command) -> Command {
2124
command
2225
.with_stdin(Stdio::null())
@@ -443,7 +446,7 @@ fn bytes_format_plain() {
443446
let actual = Command::new(PDU)
444447
.with_current_dir(&workspace)
445448
.with_arg("--total-width=100")
446-
.with_arg("--quantity=block-size")
449+
.with_arg("--quantity=apparent-size")
447450
.with_arg("--bytes-format=plain")
448451
.pipe(stdio)
449452
.output()
@@ -453,7 +456,7 @@ fn bytes_format_plain() {
453456

454457
let builder = FsTreeBuilder {
455458
root: workspace.to_path_buf(),
456-
size_getter: GetBlockSize,
459+
size_getter: GetApparentSize,
457460
reporter: ErrorOnlyReporter::new(ErrorReport::SILENT),
458461
max_depth: 10,
459462
};
@@ -482,7 +485,7 @@ fn bytes_format_metric() {
482485
let actual = Command::new(PDU)
483486
.with_current_dir(&workspace)
484487
.with_arg("--total-width=100")
485-
.with_arg("--quantity=block-size")
488+
.with_arg("--quantity=apparent-size")
486489
.with_arg("--bytes-format=metric")
487490
.pipe(stdio)
488491
.output()
@@ -492,7 +495,7 @@ fn bytes_format_metric() {
492495

493496
let builder = FsTreeBuilder {
494497
root: workspace.to_path_buf(),
495-
size_getter: GetBlockSize,
498+
size_getter: GetApparentSize,
496499
reporter: ErrorOnlyReporter::new(ErrorReport::SILENT),
497500
max_depth: 10,
498501
};
@@ -521,7 +524,7 @@ fn bytes_format_binary() {
521524
let actual = Command::new(PDU)
522525
.with_current_dir(&workspace)
523526
.with_arg("--total-width=100")
524-
.with_arg("--quantity=block-size")
527+
.with_arg("--quantity=apparent-size")
525528
.with_arg("--bytes-format=binary")
526529
.pipe(stdio)
527530
.output()
@@ -531,7 +534,7 @@ fn bytes_format_binary() {
531534

532535
let builder = FsTreeBuilder {
533536
root: workspace.to_path_buf(),
534-
size_getter: GetBlockSize,
537+
size_getter: GetApparentSize,
535538
reporter: ErrorOnlyReporter::new(ErrorReport::SILENT),
536539
max_depth: 10,
537540
};

0 commit comments

Comments
 (0)