Skip to content

Commit

Permalink
Merge pull request #28 from Phundrak/master
Browse files Browse the repository at this point in the history
Fix ANSI colors in Windows CMD and PowerShell
  • Loading branch information
colin-kiegel committed Feb 20, 2019
2 parents 55fb3e9 + f33286c commit 13fa78f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Cargo.toml
Expand Up @@ -19,3 +19,7 @@ travis-ci = { repository = "colin-kiegel/rust-pretty-assertions" }
[dependencies]
difference = "2.0.0"
ansi_term = "0.11"

[target.'cfg(windows)'.dependencies]
output_vt100 = "0.1"
ctor = "0.1.7"
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -69,6 +69,8 @@ use pretty_assertions::{assert_eq, assert_ne};
you include.
* `assert_ne` is also switched to multi-line presentation, but does _not_ show
a diff.
* Under Windows, the terminal state is modified to properly handle VT100
escape sequences, which may break display for certain use cases.

## License

Expand Down
16 changes: 15 additions & 1 deletion src/lib.rs
Expand Up @@ -2,7 +2,7 @@
//!
//! When writing tests in Rust, you'll probably use `assert_eq!(a, b)` _a lot_.
//!
//! If such a test fails, it will present all the details of `a` and `b`.
//! If such a test fails, it will present all the details of `a` and `b`.
//! But you have to spot the differences yourself, which is not always straightforward,
//! like here:
//!
Expand Down Expand Up @@ -67,6 +67,12 @@

extern crate difference;
extern crate ansi_term;

#[cfg(windows)]
extern crate output_vt100;
#[cfg(windows)]
extern crate ctor;

mod format_changeset;

use std::fmt::{self, Debug, Display};
Expand All @@ -75,6 +81,14 @@ use difference::Changeset;
use crate::format_changeset::format_changeset;
pub use ansi_term::Style;

#[cfg(windows)]
use ctor::*;
#[cfg(windows)]
#[ctor]
fn init() {
output_vt100::init();
}

#[doc(hidden)]
pub struct Comparison(Changeset);

Expand Down

0 comments on commit 13fa78f

Please sign in to comment.