@@ -852,6 +852,56 @@ fn colorful_equals_colorless() {
852852 assert_eq ! ( colorful_stripped, colorless) ;
853853}
854854
855+ #[ test]
856+ fn color_always_with_and_without_ls_colors ( ) {
857+ let workspace = SampleWorkspace :: default ( ) ;
858+
859+ let with_ls_colors = Command :: new ( PDU )
860+ . with_current_dir ( & workspace)
861+ . with_arg ( "--color=always" )
862+ . with_arg ( "--total-width=100" )
863+ . with_env ( "LS_COLORS" , LS_COLORS )
864+ . pipe ( stdio)
865+ . output ( )
866+ . expect ( "spawn command with --color=always and LS_COLORS" ) ;
867+ inspect_stderr ( & with_ls_colors. stderr ) ;
868+ assert ! (
869+ with_ls_colors. status. success( ) ,
870+ "pdu exited with non-zero status"
871+ ) ;
872+ let with_ls_colors_stripped = with_ls_colors
873+ . stdout
874+ . pipe ( String :: from_utf8)
875+ . expect ( "UTF-8" )
876+ . pipe ( strip_ansi_escapes:: strip_str)
877+ . trim_end ( )
878+ . to_string ( ) ;
879+
880+ let mut without_ls_colors_cmd = Command :: new ( PDU )
881+ . with_current_dir ( & workspace)
882+ . with_arg ( "--color=always" )
883+ . with_arg ( "--total-width=100" ) ;
884+ without_ls_colors_cmd. env_remove ( "LS_COLORS" ) ;
885+ let without_ls_colors = without_ls_colors_cmd
886+ . pipe ( stdio)
887+ . output ( )
888+ . expect ( "spawn command with --color=always and without LS_COLORS" ) ;
889+ inspect_stderr ( & without_ls_colors. stderr ) ;
890+ assert ! (
891+ without_ls_colors. status. success( ) ,
892+ "pdu exited with non-zero status"
893+ ) ;
894+ let without_ls_colors_stripped = without_ls_colors
895+ . stdout
896+ . pipe ( String :: from_utf8)
897+ . expect ( "UTF-8" )
898+ . pipe ( strip_ansi_escapes:: strip_str)
899+ . trim_end ( )
900+ . to_string ( ) ;
901+
902+ assert_eq ! ( with_ls_colors_stripped, without_ls_colors_stripped) ;
903+ }
904+
855905#[ cfg( unix) ]
856906#[ test]
857907fn color_always ( ) {
@@ -880,7 +930,7 @@ fn color_always() {
880930 data_tree. par_sort_by ( |left, right| left. size ( ) . cmp ( & right. size ( ) ) . reverse ( ) ) ;
881931 * data_tree. name_mut ( ) = OsStringDisplay :: os_string_from ( "." ) ;
882932
883- let ls_colors: LsColors = LS_COLORS . parse ( ) . expect ( "parse LS_COLORS" ) ;
933+ let ls_colors = LsColors :: from_str ( LS_COLORS ) ;
884934 let map = HashMap :: from ( [
885935 (
886936 OsStringDisplay :: os_string_from ( "file-a1.txt" ) ,
0 commit comments