Skip to content

Commit 776ba5f

Browse files
committed
Auto merge of #7607 - ehuss:fwdansi-hack, r=alexcrichton
Add hack for fwdansi change. This is a hack to fix a test failing on CI. The issue is that fwdansi 1.1 was published with a change on how it processes reset codes. I have filed kennytm/fwdansi#2 with some details on some of the issues. This is just a workaround to get the test to pass. I'm not too happy with it, but other choices seemed less than ideal. Am happy to consider them, though: - Remove fwdansi, and give up supporting color on Win 7/8, old 10. - Change `Shell` so that it knows whether or not the console supports ANSI, and only use fwdansi when necessary. This means Win 10 would stop using fwdansi, but 7/8 would continue to use it. It is a little awkward – I think it would have to call wincolor::set_virtual_terminal_processing and see if it succeeds. - Wait for a change to fwdansi to make resets more transparent. I am very tempted by the first choice. rustc's color output has been broken on win 7/8 for a long time, and only a very small number of people have complained. I have spent way too much time dealing with something I think nobody really uses. cc @kennytm
2 parents e55600b + 8149c7f commit 776ba5f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/testsuite/cache_messages.rs

+17-3
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)