Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ANSI colors in Windows CMD and PowerShell #28

Merged
merged 5 commits into from Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Expand Up @@ -18,3 +18,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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -67,6 +67,8 @@ extern crate pretty_assertions;
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 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