Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is wrong with control characters in PHPUnit command line tool?

When I run phpunit from a command line, the control characters are being printed out instead of acting like control characters. Take look at this:

PHPUnit 3.6.5 by Sebastian Bergmann.

Configuration read from app\phpunit.xml.dist

...

Time: 1 second, Memory: 12.00Mb

‹[30;42m‹[2KOK (3 tests, 3 assertions)
‹[0m‹[2K

I assume that signs like ‹[30;42m< are some kind of control characters and should be used by console in different way (positioning the cursor, deleting characters etc.)

What can be wrong here?

like image 306
Dawid Ohia Avatar asked Dec 30 '11 09:12

Dawid Ohia


2 Answers

This happens because you have configured phpunit to use colors.

<phpunit colors="true"

but sadly it is not possible to create colored output on a Windows terminal.

There is an open issue to not show those chars on windows where they can't be translated into colors on the phpunit issues tracker and I'm working on a patch for that.

For now all you can do is to ether accept it or to remove the color="true" from your phpunit.xml configuration file.

like image 70
edorian Avatar answered Sep 18 '22 12:09

edorian


Alternatively, just use https://github.com/adoxa/ansicon/releases to get ansi colors on windows.

Source code: https://github.com/adoxa/ansicon

like image 29
cweiske Avatar answered Sep 19 '22 12:09

cweiske