Skip to content

Commit 8149c7f

Browse files
committed
Add hack for fwdansi change.
1 parent e55600b commit 8149c7f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/testsuite/cache_messages.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ fn color() {
9595
// Check enabling/disabling color.
9696
let p = project().file("src/lib.rs", "fn a() {}").build();
9797

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+
98112
let agnostic_path = Path::new("src").join("lib.rs");
99113
let agnostic_path_s = agnostic_path.to_str().unwrap();
100114
// Capture the original color output.
@@ -121,21 +135,21 @@ fn color() {
121135
.cargo("check -q --color=always")
122136
.exec_with_output()
123137
.expect("cargo to run");
124-
assert_eq!(rustc_color, as_str(&cargo_output1.stderr));
138+
compare(rustc_color, as_str(&cargo_output1.stderr));
125139

126140
// Replay cached, with color.
127141
let cargo_output2 = p
128142
.cargo("check -q --color=always")
129143
.exec_with_output()
130144
.expect("cargo to run");
131-
assert_eq!(rustc_color, as_str(&cargo_output2.stderr));
145+
compare(rustc_color, as_str(&cargo_output2.stderr));
132146

133147
// Replay cached, no color.
134148
let cargo_output_nocolor = p
135149
.cargo("check -q --color=never")
136150
.exec_with_output()
137151
.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));
139153
}
140154

141155
#[cargo_test]

0 commit comments

Comments
 (0)