Skip to content

Commit

Permalink
fix: Improve color output detection
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 14, 2023
1 parent ccaac9a commit d98eabc
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 121 deletions.
158 changes: 105 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Expand Up @@ -32,21 +32,21 @@ pre-release-replacements = [
]

[features]
color = ["dep:yansi", "dep:concolor", "concolor?/std", "predicates/color"]
color-auto = ["color", "concolor?/auto"]
color = ["dep:anstyle-stream", "predicates/color"]
color-auto = ["color"]

[[bin]]
name = "bin_fixture"

[dependencies]
predicates = { version = "2.1", default-features = false, features = ["diff"] }
predicates-core = "1.0"
predicates-tree = "1.0"
predicates = { version = "3.0.1", default-features = false, features = ["diff"] }
predicates-core = "1.0.6"
predicates-tree = "1.0.1"
doc-comment = "0.3"
wait-timeout = "0.2.0"
bstr = "1.0.1"
yansi = { version = "0.5.1", optional = true }
concolor = { version = "0.0.12", optional = true }
anstyle-stream = { version = "0.2.1", optional = true }
anstyle = "0.3.1"

[dev-dependencies]
escargot = "0.5"
11 changes: 4 additions & 7 deletions src/assert.rs
Expand Up @@ -6,6 +6,8 @@ use std::fmt;
use std::process;
use std::str;

#[cfg(feature = "color")]
use anstyle_stream::panic;
use predicates::str::PredicateStrExt;
use predicates_tree::CaseTreeExt;

Expand Down Expand Up @@ -482,14 +484,9 @@ impl Assert {

impl fmt::Display for Assert {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let palette = crate::Palette::current();
let palette = crate::Palette::color();
for &(ref name, ref context) in &self.context {
writeln!(
f,
"{}=`{}`",
palette.key.paint(name),
palette.value.paint(context)
)?;
writeln!(f, "{:#}=`{:#}`", palette.key(name), palette.value(context))?;
}
output_fmt(&self.output, f)
}
Expand Down

0 comments on commit d98eabc

Please sign in to comment.