@@ -623,7 +623,6 @@ fn multiple_names() {
623623 OsStringDisplay :: os_string_from ( "(total)" ) ,
624624 0 . into ( ) ,
625625 children. collect ( ) ,
626- 10 ,
627626 )
628627 } )
629628 . into_par_sorted ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
@@ -640,4 +639,132 @@ fn multiple_names() {
640639 eprintln ! ( "EXPECTED:\n {expected}\n " ) ;
641640
642641 assert_eq ! ( actual, expected) ;
642+
643+ let mut lines = actual. lines ( ) ;
644+ assert ! ( lines. next( ) . unwrap( ) . contains( "┌──1" ) ) ;
645+ assert ! ( lines. next( ) . unwrap( ) . contains( "┌─┴0" ) ) ;
646+ assert ! ( lines. next( ) . unwrap( ) . contains( "┌─┴nested" ) ) ;
647+ assert ! ( lines. next( ) . unwrap( ) . contains( "│ ┌──1" ) ) ;
648+ assert ! ( lines. next( ) . unwrap( ) . contains( "│ ├──2" ) ) ;
649+ assert ! ( lines. next( ) . unwrap( ) . contains( "│ ├──3" ) ) ;
650+ assert ! ( lines. next( ) . unwrap( ) . contains( "├─┴flat" ) ) ;
651+ assert ! ( lines. next( ) . unwrap( ) . contains( "┌─┴(total)" ) ) ;
652+ assert_eq ! ( lines. next( ) , None ) ;
653+ }
654+
655+ #[ test]
656+ fn multiple_names_max_depth_2 ( ) {
657+ let workspace = SampleWorkspace :: default ( ) ;
658+ let actual = Command :: new ( PDU )
659+ . with_current_dir ( & workspace)
660+ . with_arg ( "--quantity=apparent-size" )
661+ . with_arg ( "--total-width=100" )
662+ . with_arg ( "--max-depth=2" )
663+ . with_arg ( "nested" )
664+ . with_arg ( "flat" )
665+ . with_arg ( "empty-dir" )
666+ . pipe ( stdio)
667+ . output ( )
668+ . expect ( "spawn command" )
669+ . pipe ( stdout_text) ;
670+ eprintln ! ( "ACTUAL:\n {actual}\n " ) ;
671+
672+ let mut data_tree = [ "nested" , "flat" , "empty-dir" ]
673+ . iter ( )
674+ . map ( |name| {
675+ let builder = FsTreeBuilder {
676+ root : workspace. to_path_buf ( ) . join ( name) ,
677+ size_getter : GetApparentSize ,
678+ reporter : ErrorOnlyReporter :: new ( ErrorReport :: SILENT ) ,
679+ max_depth : 1 ,
680+ } ;
681+ let mut data_tree: DataTree < OsStringDisplay , _ > = builder. into ( ) ;
682+ * data_tree. name_mut ( ) = OsStringDisplay :: os_string_from ( name) ;
683+ data_tree
684+ } )
685+ . pipe ( |children| {
686+ DataTree :: dir (
687+ OsStringDisplay :: os_string_from ( "(total)" ) ,
688+ 0 . into ( ) ,
689+ children. collect ( ) ,
690+ )
691+ } )
692+ . into_par_sorted ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
693+ data_tree. par_cull_insignificant_data ( 0.01 ) ;
694+ let visualizer = Visualizer :: < OsStringDisplay , _ > {
695+ data_tree : & data_tree,
696+ bytes_format : BytesFormat :: MetricUnits ,
697+ direction : Direction :: BottomUp ,
698+ bar_alignment : BarAlignment :: Left ,
699+ column_width_distribution : ColumnWidthDistribution :: total ( 100 ) ,
700+ } ;
701+ let expected = format ! ( "{visualizer}" ) ;
702+ let expected = expected. trim_end ( ) ;
703+ eprintln ! ( "EXPECTED:\n {expected}\n " ) ;
704+
705+ assert_eq ! ( actual, expected) ;
706+
707+ let mut lines = actual. lines ( ) ;
708+ assert ! ( lines. next( ) . unwrap( ) . contains( "┌──nested" ) ) ;
709+ assert ! ( lines. next( ) . unwrap( ) . contains( "├──flat" ) ) ;
710+ assert ! ( lines. next( ) . unwrap( ) . contains( "┌─┴(total)" ) ) ;
711+ assert_eq ! ( lines. next( ) , None ) ;
712+ }
713+
714+ #[ test]
715+ fn multiple_names_max_depth_1 ( ) {
716+ let workspace = SampleWorkspace :: default ( ) ;
717+ let actual = Command :: new ( PDU )
718+ . with_current_dir ( & workspace)
719+ . with_arg ( "--quantity=apparent-size" )
720+ . with_arg ( "--total-width=100" )
721+ . with_arg ( "--max-depth=1" )
722+ . with_arg ( "nested" )
723+ . with_arg ( "flat" )
724+ . with_arg ( "empty-dir" )
725+ . pipe ( stdio)
726+ . output ( )
727+ . expect ( "spawn command" )
728+ . pipe ( stdout_text) ;
729+ eprintln ! ( "ACTUAL:\n {actual}\n " ) ;
730+
731+ let mut data_tree = [ "nested" , "flat" , "empty-dir" ]
732+ . iter ( )
733+ . map ( |name| {
734+ let builder = FsTreeBuilder {
735+ root : workspace. to_path_buf ( ) . join ( name) ,
736+ size_getter : GetApparentSize ,
737+ reporter : ErrorOnlyReporter :: new ( ErrorReport :: SILENT ) ,
738+ max_depth : 10 ,
739+ } ;
740+ let mut data_tree: DataTree < OsStringDisplay , _ > = builder. into ( ) ;
741+ * data_tree. name_mut ( ) = OsStringDisplay :: os_string_from ( name) ;
742+ data_tree
743+ } )
744+ . pipe ( |children| {
745+ DataTree :: dir (
746+ OsStringDisplay :: os_string_from ( "(total)" ) ,
747+ 0 . into ( ) ,
748+ children. collect ( ) ,
749+ )
750+ } )
751+ . into_par_retained ( |_, _| false )
752+ . into_par_sorted ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
753+ data_tree. par_cull_insignificant_data ( 0.01 ) ;
754+ let visualizer = Visualizer :: < OsStringDisplay , _ > {
755+ data_tree : & data_tree,
756+ bytes_format : BytesFormat :: MetricUnits ,
757+ direction : Direction :: BottomUp ,
758+ bar_alignment : BarAlignment :: Left ,
759+ column_width_distribution : ColumnWidthDistribution :: total ( 100 ) ,
760+ } ;
761+ let expected = format ! ( "{visualizer}" ) ;
762+ let expected = expected. trim_end ( ) ;
763+ eprintln ! ( "EXPECTED:\n {expected}\n " ) ;
764+
765+ assert_eq ! ( actual, expected) ;
766+
767+ let mut lines = actual. lines ( ) ;
768+ assert ! ( lines. next( ) . unwrap( ) . contains( "┌──(total)" ) ) ;
769+ assert_eq ! ( lines. next( ) , None ) ;
643770}
0 commit comments