Skip to content

Commit 357c547

Browse files
committed
dd tests: fix 'temporary value dropped while borrowed'
1 parent 5eb3cae commit 357c547

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

tests/by-util/test_dd.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ use std::time::Duration;
3030
use tempfile::tempfile;
3131

3232
macro_rules! inf {
33-
($fname:expr) => {{ &format!("if={}", $fname) }};
33+
($fname:expr) => {
34+
format!("if={}", $fname)
35+
};
3436
}
3537

3638
macro_rules! of {
37-
($fname:expr) => {{ &format!("of={}", $fname) }};
39+
($fname:expr) => {
40+
format!("of={}", $fname)
41+
};
3842
}
3943

4044
macro_rules! fixture_path {
@@ -290,7 +294,7 @@ fn test_noatime_does_not_update_infile_atime() {
290294
assert_fixture_exists!(&fname);
291295

292296
let (fix, mut ucmd) = at_and_ucmd!();
293-
ucmd.args(&["status=none", "iflag=noatime", inf!(fname)]);
297+
ucmd.args(&["status=none", "iflag=noatime", &inf!(fname)]);
294298

295299
let pre_atime = fix.metadata(fname).accessed().unwrap();
296300

@@ -310,7 +314,7 @@ fn test_noatime_does_not_update_ofile_atime() {
310314
assert_fixture_exists!(&fname);
311315

312316
let (fix, mut ucmd) = at_and_ucmd!();
313-
ucmd.args(&["status=none", "oflag=noatime", of!(fname)]);
317+
ucmd.args(&["status=none", "oflag=noatime", &of!(fname)]);
314318

315319
let pre_atime = fix.metadata(fname).accessed().unwrap();
316320

@@ -327,7 +331,7 @@ fn test_nocreat_causes_failure_when_outfile_not_present() {
327331
assert_fixture_not_exists!(&fname);
328332

329333
let (fix, mut ucmd) = at_and_ucmd!();
330-
ucmd.args(&["conv=nocreat", of!(&fname)])
334+
ucmd.args(&["conv=nocreat", &of!(&fname)])
331335
.pipe_in("")
332336
.fails()
333337
.stderr_only(
@@ -347,7 +351,7 @@ fn test_notrunc_does_not_truncate() {
347351
}
348352

349353
let (fix, mut ucmd) = at_and_ucmd!();
350-
ucmd.args(&["status=none", "conv=notrunc", of!(&fname), "if=null.txt"])
354+
ucmd.args(&["status=none", "conv=notrunc", &of!(&fname), "if=null.txt"])
351355
.succeeds()
352356
.no_output();
353357

@@ -365,7 +369,7 @@ fn test_existing_file_truncated() {
365369
}
366370

367371
let (fix, mut ucmd) = at_and_ucmd!();
368-
ucmd.args(&["status=none", "if=null.txt", of!(fname)])
372+
ucmd.args(&["status=none", "if=null.txt", &of!(fname)])
369373
.succeeds()
370374
.no_output();
371375

@@ -409,7 +413,7 @@ fn test_fullblock() {
409413
let ucmd = new_ucmd!()
410414
.args(&[
411415
"if=/dev/urandom",
412-
of!(&tmp_fn),
416+
&of!(&tmp_fn),
413417
"bs=128M",
414418
// Note: In order for this test to actually test iflag=fullblock, the bs=VALUE
415419
// must be big enough to 'overwhelm' the urandom store of bytes.
@@ -492,7 +496,7 @@ fn test_zeros_to_file() {
492496
assert_fixture_exists!(test_fn);
493497

494498
let (fix, mut ucmd) = at_and_ucmd!();
495-
ucmd.args(&["status=none", inf!(test_fn), of!(tmp_fn)])
499+
ucmd.args(&["status=none", &inf!(test_fn), &of!(tmp_fn)])
496500
.succeeds()
497501
.no_output();
498502

@@ -512,8 +516,8 @@ fn test_to_file_with_ibs_obs() {
512516
let (fix, mut ucmd) = at_and_ucmd!();
513517
ucmd.args(&[
514518
"status=none",
515-
inf!(test_fn),
516-
of!(tmp_fn),
519+
&inf!(test_fn),
520+
&of!(tmp_fn),
517521
"ibs=222",
518522
"obs=111",
519523
])
@@ -533,7 +537,7 @@ fn test_ascii_521k_to_file() {
533537
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
534538

535539
let (fix, mut ucmd) = at_and_ucmd!();
536-
ucmd.args(&["status=none", of!(tmp_fn)])
540+
ucmd.args(&["status=none", &of!(tmp_fn)])
537541
.pipe_in(input.clone())
538542
.succeeds()
539543
.no_output();
@@ -563,7 +567,7 @@ fn test_ascii_5_gibi_to_file() {
563567
"count=5G",
564568
"iflag=count_bytes",
565569
"if=/dev/zero",
566-
of!(tmp_fn),
570+
&of!(tmp_fn),
567571
])
568572
.succeeds()
569573
.no_output();
@@ -577,7 +581,7 @@ fn test_self_transfer() {
577581
assert_fixture_exists!(fname);
578582

579583
let (fix, mut ucmd) = at_and_ucmd!();
580-
ucmd.args(&["status=none", "conv=notrunc", inf!(fname), of!(fname)]);
584+
ucmd.args(&["status=none", "conv=notrunc", &inf!(fname), &of!(fname)]);
581585

582586
assert!(fix.file_exists(fname));
583587
assert_eq!(256 * 1024, fix.metadata(fname).len());
@@ -596,7 +600,7 @@ fn test_unicode_filenames() {
596600
assert_fixture_exists!(test_fn);
597601

598602
let (fix, mut ucmd) = at_and_ucmd!();
599-
ucmd.args(&["status=none", inf!(test_fn), of!(tmp_fn)])
603+
ucmd.args(&["status=none", &inf!(test_fn), &of!(tmp_fn)])
600604
.succeeds()
601605
.no_output();
602606

0 commit comments

Comments
 (0)