Skip to content

Commit 37f25d9

Browse files
committed
test: Fix compilation errors
1 parent 57fdd5d commit 37f25d9

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

tests/_utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub const DEFAULT_GET_SIZE: SizeGetter<Bytes> = size_getters::GET_APPARENT_SIZE;
3232
///
3333
/// **NOTE:** Delete this once https://github.com/samgiles/rs-mktemp/issues/8 is resolved.
3434
#[derive(Debug, AsRef, Deref)]
35+
#[as_ref(forward)]
36+
#[deref(forward)]
3537
pub struct Temp(PathBuf);
3638

3739
impl Temp {
@@ -63,6 +65,8 @@ impl Drop for Temp {
6365

6466
/// Temporary workspace with sample filesystem tree.
6567
#[derive(Debug, AsRef, Deref)]
68+
#[as_ref(forward)]
69+
#[deref(forward)]
6670
pub struct SampleWorkspace(Temp);
6771

6872
impl Default for SampleWorkspace {

tests/cli_errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn min_ratio_1() {
5454
stdout,
5555
stderr,
5656
} = Command::new(PDU)
57-
.with_current_dir(workspace.as_path())
57+
.with_current_dir(&workspace)
5858
.with_arg("--min-ratio=1")
5959
.pipe(stdio)
6060
.output()
@@ -83,7 +83,7 @@ fn max_depth_0() {
8383
stdout,
8484
stderr,
8585
} = Command::new(PDU)
86-
.with_current_dir(workspace.as_path())
86+
.with_current_dir(&workspace)
8787
.with_arg("--max-depth=0")
8888
.pipe(stdio)
8989
.output()
@@ -116,7 +116,7 @@ fn fs_errors() {
116116
stdout,
117117
stderr,
118118
} = Command::new(PDU)
119-
.with_current_dir(workspace.as_path())
119+
.with_current_dir(&workspace)
120120
.with_arg("--min-ratio=0")
121121
.with_arg("--total-width=100")
122122
.with_arg("--quantity=apparent-size")
@@ -148,7 +148,7 @@ fn fs_errors() {
148148
let expected_stdout = format!("{}", visualizer);
149149
eprintln!("EXPECTED STDOUT:\n{}\n", &expected_stdout);
150150

151-
fs_permission(workspace.as_path(), "+rwx", true); // to allow SampleWorkspace destructor to clean itself
151+
fs_permission(&workspace, "+rwx", true); // to allow SampleWorkspace destructor to clean itself
152152

153153
let actual_stderr_lines: BTreeSet<_> = stderr
154154
.trim_end()

tests/flag_combinations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ fn flag_combinations() {
2323
for command in list.commands() {
2424
dbg!(&command);
2525
let workspace = SampleWorkspace::default();
26-
dbg!(workspace.as_path());
26+
dbg!(&workspace);
2727
let output = command
28-
.with_current_dir(workspace.as_path())
28+
.with_current_dir(&workspace)
2929
.with_stdin(Stdio::null())
3030
.with_stdout(Stdio::null())
3131
.with_stderr(Stdio::piped())

tests/json.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ fn sample_tree() -> SampleTree {
6060
fn json_output() {
6161
let workspace = SampleWorkspace::default();
6262
let actual = Command::new(PDU)
63-
.with_current_dir(workspace.as_path())
63+
.with_current_dir(&workspace)
6464
.with_arg("--json-output")
6565
.with_arg("--quantity=apparent-size")
6666
.with_arg("--min-ratio=0")
67-
.with_arg(workspace.as_path())
67+
.with_arg(&workspace)
6868
.with_stdin(Stdio::null())
6969
.with_stdout(Stdio::piped())
7070
.with_stderr(Stdio::piped())
@@ -104,7 +104,7 @@ fn json_input() {
104104
eprintln!("JSON: {}\n", json);
105105
let workspace = Temp::new_dir().expect("create temporary directory");
106106
let mut child = Command::new(PDU)
107-
.with_current_dir(workspace.as_path())
107+
.with_current_dir(&workspace)
108108
.with_arg("--json-input")
109109
.with_arg("--bytes-format=metric")
110110
.with_arg("--total-width=100")
@@ -147,17 +147,17 @@ fn json_output_json_input() {
147147
let workspace = SampleWorkspace::default();
148148

149149
let json_output = Command::new(PDU)
150-
.with_current_dir(workspace.as_path())
150+
.with_current_dir(&workspace)
151151
.with_arg("--json-output")
152152
.with_arg("--quantity=apparent-size")
153-
.with_arg(workspace.as_path())
153+
.with_arg(&workspace)
154154
.with_stdin(Stdio::null())
155155
.with_stdout(Stdio::piped())
156156
.with_stderr(Stdio::piped())
157157
.spawn()
158158
.expect("spawn command with --json-output");
159159
let actual = Command::new(PDU)
160-
.with_current_dir(workspace.as_path())
160+
.with_current_dir(&workspace)
161161
.with_arg("--json-input")
162162
.with_arg("--bytes-format=metric")
163163
.with_arg("--total-width=100")
@@ -176,12 +176,12 @@ fn json_output_json_input() {
176176
eprintln!("ACTUAL:\n{}\n", &actual);
177177

178178
let expected = Command::new(PDU)
179-
.with_current_dir(workspace.as_path())
179+
.with_current_dir(&workspace)
180180
.with_arg("--bytes-format=metric")
181181
.with_arg("--total-width=100")
182182
.with_arg("--max-depth=10")
183183
.with_arg("--quantity=apparent-size")
184-
.with_arg(workspace.as_path())
184+
.with_arg(&workspace)
185185
.with_stdin(Stdio::piped())
186186
.with_stdout(Stdio::piped())
187187
.with_stderr(Stdio::piped())

tests/usual_cli.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn stdio(command: Command) -> Command {
3131
fn total_width() {
3232
let workspace = SampleWorkspace::default();
3333
let actual = Command::new(PDU)
34-
.with_current_dir(workspace.as_path())
34+
.with_current_dir(&workspace)
3535
.with_arg("--total-width=100")
3636
.pipe(stdio)
3737
.output()
@@ -67,7 +67,7 @@ fn total_width() {
6767
fn column_width() {
6868
let workspace = SampleWorkspace::default();
6969
let actual = Command::new(PDU)
70-
.with_current_dir(workspace.as_path())
70+
.with_current_dir(&workspace)
7171
.with_arg("--column-width")
7272
.with_arg("10")
7373
.with_arg("90")
@@ -105,7 +105,7 @@ fn column_width() {
105105
fn min_ratio_0() {
106106
let workspace = SampleWorkspace::default();
107107
let actual = Command::new(PDU)
108-
.with_current_dir(workspace.as_path())
108+
.with_current_dir(&workspace)
109109
.with_arg("--quantity=apparent-size")
110110
.with_arg("--total-width=100")
111111
.with_arg("--min-ratio=0")
@@ -142,7 +142,7 @@ fn min_ratio_0() {
142142
fn min_ratio() {
143143
let workspace = SampleWorkspace::default();
144144
let actual = Command::new(PDU)
145-
.with_current_dir(workspace.as_path())
145+
.with_current_dir(&workspace)
146146
.with_arg("--quantity=apparent-size")
147147
.with_arg("--total-width=100")
148148
.with_arg("--min-ratio=0.1")
@@ -180,7 +180,7 @@ fn min_ratio() {
180180
fn max_depth_2() {
181181
let workspace = SampleWorkspace::default();
182182
let actual = Command::new(PDU)
183-
.with_current_dir(workspace.as_path())
183+
.with_current_dir(&workspace)
184184
.with_arg("--quantity=apparent-size")
185185
.with_arg("--total-width=100")
186186
.with_arg("--max-depth=2")
@@ -218,7 +218,7 @@ fn max_depth_2() {
218218
fn max_depth_1() {
219219
let workspace = SampleWorkspace::default();
220220
let actual = Command::new(PDU)
221-
.with_current_dir(workspace.as_path())
221+
.with_current_dir(&workspace)
222222
.with_arg("--quantity=apparent-size")
223223
.with_arg("--total-width=100")
224224
.with_arg("--max-depth=1")
@@ -256,7 +256,7 @@ fn max_depth_1() {
256256
fn top_down() {
257257
let workspace = SampleWorkspace::default();
258258
let actual = Command::new(PDU)
259-
.with_current_dir(workspace.as_path())
259+
.with_current_dir(&workspace)
260260
.with_arg("--total-width=100")
261261
.with_arg("--top-down")
262262
.pipe(stdio)
@@ -293,7 +293,7 @@ fn top_down() {
293293
fn align_right() {
294294
let workspace = SampleWorkspace::default();
295295
let actual = Command::new(PDU)
296-
.with_current_dir(workspace.as_path())
296+
.with_current_dir(&workspace)
297297
.with_arg("--total-width=100")
298298
.with_arg("--align-right")
299299
.pipe(stdio)
@@ -330,7 +330,7 @@ fn align_right() {
330330
fn quantity_apparent_size() {
331331
let workspace = SampleWorkspace::default();
332332
let actual = Command::new(PDU)
333-
.with_current_dir(workspace.as_path())
333+
.with_current_dir(&workspace)
334334
.with_arg("--total-width=100")
335335
.with_arg("--quantity=apparent-size")
336336
.pipe(stdio)
@@ -368,7 +368,7 @@ fn quantity_apparent_size() {
368368
fn quantity_block_size() {
369369
let workspace = SampleWorkspace::default();
370370
let actual = Command::new(PDU)
371-
.with_current_dir(workspace.as_path())
371+
.with_current_dir(&workspace)
372372
.with_arg("--total-width=100")
373373
.with_arg("--quantity=block-size")
374374
.pipe(stdio)
@@ -406,7 +406,7 @@ fn quantity_block_size() {
406406
fn quantity_block_count() {
407407
let workspace = SampleWorkspace::default();
408408
let actual = Command::new(PDU)
409-
.with_current_dir(workspace.as_path())
409+
.with_current_dir(&workspace)
410410
.with_arg("--total-width=100")
411411
.with_arg("--quantity=block-count")
412412
.pipe(stdio)
@@ -444,7 +444,7 @@ fn quantity_block_count() {
444444
fn bytes_format_plain() {
445445
let workspace = SampleWorkspace::default();
446446
let actual = Command::new(PDU)
447-
.with_current_dir(workspace.as_path())
447+
.with_current_dir(&workspace)
448448
.with_arg("--total-width=100")
449449
.with_arg("--quantity=block-size")
450450
.with_arg("--bytes-format=plain")
@@ -483,7 +483,7 @@ fn bytes_format_plain() {
483483
fn bytes_format_metric() {
484484
let workspace = SampleWorkspace::default();
485485
let actual = Command::new(PDU)
486-
.with_current_dir(workspace.as_path())
486+
.with_current_dir(&workspace)
487487
.with_arg("--total-width=100")
488488
.with_arg("--quantity=block-size")
489489
.with_arg("--bytes-format=metric")
@@ -522,7 +522,7 @@ fn bytes_format_metric() {
522522
fn bytes_format_binary() {
523523
let workspace = SampleWorkspace::default();
524524
let actual = Command::new(PDU)
525-
.with_current_dir(workspace.as_path())
525+
.with_current_dir(&workspace)
526526
.with_arg("--total-width=100")
527527
.with_arg("--quantity=block-size")
528528
.with_arg("--bytes-format=binary")
@@ -560,9 +560,9 @@ fn bytes_format_binary() {
560560
fn path_to_workspace() {
561561
let workspace = SampleWorkspace::default();
562562
let actual = Command::new(PDU)
563-
.with_current_dir(workspace.as_path())
563+
.with_current_dir(&workspace)
564564
.with_arg("--total-width=100")
565-
.with_arg(workspace.as_path())
565+
.with_arg(&workspace)
566566
.pipe(stdio)
567567
.output()
568568
.expect("spawn command")
@@ -596,7 +596,7 @@ fn path_to_workspace() {
596596
fn multiple_names() {
597597
let workspace = SampleWorkspace::default();
598598
let actual = Command::new(PDU)
599-
.with_current_dir(workspace.as_path())
599+
.with_current_dir(&workspace)
600600
.with_arg("--quantity=apparent-size")
601601
.with_arg("--total-width=100")
602602
.with_arg("nested")

0 commit comments

Comments
 (0)