risinglightdb/sqllogictest-rs

TestError::display is hard to use

xxchan opened this issue · 3 comments

Because users generally will return Result in tests, and there's no chance to call display(true) to get colorful error message. If it's printed, it will be duplicate with the Err.

Maybe we can refer to https://docs.rs/pretty_assertions/latest/pretty_assertions/ about how can we opt-in colorful message in library usage.

pretty-assertions also suffer from this rust-pretty-assertions/rust-pretty-assertions#31

can we detect ANSI-colour support automatically?

In general, no.

runner
.run_async(record)
.await
.map_err(|e| anyhow!("{}", e.display(console::colors_enabled())))
.context(format!(
"failed to run `{}`",
style(filename.to_string_lossy()).bold()
))?;
}

I think this is actually acceptable 🤣