@@ -95,6 +95,20 @@ fn color() {
95
95
// Check enabling/disabling color.
96
96
let p = project ( ) . file ( "src/lib.rs" , "fn a() {}" ) . build ( ) ;
97
97
98
+ // Hack for issue in fwdansi 1.1. It is squashing multiple resets
99
+ // into a single reset.
100
+ // https://github.com/kennytm/fwdansi/issues/2
101
+ fn normalize ( s : & str ) -> String {
102
+ #[ cfg( windows) ]
103
+ return s. replace ( "\x1b [0m\x1b [0m" , "\x1b [0m" ) ;
104
+ #[ cfg( not( windows) ) ]
105
+ return s. to_string ( ) ;
106
+ } ;
107
+
108
+ let compare = |a, b| {
109
+ assert_eq ! ( normalize( a) , normalize( b) ) ;
110
+ } ;
111
+
98
112
let agnostic_path = Path :: new ( "src" ) . join ( "lib.rs" ) ;
99
113
let agnostic_path_s = agnostic_path. to_str ( ) . unwrap ( ) ;
100
114
// Capture the original color output.
@@ -121,21 +135,21 @@ fn color() {
121
135
. cargo ( "check -q --color=always" )
122
136
. exec_with_output ( )
123
137
. expect ( "cargo to run" ) ;
124
- assert_eq ! ( rustc_color, as_str( & cargo_output1. stderr) ) ;
138
+ compare ( rustc_color, as_str ( & cargo_output1. stderr ) ) ;
125
139
126
140
// Replay cached, with color.
127
141
let cargo_output2 = p
128
142
. cargo ( "check -q --color=always" )
129
143
. exec_with_output ( )
130
144
. expect ( "cargo to run" ) ;
131
- assert_eq ! ( rustc_color, as_str( & cargo_output2. stderr) ) ;
145
+ compare ( rustc_color, as_str ( & cargo_output2. stderr ) ) ;
132
146
133
147
// Replay cached, no color.
134
148
let cargo_output_nocolor = p
135
149
. cargo ( "check -q --color=never" )
136
150
. exec_with_output ( )
137
151
. expect ( "cargo to run" ) ;
138
- assert_eq ! ( rustc_nocolor, as_str( & cargo_output_nocolor. stderr) ) ;
152
+ compare ( rustc_nocolor, as_str ( & cargo_output_nocolor. stderr ) ) ;
139
153
}
140
154
141
155
#[ cargo_test]
0 commit comments