8000 bug #22194 [Console] CommandTester: disable color support detection (… · symfony/symfony@fb6de49 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb6de49

Browse files
committed
bug #22194 [Console] CommandTester: disable color support detection (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
2 parents adf73aa + 3fe419c commit fb6de49

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/Symfony/Component/Console/Tester/CommandTester.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ public function execute(array $input, array $options = array())
7070
}
7171

7272
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
73-
if (isset($options['decorated'])) {
74-
$this->output->setDecorated($options['decorated']);
75-
}
73+
$this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
7674
if (isset($options['verbosity'])) {
7775
$this->output->setVerbosity($options['verbosity']);
7876
}

0 commit comments

Comments
 (0)
0