Skip to content

Commit a9b4fb0

Browse files
committed
Add colors
1 parent 175e48e commit a9b4fb0

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/expect/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ edition = "2018"
66

77
[dependencies]
88
once_cell = "1"
9+
difference = "2"
910
stdx = { path = "../stdx" }

crates/expect/src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,30 @@ impl Runtime {
107107
rt.help_printed = true;
108108

109109
let help = if print_help { HELP } else { "" };
110+
111+
let diff = difference::Changeset::new(actual, expected, "\n");
112+
110113
println!(
111114
"\n
112-
error: expect test failed{}
113-
--> {}:{}:{}
115+
\x1b[1m\x1b[91merror\x1b[97m: expect test failed\x1b[0m{}
116+
\x1b[1m\x1b[34m-->\x1b[0m {}:{}:{}
117+
{}
118+
\x1b[1mExpect\x1b[0m:
119+
----
114120
{}
115-
Expect:
121+
----
122+
123+
\x1b[1mActual\x1b[0m:
116124
----
117125
{}
118126
----
119127
120-
Actual:
128+
\x1b[1mDiff\x1b[0m:
121129
----
122130
{}
123131
----
124132
",
125-
updated, expect.file, expect.line, expect.column, help, expected, actual
133+
updated, expect.file, expect.line, expect.column, help, expected, actual, diff
126134
);
127135
// Use resume_unwind instead of panic!() to prevent a backtrace, which is unnecessary noise.
128136
std::panic::resume_unwind(Box::new(()));

0 commit comments

Comments
 (0)