mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
Add TextEmitter::with_color
and disable colors in unreadable_files
test (#19562)
Summary
--
I looked at other uses of `TextEmitter`, and I think this should be the
only one affected by this. The other integration tests must work
properly since they're run with `assert_cmd_snapshot!`, which I assume
triggers the `SHOULD_COLORIZE` case, and the `cfg!(test)` check will
work for uses in `ruff_linter`.
4a4dc38b5b/crates/ruff_linter/src/message/text.rs (L36-L44)
Alternatively, we could probably move this to a CLI test instead.
Test Plan
--
`cargo test -p ruff`, which was failing on `main` with color codes in
the output before this
This commit is contained in:
parent
4a4dc38b5b
commit
165091a31c
2 changed files with 7 additions and 0 deletions
|
@ -279,6 +279,7 @@ mod test {
|
||||||
|
|
||||||
TextEmitter::default()
|
TextEmitter::default()
|
||||||
.with_show_fix_status(true)
|
.with_show_fix_status(true)
|
||||||
|
.with_color(false)
|
||||||
.emit(
|
.emit(
|
||||||
&mut output,
|
&mut output,
|
||||||
&diagnostics.inner,
|
&diagnostics.inner,
|
||||||
|
|
|
@ -76,6 +76,12 @@ impl TextEmitter {
|
||||||
self.config = self.config.preview(preview);
|
self.config = self.config.preview(preview);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn with_color(mut self, color: bool) -> Self {
|
||||||
|
self.config = self.config.color(color);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Emitter for TextEmitter {
|
impl Emitter for TextEmitter {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue