-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] default to stderr in the console helpers #15794
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
Conversation
@@ -454,6 +467,10 @@ private function validateAttempts($interviewer, OutputInterface $output, $valida | |||
{ | |||
$e = null; | |||
while (false === $attempts || $attempts--) { | |||
if ($output instanceof ConsoleOutputInterface) { | |||
$output = $output->getErrorOutput(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be outside the loop
Could you create another PR against 2.7 that changes |
Yes already working on a PR for 2.7. Are |
SymfonyQuestionHelper extends QuestionHelper and thus should be convered already |
Please let me know if #15795 covers it or if any amendments need to be made. |
@Seldaek here you go (again). |
👍 Status: Reviewed |
Tests covering this are missing |
What would be an acceptable test scenario in your opinion, to validate these changes? |
@alcohol Creating the helper with a ConsoleOutputInterface, and asserting that it writes its output to the error output. |
Allright. Will implement something later today. Thanks for the feedback. |
Status: Needs Work |
@Tobion got any tips? I tried the following for the public function testAskOnStderrWithConsoleOutput()
{
if (!$this->hasSttyAvailable()) {
$this->markTestSkipped('`stderr` is required to test stderr output functionality');
}
$dialog = new DialogHelper();
$dialog->setInputStream($this->getInputStream("\nnot stdout\n"));
$this->assertEquals('stderr', $dialog->ask(new ConsoleOutput(), 'Where should output go?', 'stderr'));
$this->assertEquals('not stdout', $dialog->ask($output = new ConsoleOutput(), 'Where should output go?', 'stderr'));
rewind($output->getErrorOutput()->getStream());
$this->assertEquals('Where should output go?', stream_get_contents($output->getErrorOutput()->getStream()));
}
I noticed all the tests use |
… (alcohol) This PR was merged into the 2.7 branch. Discussion ---------- [Console] Default to stderr for the console helpers (2.7+) Interactive input/output and informational output such as progress should go to `stderr` if available. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Only merge if #15794 is merged. If someone explicitly wants to use `stdout`, they can simply pass `$output->getStream()` instead of `$output` in most use-cases. Commits ------- 90c2a96 Default to stderr for console helpers (only merge if #15794 gets merged)
* 2.7: [Config] Fix enum default value in Yaml dumper Finnish translation fix [CssSelector] Optimize regexs matching simple selectors Fix the phpdoc in the CssSelector TranslatorInterface [Console] Add clock mock to fix transient test on HHVM [DomCrawler] Optimize the regex used to find namespace prefixes [EventDispatcher] skip one lazy loading call [EventDispatcher] fix memory leak in a getListeners Default to stderr for console helpers (only merge if #15794 gets merged)
* 2.8: Added the right revision date for status code registry [Config] Fix enum default value in Yaml dumper fixed typo. [Translation][File dumper] allow get file content without writing in file. Finnish translation fix [CssSelector] Optimize regexs matching simple selectors Fix the phpdoc in the CssSelector TranslatorInterface [Console] Add clock mock to fix transient test on HHVM [DomCrawler] Optimize the regex used to find namespace prefixes [VarDumper] Add EnumStub for dumping virtual collections with casters [Finder] Deprecate adapters and related classes [EventDispatcher] skip one lazy loading call [EventDispatcher] fix memory leak in a getListeners [WebProfilerBundle] added btn-link. Remove duplication of the handling of regex filters in the Finder Default to stderr for console helpers (only merge if #15794 gets merged) Conflicts: src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php src/Symfony/Component/EventDispatcher/EventDispatcher.php src/Symfony/Component/VarDumper/Tests/CliDumperTest.php src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
Hi everyone ! |
@keradus not sure, getting dusty? :d |
Thank you @alcohol. |
This PR was squashed before being merged into the 2.3 branch (closes #15794). Discussion ---------- [Console] default to stderr in the console helpers Interactive input/output and informational output such as progress should go to `stderr` if available. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | See #13730 also for previous discussion. If someone explicitly wants to use `stdout`, they can simply pass `$output->getStream()` instead of `$output` in most use-cases. Commits ------- 3d4e95e [Console] default to stderr in the console helpers
* 2.8: Added the right revision date for status code registry [Config] Fix enum default value in Yaml dumper fixed typo. [Translation][File dumper] allow get file content without writing in file. Finnish translation fix [CssSelector] Optimize regexs matching simple selectors Fix the phpdoc in the CssSelector TranslatorInterface [Console] Add clock mock to fix transient test on HHVM [DomCrawler] Optimize the regex used to find namespace prefixes [VarDumper] Add EnumStub for dumping virtual collections with casters [Finder] Deprecate adapters and related classes [EventDispatcher] skip one lazy loading call [EventDispatcher] fix memory leak in a getListeners [WebProfilerBundle] added btn-link. Remove duplication of the handling of regex filters in the Finder Default to stderr for console helpers (only merge if symfony#15794 gets merged) Conflicts: src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php src/Symfony/Component/EventDispatcher/EventDispatcher.php src/Symfony/Component/VarDumper/Tests/CliDumperTest.php src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
Interactive input/output and informational output such as progress should go to
stderr
if available.See #13730 also for previous discussion.
If someone explicitly wants to use
stdout
, they can simply pass$output->getStream()
instead of$output
in most use-cases.