File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ struct StatPrinter {
9292 time_format : String ,
9393 line_ending : LineEnding ,
9494 summarize : bool ,
95+ total_text : String ,
9596}
9697
9798#[ derive( PartialEq , Clone ) ]
@@ -546,11 +547,7 @@ impl StatPrinter {
546547 }
547548
548549 if self . total {
549- print ! (
550- "{}\t {}" ,
551- self . convert_size( grand_total) ,
552- get_message( "du-total" )
553- ) ;
550+ print ! ( "{}\t {}" , self . convert_size( grand_total) , self . total_text) ;
554551 print ! ( "{}" , self . line_ending) ;
555552 }
556553
@@ -779,6 +776,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
779776 time,
780777 time_format,
781778 line_ending : LineEnding :: from_zero_flag ( matches. get_flag ( options:: NULL ) ) ,
779+ total_text : get_message ( "du-total" ) ,
782780 } ;
783781
784782 if stat_printer. inodes
Original file line number Diff line number Diff line change @@ -1295,3 +1295,25 @@ fn test_du_inodes_blocksize_ineffective() {
12951295 ) ;
12961296 }
12971297}
1298+
1299+ #[ test]
1300+ fn test_du_inodes_total_text ( ) {
1301+ let ts = TestScenario :: new ( util_name ! ( ) ) ;
1302+ let at = & ts. fixtures ;
1303+
1304+ at. mkdir_all ( "d/d" ) ;
1305+
1306+ let result = ts. ucmd ( ) . arg ( "--inodes" ) . arg ( "-c" ) . arg ( "d" ) . succeeds ( ) ;
1307+
1308+ let lines: Vec < & str > = result. stdout_str ( ) . lines ( ) . collect ( ) ;
1309+
1310+ assert_eq ! ( lines. len( ) , 3 ) ;
1311+
1312+ let total_line = lines. last ( ) . unwrap ( ) ;
1313+ assert ! ( total_line. contains( "total" ) ) ;
1314+
1315+ let parts: Vec < & str > = total_line. split ( '\t' ) . collect ( ) ;
1316+ assert_eq ! ( parts. len( ) , 2 ) ;
1317+
1318+ assert ! ( parts[ 0 ] . parse:: <u64 >( ) . is_ok( ) ) ;
1319+ }
You can’t perform that action at this time.
0 commit comments