bacon icon indicating copy to clipboard operation
bacon copied to clipboard

Show color in doc test results

Open joshka opened this issue 1 year ago • 1 comments

Bacon doesn't appear to colorize test failures in doc tests:

Given the following Error code (intentionally created):

    /// # Examples
    ///
    /// ```
    /// # use ratatui::{prelude::*, buffer::Cell, layout::Position};
    /// let buf = Buffer::empty(Rect::new(0, 0, 10, 10));
    /// let cell = buf[(0, 0)];
    /// let cell = &buf[Position::new(0, 0)];
    /// ```

Cargo test --doc buffer/buffer output:

image

Bacon config:

[jobs.test]
command = [
    "cargo", "test",
    "--all-features",
    "--color", "always",
    "--", "--color", "always", # see https://github.com/Canop/bacon/issues/124
]
need_stdout = true

Bacon output: image

joshka avatar May 30 '24 21:05 joshka

It looks like cargo test doesn't respect the --color always argument. This might be a regression in cargo test (but it's also possible this was always the case, cargo test is a weird complicated construct).

Canop avatar May 31 '24 05:05 Canop

I'm seeing --color always as working for cargo test.

  • cargo test &> tmp.txt --> no color
  • cargo test --color always &> tmp2.txt --> color

version: cargo 1.93.0-nightly (445fe4a68 2025-11-07)

Possibly related upstream discussion: https://github.com/rust-lang/cargo/issues/1983

willhansen avatar Nov 12 '25 15:11 willhansen

Hum. Unless I miss something, it does look like colors are back in cargo test output...

(I'm quite sure I'm missing something, in fact, as I get colors also with a cargo +1.60 test)

Canop avatar Nov 12 '25 15:11 Canop