Support simple colored diffs
dkarlovi opened this issue · 2 comments
dkarlovi commented
When doing this in PHPUnit
static::assertEquals(['aa', 'bb'], ['aa', 'cc']);
Output comes out as
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => 'aa'
- 1 => 'bb'
+ 1 => 'cc'
)
but, if PHPUnit is in color mode, it could come out as
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => 'aa'
- 1 => 'bb'
+ 1 => 'cc'
)
The way to go about it seems like:
- add color mode to output here
- make PHPUnit tell Comparator to be in color mode
- make Comparator pass the information along
Don't know if I'm missing something or if this is the correct repo to create this issue, seems like the correct way forward.
SpacePossum commented
I wouldn't increase the scope of the library with output formatters.
The lib creates strings in the well known/documented diff
format, this should allow any to process the output and apply what ever operation on it (like adding console coloring and sending it to the console).
sebastianbergmann commented
I agree with @SpacePossum.