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

--colors=never is not respected #49

Closed
maks-rafalko opened this issue May 30, 2020 · 6 comments
Closed

--colors=never is not respected #49

maks-rafalko opened this issue May 30, 2020 · 6 comments

Comments

@maks-rafalko
Copy link

When I run

vendor/bin/pest --colors=never

Pest continues printing ascii chars that produces the following text:

  �[37;41;1m FAIL �[39;49;22m�[39m PestExample\Test\PhpUnitSourceFileTest�[39m
  �[31;1m•�[39;22m�[39m �[2mit can add two integers�[22m�[39m

  �[2m---�[22m

  �[31;1m• PestExample\Test\PhpUnitSourceFileTest �[39;22m> �[31;1mit can add two integers�[39;22m
  �[41;1m Error �[49;22m

�[39;1m  Call to protected method PestExample\SourceFile::add() from context 'PestExample\Test\PhpUnitSourceFileTest'�[39;22m

  at �[32mtests/PhpUnitSourceFileTest.php�[39m:�[32m18�[39m
     14▕     public function test_it_can_add_two_integers(): void
     15▕     {
     16▕         $source = new SourceFile();
     17▕ 
  ➜  18▕         $result = $source->add(3, 2);
     19▕ 
     20▕         $this->assertGreaterThan(0, $result);
     21▕     }
     22▕ }



  �[37;1mTests:  �[39;22m�[31;1m1 failed�[39;22m
  �[37;1mTime:   �[39;22m�[39m0.03s�[39m

For example, when I use --colors=never with PHPUnit, it correctly disables and prints just raw text:

PHPUnit 9.1.5 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Time: 00:00.046, Memory: 6.00 MB

Related to #4 (In Infection PHP, we need a "raw" output without all those colours for terminal to parse the text);

Even without Infection, it's still the issue as some CI do not support such output as well

@nunomaduro
Copy link
Member

@maks-rafalko Maybe is better just change the printer to the default phpunit printer. what do you think?

@maks-rafalko
Copy link
Author

maks-rafalko commented May 30, 2020

  1. is it possible right now? can't find anything related
  2. if it's possibl (or will be) - will I be able to use --colors=never with default PHPUnit printer?
  3. I still think colors=never should be supported by Pest. Why? For example, if Pest is used for Jenkins, there is no support for ascii codes (from what I see in my daily job :) ). So I see [37;41;1m FAIL insteaf of pretty raw FAIL

@Jibbarth
Copy link
Collaborator

To launch Pest with default phpunit printer, I usually do :

vendor/bin/pest --printer \\PHPUnit\\TextUI\\DefaultResultPrinter

Just try with --colors=never, work as expected 😉

Anyway, to support in in pest, this could be done:

// src/Actions/AddsDefaults.php
        if (!array_key_exists('printer', $arguments)) {
-            $arguments['printer'] = new Printer();
+            $arguments['printer'] = new Printer(null, $arguments['verbose'] ?? false, $arguments['colors'] ?? 'always');
        }

@maks-rafalko
Copy link
Author

Thank you!

@crossworth
Copy link

Hi, I'm facing a problem when using pest on Windows.

When I run pest --colors=never, the output is not quite right.

pest
image

pest --colors=never
image

Just to make it clear, if I run from a terminal that supports colors, it will print the colors correctly, the issue here is the fact that --colors=never still sends colors information.

@owenvoke
Copy link
Member

@crossworth, I think this is actually an issue with Collision rather than Pest.

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

5 participants