Skip to content

Commit 367fd9f

Browse files
authored
test: Don't look for a specfic ANSI color (#16118)
In rust-lang/rust#147207, I am changing `rustc` to `anstyle` for terminal styling. As part of this change, `rustc` will now be emitting `4-bit` ANSI colors instead of `8-bit` (256-color). That change is blocked on the `message_format::cargo_renders_ansi` test, which looks for a specific color sequence that `rustc` is no longer emitting and subsequently causes it to fail. To fix this, I made it so the test now looks for the start of an ANSI sequence instead of a specific sequence, as seeing the start of an ANSI escape sequence allows us to verify that ANSI colors are being emitted without the problems of looking for a specific sequence.
2 parents e1530bd + 773a037 commit 367fd9f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/testsuite/message_format.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ fn cargo_renders_ansi() {
120120

121121
p.cargo("check --message-format json-diagnostic-rendered-ansi")
122122
.with_status(101)
123-
.with_stdout_contains("[..]\\u001b[38;5;9merror[..]")
123+
// Because 1b is the start of an ANSI escape sequence, checking for it
124+
// allows us to verify that ANSI colors are being emitted without
125+
// looking for specific color codes, that may change over time.
126+
.with_stdout_contains("[..]\\u001b[..]")
124127
.run();
125128
}
126129

0 commit comments

Comments
 (0)