Skip to content

Commit

Permalink
bug #22194 [Console] CommandTester: disable color support detection (…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
fabpot committed Mar 31, 2017
2 parents adf73aa + 3fe419c commit fb6de49
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Symfony/Component/Console/Tester/CommandTester.php
Expand Up @@ -70,9 +70,7 @@ public function execute(array $input, array $options = array())
}

$this->output = new StreamOutput(fopen('php://memory', 'w', false));
if (isset($options['decorated'])) {
$this->output->setDecorated($options['decorated']);
}
$this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
if (isset($options['verbosity'])) {
$this->output->setVerbosity($options['verbosity']);
}
Expand Down

0 comments on commit fb6de49

Please sign in to comment.