Skip to content

[Console] CommandTester: disable color support detection #22194

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

Merged
merged 1 commit into from
Mar 31, 2017

Conversation

julienfalque
Copy link
Contributor

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

By default, the command tester relies on color support guessing to enable output decoration.

This is an issue for tests in that guessing is done against the stream instance on Linux and against the actual environment running the test on Windows, so color support can be detected on Windows even when the used stream is a memory stream like here, resulting in non-deterministic tests.

This PR disables output decoration by default. This will only change behavior on Windows with color support, as guessing on Linux always detects color as not supported for memory streams anyway. Tests should enable decoration explicitly when they want to test it.

A better fix would be to actually detect that we are using a memory stream on Windows as well, but I'm not sure it's possible.

@julienfalque julienfalque changed the base branch from master to 2.7 March 28, 2017 07:43
@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Mar 28, 2017
@stof
Copy link
Member

stof commented Mar 31, 2017

👍

@stof
Copy link
Member

stof commented Mar 31, 2017

Status: reviewed

@fabpot
Copy link
Member

fabpot commented Mar 31, 2017

Thank you @julienfalque.

@fabpot fabpot merged commit 3fe419c into symfony:2.7 Mar 31, 2017
fabpot added a commit that referenced this pull request Mar 31, 2017
…julienfalque)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] CommandTester: disable color support detection

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

By default, the command tester relies on [color support guessing](https://github.com/julienfalque/symfony/blob/3fe419cf66a8a9f033db54186896b142c5cbcada/src/Symfony/Component/Console/Output/StreamOutput.php#L91) to enable output decoration.

This is an issue for tests in that guessing is done against the stream instance on Linux and against the actual environment running the test on Windows, so color support can be detected on Windows even when the used stream is a memory stream like here, resulting in non-deterministic tests.

This PR disables output decoration by default. This will only change behavior on Windows with color support, as guessing on Linux always detects color as not supported for memory streams anyway. Tests should enable decoration explicitly when they want to test it.

A better fix would be to actually detect that we are using a memory stream on Windows as well, but I'm not sure it's possible.

Commits
-------

3fe419c Disable color support detection for tests
@keradus
Copy link
Member

keradus commented Mar 31, 2017

I see you were able to hunt it down @julienfalque , that's great! Thank you !

@julienfalque julienfalque deleted the command-tester-decoration branch March 31, 2017 15:42
This was referenced Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants