From a9b4fb034bab194bef80c75f146288e55ae8aa2d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 27 Jun 2020 21:13:49 +0200 Subject: Add colors --- crates/expect/src/lib.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'crates/expect/src') diff --git a/crates/expect/src/lib.rs b/crates/expect/src/lib.rs index dc4a4223e..18f361ec2 100644 --- a/crates/expect/src/lib.rs +++ b/crates/expect/src/lib.rs @@ -107,22 +107,30 @@ impl Runtime { rt.help_printed = true; let help = if print_help { HELP } else { "" }; + + let diff = difference::Changeset::new(actual, expected, "\n"); + println!( "\n -error: expect test failed{} - --> {}:{}:{} +\x1b[1m\x1b[91merror\x1b[97m: expect test failed\x1b[0m{} + \x1b[1m\x1b[34m-->\x1b[0m {}:{}:{} +{} +\x1b[1mExpect\x1b[0m: +---- {} -Expect: +---- + +\x1b[1mActual\x1b[0m: ---- {} ---- -Actual: +\x1b[1mDiff\x1b[0m: ---- {} ---- ", - updated, expect.file, expect.line, expect.column, help, expected, actual + updated, expect.file, expect.line, expect.column, help, expected, actual, diff ); // Use resume_unwind instead of panic!() to prevent a backtrace, which is unnecessary noise. std::panic::resume_unwind(Box::new(())); -- cgit v1.2.3