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

Colored output does not work anymore #1690

Closed
thunderer opened this issue Apr 22, 2015 · 16 comments
Closed

Colored output does not work anymore #1690

thunderer opened this issue Apr 22, 2015 · 16 comments

Comments

@thunderer
Copy link

Since around 4.5 colored output stopped working. It does not matter if it is triggered by phpunit --colors switch in console or colors = "true" in phpunit.xml, the line with result (green/yellow OK / red FAILURE) is not colored which makes it harder to quickly assess tests state. What works though is coloring output of --coverage-text, all lines are working as expected.

I couldn't find anything in the project documentation, there are no complaints about the issue on StackOverflow and other such places so I'm wondering what happened? I'm using Ubuntu 14.04 and ZSH shell, PHPUnit is installed through Composer.

@GrahamCampbell
Copy link
Contributor

This has already been discussed. Look at all the conversations on colour. :)

@GrahamCampbell
Copy link
Contributor

#1458
#1458
#1529
#719

@thunderer
Copy link
Author

Thanks for pointers to these issues, but I just noticed another issue: colors are present when PHPUnit is invoked like ./vendor/phpunit/phpunit/phpunit, but not with straight phpunit. In both cases PHPUnit reports latest version 4.6.4. Things get weird when it is invoked using phpunit --colors=always, in this case PHPUnit reports version 3.7.28 (Ubuntu DEB package version) and displays error "option --colors doesn't allow an argument".

@GrahamCampbell
Copy link
Contributor

case PHPUnit reports version 3.7.28 (Ubuntu DEB package version) and displays error "option --colors doesn't allow an argument".

Yes, you must be using a new 4.x version to use "always".

@GrahamCampbell
Copy link
Contributor

PHPUnit reports version 3.7.28

That version has the old behaviour, where "true" will do the same thing as "always" now does.

@thunderer
Copy link
Author

Yes, but isn't it strange that same command triggers different versions of the library? As I said, phpunit without parameters runs Composer version, but DEB version with them. I can't recall such behavior in older versions.

@GrahamCampbell
Copy link
Contributor

This is unrelated. This is just to do with your system setup. Nothing to do with phpunit. phpunit doesn't determine how to run itself. :)

@thunderer
Copy link
Author

When I uninstall system package phpunit command is not recognized. How do you then have it installed? Shell alias?

@thunderer
Copy link
Author

Ok, I managed to work around this issue by creating shell alias to vendor/phpunit/phpunit/phpunit and it's working now. Thanks for conversation.

@mzur
Copy link

mzur commented Jun 18, 2015

I' experiencing a similar issue. For one thing, the colors are not displayed any more (despite colors="true" in the phpunit.xml). Also the version seems to change when I use --colors=always. This shouldn't be an issue with the system setup since a command line argument doesn't change the binary that is called.

Example:

$ phpunit --filter NonexistentTest
PHPUnit 4.7.3 by Sebastian Bergmann and contributors.

Time: 175 ms, Memory: 9.75Mb

No tests executed!

$ phpunit --colors --filter NonexistentTest
PHPUnit 4.7.3 by Sebastian Bergmann and contributors.

Time: 176 ms, Memory: 9.75Mb

No tests executed!

$ phpunit --colors=always --filter NonexistentTest
PHPUnit 3.7.28 by Sebastian Bergmann.

option --colors doesn't allow an argument

Only with the suggested workaround of calling vendor/bin/phpunit colors are displayed again.

@sebastianbergmann
Copy link
Owner

Sorry, @mzur, but it appears that your PHP / PHPUnit environment is broken (mixed versions of PHPUnit). What you are posting does not make any sense.

@thunderer
Copy link
Author

@mzur I had the same issue, you probably have installed PHPUnit both as a system package (apt-get or something) and as a composer package in the project directory. Purge the system package and run alias phpunit=./vendor/bin/phpunit and everything should be okay.

@mzur
Copy link

mzur commented Jun 18, 2015

@thunderer That'll do but it's kind of a workaround still.

@sebastianbergmann I've digged a little deeper and it seems you're right. My system package is 3.7.28 and the local composer package 4.7.3. The first two calls of phpunit in my previous post seem to have been redirected to the local composer package somehow, whereas the last one wasn't. Don't ask me why but I'll be content with the suggested alias.

Thanks to you both :-)

@Xerkus
Copy link

Xerkus commented Mar 23, 2016

To anyone who does not have colors with --colors=auto or colors="true": you need to have posix extension installed.

@ianrussel
Copy link

Suggested alias also works for me.

@ob-ivan
Copy link

ob-ivan commented Feb 8, 2018

For those on Fedora: posix extension is installed as php-process package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants