mirror of
https://github.com/openai/codex.git
synced 2026-04-28 02:11:08 +03:00
test(tui2): narrow disallowed_methods suppression
The SGR writer tests intentionally construct truecolor (RGB) and indexed colors so the emitted escape sequences are deterministic. Replace the blanket allow on the whole test with statement-level `#[expect(clippy::disallowed_methods)]` on the specific constructors (`Color::Rgb`/`Color::Indexed`), with inline rationale.
This commit is contained in:
@@ -321,14 +321,22 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
fn write_spans_emits_truecolor_and_indexed_sgr() {
|
||||
let spans = [Span::styled(
|
||||
"X",
|
||||
Style::default()
|
||||
.fg(Color::Rgb(1, 2, 3))
|
||||
.bg(Color::Indexed(42)),
|
||||
)];
|
||||
// This test asserts that `write_spans` emits the correct SGR sequences for colors that
|
||||
// can't be represented with the theme-aware ANSI palette:
|
||||
//
|
||||
// - `ratatui::style::Color::Rgb` (truecolor; `38;2;r;g;b`)
|
||||
// - `ratatui::style::Color::Indexed` (256-color index; `48;5;n`)
|
||||
//
|
||||
// Those constructors are intentionally disallowed in production code (see
|
||||
// `codex-rs/clippy.toml`), but the test needs them so the output bytes are fully
|
||||
// deterministic.
|
||||
#[expect(clippy::disallowed_methods)]
|
||||
let fg = Color::Rgb(1, 2, 3);
|
||||
#[expect(clippy::disallowed_methods)]
|
||||
let bg = Color::Indexed(42);
|
||||
|
||||
let spans = [Span::styled("X", Style::default().fg(fg).bg(bg))];
|
||||
|
||||
let mut actual: Vec<u8> = Vec::new();
|
||||
write_spans(&mut actual, spans.iter()).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user