Skip to content

Commit

Permalink
Merge pull request #165 from epage/anstream
Browse files Browse the repository at this point in the history
fix: Improve color output detection
  • Loading branch information
epage committed Mar 15, 2023
2 parents 13a8f3b + d98eabc commit 026c580
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .clippy.toml
@@ -1 +1 @@
msrv = "1.60.0" # MSRV
msrv = "1.64.0" # MSRV
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -51,15 +51,15 @@ jobs:
- name: No-default features
run: cargo test --workspace --no-default-features
msrv:
name: "Check MSRV: 1.60.0"
name: "Check MSRV: 1.64.0"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0 # MSRV
toolchain: 1.64.0 # MSRV
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0 # MSRV
toolchain: 1.64.0 # MSRV
profile: minimal
override: true
components: clippy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-next.yml
Expand Up @@ -59,9 +59,9 @@ jobs:
strategy:
matrix:
rust:
- 1.60.0 # MSRV
- 1.64.0 # MSRV
- stable
continue-on-error: ${{ matrix.rust != '1.60.0' }} # MSRV
continue-on-error: ${{ matrix.rust != '1.64.0' }} # MSRV
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
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.

16 changes: 8 additions & 8 deletions Cargo.toml
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"
categories = ["development-tools::testing"]
keywords = ["cli", "test", "assert", "command", "duct"]
edition = "2021"
rust-version = "1.60.0" # MSRV
rust-version = "1.64.0" # MSRV
include = [
"build.rs",
"src/**/*",
Expand All @@ -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 026c580

Please sign in to comment.