@@ -880,6 +880,81 @@ fn color_always() {
880880 assert_eq ! ( actual, expected) ;
881881}
882882
883+ #[ cfg( unix) ]
884+ #[ test]
885+ fn color_always_multiple_args ( ) {
886+ let workspace = SampleWorkspace :: simple_tree_with_diverse_kinds ( ) ;
887+
888+ let actual = Command :: new ( PDU )
889+ . with_current_dir ( & workspace)
890+ . with_arg ( "--color=always" )
891+ . with_arg ( "--quantity=apparent-size" )
892+ . with_arg ( "--total-width=100" )
893+ . with_arg ( "--min-ratio=0" )
894+ . with_arg ( "dir-a" )
895+ . with_arg ( "link-dir" )
896+ . with_env ( "LS_COLORS" , LS_COLORS )
897+ . pipe ( stdio)
898+ . output ( )
899+ . expect ( "spawn command with --color=always and multiple args" )
900+ . pipe ( stdout_text) ;
901+ eprintln ! ( "ACTUAL:\n {actual}\n " ) ;
902+
903+ let data_tree = [ "dir-a" , "link-dir" ]
904+ . iter ( )
905+ . map ( |name| {
906+ let builder = FsTreeBuilder {
907+ root : workspace. to_path_buf ( ) . join ( name) ,
908+ size_getter : GetApparentSize ,
909+ hardlinks_recorder : & HardlinkIgnorant ,
910+ reporter : & ErrorOnlyReporter :: new ( ErrorReport :: SILENT ) ,
911+ max_depth : 10 ,
912+ } ;
913+ let mut data_tree: DataTree < OsStringDisplay , _ > = builder. into ( ) ;
914+ * data_tree. name_mut ( ) = OsStringDisplay :: os_string_from ( name) ;
915+ data_tree
916+ } )
917+ . pipe ( |children| {
918+ DataTree :: dir (
919+ OsStringDisplay :: os_string_from ( "(total)" ) ,
920+ 0u64 . into ( ) ,
921+ children. collect ( ) ,
922+ )
923+ } )
924+ . into_par_sorted ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
925+
926+ let ls_colors = LsColors :: from_str ( LS_COLORS ) ;
927+ let leaf_colors = [
928+ ( "(total)/dir-a/file-a1.txt" , Color :: Normal ) ,
929+ ( "(total)/dir-a/file-a2.txt" , Color :: Normal ) ,
930+ ( "(total)/dir-a/subdir-a/file-a3.txt" , Color :: Normal ) ,
931+ ( "(total)/link-dir" , Color :: Symlink ) ,
932+ ] ;
933+ let leaf_colors = HashMap :: from ( leaf_colors. map ( |( path, color) | {
934+ (
935+ path. split ( '/' )
936+ . map ( AsRef :: < OsStr > :: as_ref)
937+ . collect :: < Vec < _ > > ( ) ,
938+ color,
939+ )
940+ } ) ) ;
941+ let coloring = Coloring :: new ( ls_colors, leaf_colors) ;
942+
943+ let visualizer = Visualizer :: < OsStringDisplay , _ > {
944+ data_tree : & data_tree,
945+ bytes_format : BytesFormat :: MetricUnits ,
946+ direction : Direction :: BottomUp ,
947+ bar_alignment : BarAlignment :: Left ,
948+ column_width_distribution : ColumnWidthDistribution :: total ( 100 ) ,
949+ coloring : Some ( & coloring) ,
950+ } ;
951+ let expected = format ! ( "{visualizer}" ) ;
952+ let expected = expected. trim_end ( ) ;
953+ eprintln ! ( "EXPECTED:\n {expected}\n " ) ;
954+
955+ assert_eq ! ( actual, expected) ;
956+ }
957+
883958#[ test]
884959fn colorful_equals_colorless ( ) {
885960 let workspace = SampleWorkspace :: default ( ) ;
0 commit comments