@@ -117,7 +117,7 @@ fn test_df_output() {
117
117
. arg ( "-H" )
118
118
. arg ( "--total" )
119
119
. succeeds ( )
120
- . stdout_move_str ( ) ;
120
+ . stdout_str_lossy ( ) ;
121
121
let actual = output. lines ( ) . take ( 1 ) . collect :: < Vec < & str > > ( ) [ 0 ] ;
122
122
let actual = actual. split_whitespace ( ) . collect :: < Vec < _ > > ( ) ;
123
123
assert_eq ! ( actual, expected) ;
@@ -151,7 +151,7 @@ fn test_df_output_overridden() {
151
151
. arg ( "-hH" )
152
152
. arg ( "--total" )
153
153
. succeeds ( )
154
- . stdout_move_str ( ) ;
154
+ . stdout_str_lossy ( ) ;
155
155
let actual = output. lines ( ) . take ( 1 ) . collect :: < Vec < & str > > ( ) [ 0 ] ;
156
156
let actual = actual. split_whitespace ( ) . collect :: < Vec < _ > > ( ) ;
157
157
assert_eq ! ( actual, expected) ;
@@ -181,7 +181,7 @@ fn test_default_headers() {
181
181
"on" ,
182
182
]
183
183
} ;
184
- let output = new_ucmd ! ( ) . succeeds ( ) . stdout_move_str ( ) ;
184
+ let output = new_ucmd ! ( ) . succeeds ( ) . stdout_str_lossy ( ) ;
185
185
let actual = output. lines ( ) . take ( 1 ) . collect :: < Vec < & str > > ( ) [ 0 ] ;
186
186
let actual = actual. split_whitespace ( ) . collect :: < Vec < _ > > ( ) ;
187
187
assert_eq ! ( actual, expected) ;
@@ -195,7 +195,7 @@ fn test_precedence_of_human_readable_and_si_header_over_output_header() {
195
195
let output = new_ucmd ! ( )
196
196
. args ( & [ arg, "--output=size" ] )
197
197
. succeeds ( )
198
- . stdout_move_str ( ) ;
198
+ . stdout_str_lossy ( ) ;
199
199
let header = output. lines ( ) . next ( ) . unwrap ( ) ;
200
200
assert_eq ! ( header, " Size" ) ;
201
201
}
@@ -207,7 +207,7 @@ fn test_used_header_starts_with_space() {
207
207
// using -h here to ensure the width of the column's content is <= 4
208
208
. args ( & [ "-h" , "--output=used" ] )
209
209
. succeeds ( )
210
- . stdout_move_str ( ) ;
210
+ . stdout_str_lossy ( ) ;
211
211
let header = output. lines ( ) . next ( ) . unwrap ( ) ;
212
212
assert_eq ! ( header, " Used" ) ;
213
213
}
@@ -226,19 +226,19 @@ fn test_order_same() {
226
226
let output1 = new_ucmd ! ( )
227
227
. arg ( "--output=source" )
228
228
. succeeds ( )
229
- . stdout_move_str ( ) ;
229
+ . stdout_str_lossy ( ) ;
230
230
let output2 = new_ucmd ! ( )
231
231
. arg ( "--output=source" )
232
232
. succeeds ( )
233
- . stdout_move_str ( ) ;
233
+ . stdout_str_lossy ( ) ;
234
234
assert_eq ! ( output1, output2) ;
235
235
}
236
236
237
237
/// Test of mount point begin repeated
238
238
#[ cfg( all( unix, not( target_os = "freebsd" ) ) ) ] // FIXME: fix this test for FreeBSD
239
239
#[ test]
240
240
fn test_output_mp_repeat ( ) {
241
- let output1 = new_ucmd ! ( ) . arg ( "/" ) . arg ( "/" ) . succeeds ( ) . stdout_move_str ( ) ;
241
+ let output1 = new_ucmd ! ( ) . arg ( "/" ) . arg ( "/" ) . succeeds ( ) . stdout_str_lossy ( ) ;
242
242
let output1: Vec < String > = output1
243
243
. lines ( )
244
244
. map ( |l| String :: from ( l. split_once ( ' ' ) . unwrap ( ) . 0 ) )
@@ -272,7 +272,7 @@ fn test_type_option() {
272
272
let fs_types = new_ucmd ! ( )
273
273
. arg ( "--output=fstype" )
274
274
. succeeds ( )
275
- . stdout_move_str ( ) ;
275
+ . stdout_str_lossy ( ) ;
276
276
let fs_type = fs_types. lines ( ) . nth ( 1 ) . unwrap ( ) . trim ( ) ;
277
277
278
278
new_ucmd ! ( ) . args ( & [ "-t" , fs_type] ) . succeeds ( ) ;
@@ -292,7 +292,7 @@ fn test_type_option_with_file() {
292
292
let fs_type = new_ucmd ! ( )
293
293
. args ( & [ "--output=fstype" , "." ] )
294
294
. succeeds ( )
295
- . stdout_move_str ( ) ;
295
+ . stdout_str_lossy ( ) ;
296
296
let fs_type = fs_type. lines ( ) . nth ( 1 ) . unwrap ( ) . trim ( ) ;
297
297
298
298
new_ucmd ! ( ) . args ( & [ "-t" , fs_type, "." ] ) . succeeds ( ) ;
@@ -310,7 +310,7 @@ fn test_type_option_with_file() {
310
310
let fs_types = new_ucmd ! ( )
311
311
. arg ( "--output=fstype" )
312
312
. succeeds ( )
313
- . stdout_move_str ( ) ;
313
+ . stdout_str_lossy ( ) ;
314
314
let fs_types: Vec < _ > = fs_types
315
315
. lines ( )
316
316
. skip ( 1 )
@@ -335,7 +335,7 @@ fn test_exclude_all_types() {
335
335
let fs_types = new_ucmd ! ( )
336
336
. arg ( "--output=fstype" )
337
337
. succeeds ( )
338
- . stdout_move_str ( ) ;
338
+ . stdout_str_lossy ( ) ;
339
339
let fs_types: HashSet < _ > = fs_types. lines ( ) . skip ( 1 ) . collect ( ) ;
340
340
341
341
let mut args = Vec :: new ( ) ;
@@ -379,7 +379,7 @@ fn test_total() {
379
379
// ...
380
380
// /dev/loop14 63488 63488 0 100% /snap/core20/1361
381
381
// total 258775268 98099712 148220200 40% -
382
- let output = new_ucmd ! ( ) . arg ( "--total" ) . succeeds ( ) . stdout_move_str ( ) ;
382
+ let output = new_ucmd ! ( ) . arg ( "--total" ) . succeeds ( ) . stdout_str_lossy ( ) ;
383
383
384
384
// Skip the header line.
385
385
let lines: Vec < & str > = output. lines ( ) . skip ( 1 ) . collect ( ) ;
@@ -422,21 +422,21 @@ fn test_total_label_in_correct_column() {
422
422
let output = new_ucmd ! ( )
423
423
. args ( & [ "--output=source" , "--total" , "." ] )
424
424
. succeeds ( )
425
- . stdout_move_str ( ) ;
425
+ . stdout_str_lossy ( ) ;
426
426
let last_line = output. lines ( ) . last ( ) . unwrap ( ) ;
427
427
assert_eq ! ( last_line. trim( ) , "total" ) ;
428
428
429
429
let output = new_ucmd ! ( )
430
430
. args ( & [ "--output=target" , "--total" , "." ] )
431
431
. succeeds ( )
432
- . stdout_move_str ( ) ;
432
+ . stdout_str_lossy ( ) ;
433
433
let last_line = output. lines ( ) . last ( ) . unwrap ( ) ;
434
434
assert_eq ! ( last_line. trim( ) , "total" ) ;
435
435
436
436
let output = new_ucmd ! ( )
437
437
. args ( & [ "--output=source,target" , "--total" , "." ] )
438
438
. succeeds ( )
439
- . stdout_move_str ( ) ;
439
+ . stdout_str_lossy ( ) ;
440
440
let last_line = output. lines ( ) . last ( ) . unwrap ( ) ;
441
441
assert_eq ! (
442
442
last_line. split_whitespace( ) . collect:: <Vec <& str >>( ) ,
@@ -446,7 +446,7 @@ fn test_total_label_in_correct_column() {
446
446
let output = new_ucmd ! ( )
447
447
. args ( & [ "--output=target,source" , "--total" , "." ] )
448
448
. succeeds ( )
449
- . stdout_move_str ( ) ;
449
+ . stdout_str_lossy ( ) ;
450
450
let last_line = output. lines ( ) . last ( ) . unwrap ( ) ;
451
451
assert_eq ! (
452
452
last_line. split_whitespace( ) . collect:: <Vec <& str >>( ) ,
@@ -463,7 +463,7 @@ fn test_use_percentage() {
463
463
// "percentage" values.
464
464
. args ( & [ "--total" , "--output=used,avail,pcent" , "--block-size=1" ] )
465
465
. succeeds ( )
466
- . stdout_move_str ( ) ;
466
+ . stdout_str_lossy ( ) ;
467
467
468
468
// Skip the header line.
469
469
let lines: Vec < & str > = output. lines ( ) . skip ( 1 ) . collect ( ) ;
@@ -488,7 +488,7 @@ fn test_iuse_percentage() {
488
488
let output = new_ucmd ! ( )
489
489
. args ( & [ "--total" , "--output=itotal,iused,ipcent" ] )
490
490
. succeeds ( )
491
- . stdout_move_str ( ) ;
491
+ . stdout_str_lossy ( ) ;
492
492
493
493
// Skip the header line.
494
494
let lines: Vec < & str > = output. lines ( ) . skip ( 1 ) . collect ( ) ;
@@ -518,7 +518,7 @@ fn test_default_block_size() {
518
518
let output = new_ucmd ! ( )
519
519
. arg ( "--output=size" )
520
520
. succeeds ( )
521
- . stdout_move_str ( ) ;
521
+ . stdout_str_lossy ( ) ;
522
522
let header = output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( ) ;
523
523
524
524
assert_eq ! ( header, "1K-blocks" ) ;
@@ -527,7 +527,7 @@ fn test_default_block_size() {
527
527
. arg ( "--output=size" )
528
528
. env ( "POSIXLY_CORRECT" , "1" )
529
529
. succeeds ( )
530
- . stdout_move_str ( ) ;
530
+ . stdout_str_lossy ( ) ;
531
531
let header = output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( ) ;
532
532
533
533
assert_eq ! ( header, "512B-blocks" ) ;
@@ -547,14 +547,14 @@ fn test_default_block_size_in_posix_portability_mode() {
547
547
. to_string ( )
548
548
}
549
549
550
- let output = new_ucmd ! ( ) . arg ( "-P" ) . succeeds ( ) . stdout_move_str ( ) ;
550
+ let output = new_ucmd ! ( ) . arg ( "-P" ) . succeeds ( ) . stdout_str_lossy ( ) ;
551
551
assert_eq ! ( get_header( & output) , "1024-blocks" ) ;
552
552
553
553
let output = new_ucmd ! ( )
554
554
. arg ( "-P" )
555
555
. env ( "POSIXLY_CORRECT" , "1" )
556
556
. succeeds ( )
557
- . stdout_move_str ( ) ;
557
+ . stdout_str_lossy ( ) ;
558
558
assert_eq ! ( get_header( & output) , "512-blocks" ) ;
559
559
}
560
560
@@ -564,7 +564,7 @@ fn test_block_size_1024() {
564
564
let output = new_ucmd ! ( )
565
565
. args ( & [ "-B" , & format ! ( "{block_size}" ) , "--output=size" ] )
566
566
. succeeds ( )
567
- . stdout_move_str ( ) ;
567
+ . stdout_str_lossy ( ) ;
568
568
output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( )
569
569
}
570
570
@@ -588,7 +588,7 @@ fn test_block_size_with_suffix() {
588
588
let output = new_ucmd ! ( )
589
589
. args ( & [ "-B" , block_size, "--output=size" ] )
590
590
. succeeds ( )
591
- . stdout_move_str ( ) ;
591
+ . stdout_str_lossy ( ) ;
592
592
output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( )
593
593
}
594
594
@@ -612,7 +612,7 @@ fn test_block_size_in_posix_portability_mode() {
612
612
let output = new_ucmd ! ( )
613
613
. args ( & [ "-P" , "-B" , block_size] )
614
614
. succeeds ( )
615
- . stdout_move_str ( ) ;
615
+ . stdout_str_lossy ( ) ;
616
616
output
617
617
. lines ( )
618
618
. next ( )
@@ -639,7 +639,7 @@ fn test_block_size_from_env() {
639
639
. arg ( "--output=size" )
640
640
. env ( env_var, env_value)
641
641
. succeeds ( )
642
- . stdout_move_str ( ) ;
642
+ . stdout_str_lossy ( ) ;
643
643
output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( )
644
644
}
645
645
@@ -658,7 +658,7 @@ fn test_block_size_from_env_precedences() {
658
658
. env ( k1, v1)
659
659
. env ( k2, v2)
660
660
. succeeds ( )
661
- . stdout_move_str ( ) ;
661
+ . stdout_str_lossy ( ) ;
662
662
output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( )
663
663
}
664
664
@@ -677,7 +677,7 @@ fn test_precedence_of_block_size_arg_over_env() {
677
677
. args ( & [ "-B" , "999" , "--output=size" ] )
678
678
. env ( "DF_BLOCK_SIZE" , "111" )
679
679
. succeeds ( )
680
- . stdout_move_str ( ) ;
680
+ . stdout_str_lossy ( ) ;
681
681
let header = output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( ) ;
682
682
683
683
assert_eq ! ( header, "999B-blocks" ) ;
@@ -691,7 +691,7 @@ fn test_invalid_block_size_from_env() {
691
691
. arg ( "--output=size" )
692
692
. env ( "DF_BLOCK_SIZE" , "invalid" )
693
693
. succeeds ( )
694
- . stdout_move_str ( ) ;
694
+ . stdout_str_lossy ( ) ;
695
695
let header = output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( ) ;
696
696
697
697
assert_eq ! ( header, default_block_size_header) ;
@@ -701,7 +701,7 @@ fn test_invalid_block_size_from_env() {
701
701
. env ( "DF_BLOCK_SIZE" , "invalid" )
702
702
. env ( "BLOCK_SIZE" , "222" )
703
703
. succeeds ( )
704
- . stdout_move_str ( ) ;
704
+ . stdout_str_lossy ( ) ;
705
705
let header = output. lines ( ) . next ( ) . unwrap ( ) . trim ( ) . to_string ( ) ;
706
706
707
707
assert_eq ! ( header, default_block_size_header) ;
@@ -717,7 +717,7 @@ fn test_ignore_block_size_from_env_in_posix_portability_mode() {
717
717
. env ( "BLOCK_SIZE" , "222" )
718
718
. env ( "BLOCKSIZE" , "333" )
719
719
. succeeds ( )
720
- . stdout_move_str ( ) ;
720
+ . stdout_str_lossy ( ) ;
721
721
let header = output
722
722
. lines ( )
723
723
. next ( )
@@ -784,13 +784,13 @@ fn test_output_selects_columns() {
784
784
let output = new_ucmd ! ( )
785
785
. args ( & [ "--output=source" ] )
786
786
. succeeds ( )
787
- . stdout_move_str ( ) ;
787
+ . stdout_str_lossy ( ) ;
788
788
assert_eq ! ( output. lines( ) . next( ) . unwrap( ) , "Filesystem" ) ;
789
789
790
790
let output = new_ucmd ! ( )
791
791
. args ( & [ "--output=source,target" ] )
792
792
. succeeds ( )
793
- . stdout_move_str ( ) ;
793
+ . stdout_str_lossy ( ) ;
794
794
assert_eq ! (
795
795
output
796
796
. lines( )
@@ -804,7 +804,7 @@ fn test_output_selects_columns() {
804
804
let output = new_ucmd ! ( )
805
805
. args ( & [ "--output=source,target,used" ] )
806
806
. succeeds ( )
807
- . stdout_move_str ( ) ;
807
+ . stdout_str_lossy ( ) ;
808
808
assert_eq ! (
809
809
output
810
810
. lines( )
@@ -821,7 +821,7 @@ fn test_output_multiple_occurrences() {
821
821
let output = new_ucmd ! ( )
822
822
. args ( & [ "--output=source" , "--output=target" ] )
823
823
. succeeds ( )
824
- . stdout_move_str ( ) ;
824
+ . stdout_str_lossy ( ) ;
825
825
assert_eq ! (
826
826
output
827
827
. lines( )
@@ -840,7 +840,7 @@ fn test_output_file_all_filesystems() {
840
840
let output = new_ucmd ! ( )
841
841
. arg ( "--output=file" )
842
842
. succeeds ( )
843
- . stdout_move_str ( ) ;
843
+ . stdout_str_lossy ( ) ;
844
844
let mut lines = output. lines ( ) ;
845
845
assert_eq ! ( lines. next( ) . unwrap( ) , "File" ) ;
846
846
for line in lines {
@@ -862,7 +862,7 @@ fn test_output_file_specific_files() {
862
862
let output = ucmd
863
863
. args ( & [ "--output=file" , "a" , "b" , "c" ] )
864
864
. succeeds ( )
865
- . stdout_move_str ( ) ;
865
+ . stdout_str_lossy ( ) ;
866
866
let actual: Vec < & str > = output. lines ( ) . collect ( ) ;
867
867
assert_eq ! ( actual, vec![ "File" , "a" , "b" , "c" ] ) ;
868
868
}
@@ -876,7 +876,7 @@ fn test_file_column_width_if_filename_contains_unicode_chars() {
876
876
let output = ucmd
877
877
. args ( & [ "--output=file,target" , "äöü.txt" ] )
878
878
. succeeds ( )
879
- . stdout_move_str ( ) ;
879
+ . stdout_str_lossy ( ) ;
880
880
let actual = output. lines ( ) . next ( ) . unwrap ( ) ;
881
881
// expected width: 7 chars (length of äöü.txt) + 1 char (column separator)
882
882
assert_eq ! ( actual, "File Mounted on" ) ;
0 commit comments