Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Detect EOF when reading input stream#1704

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromlenar:dialoghelper-eof
Jul 27, 2011
Merged

[Console] Detect EOF when reading input stream#1704

fabpot merged 1 commit intosymfony:masterfromlenar:dialoghelper-eof
Jul 27, 2011

Conversation

lenar
Copy link
Contributor

This is related to commits511a9a1 and3a5d508.

First of them introduced abort-on-EOF and the second regressed the functionality.
Problem is stream_get_line() doesn't return false on EOF. So it needs call to feof() to
detect the situation.

Still, it's not ideal. With fgets() it worked fine, but with stream_get_line() one has to press
CTRL+D twice to get out. I presume this could be bug in PHP itself.

But better than nothing. Please consider.

@fabpot
Copy link
Member

I have usedstream_get_line especially because it does not returnfalse on eof. This is needed when you pass your own stream for unit tests.

@lenar
Copy link
ContributorAuthor

This is not the best solution I think. Tests should mimic and cope with real life not the other way around.
Better solution would be to fix testcase. Like this:lenar/SensioGeneratorBundle@6ff3f26. Or maybe create a special "testing" stream wrapper that wraps php://memory and gives out just linefeeds after real data ends.

And then change stream_get_line() back to fgets() if there is no other reason for this change.

@fabpot
Copy link
Member

When applying your patch to the generator bundle (and revert to usefgets), I get "RuntimeException: Aborted" exceptions.

@lenar
Copy link
ContributorAuthor

With d326f89 added +lenar/SensioGeneratorBundle@6ff3f26 I can successfully run every test in that file.

@fabpot
Copy link
Member

@lenar: not for me. I have many 'Aborted' exception on my Mac.

@fabpot
Copy link
Member

And I have the exact same errors on Linux:

There were 7 errors:1) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateBundleCommandTest::testInteractiveCommand with data set #0 (array('/tmp'), 'Foo/BarBundle', array('Foo\\BarBundle', 'FooBarBundle', '/tmp/', 'annotation', false))RuntimeException: Aborted.../Symfony/Component/Console/Helper/DialogHelper.php:40.../Symfony/Component/Console/Helper/DialogHelper.php:97.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateBundleCommand.php:165.../Symfony/Component/Console/Command/Command.php:205.../Symfony/Component/Console/Tester/CommandTester.php:66.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateBundleCommandTest.php:392) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateBundleCommandTest::testInteractiveCommand with data set #1 (array('/tmp'), 'Foo/BarBundleBarBundlefooymln', array('Foo\\BarBundle', 'BarBundle', 'foo/', 'yml', false))RuntimeException: Aborted.../Symfony/Component/Console/Helper/DialogHelper.php:40.../Symfony/Component/Console/Helper/DialogHelper.php:62.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateBundleCommand.php:83.../Symfony/Component/Console/Command/Command.php:214.../Symfony/Component/Console/Tester/CommandTester.php:66.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateBundleCommandTest.php:393) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateBundleCommandTest::testInteractiveCommand with data set #2 (array('/tmp', 'yml', 'BarBundle', true), 'Foo/BarBundle', array('Foo\\BarBundle', 'BarBundle', '/tmp/', 'yml', true))RuntimeException: Aborted.../Symfony/Component/Console/Helper/DialogHelper.php:40.../Symfony/Component/Console/Helper/DialogHelper.php:97.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateBundleCommand.php:165.../Symfony/Component/Console/Command/Command.php:205.../Symfony/Component/Console/Tester/CommandTester.php:66.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateBundleCommandTest.php:394) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateDoctrineEntityCommandTest::testInteractiveCommand with data set #0 (array(), 'AcmeBlogBundle:Blog/Post', array('Blog\\Post', 'annotation', array()))RuntimeException: Aborted.../Symfony/Component/Console/Helper/DialogHelper.php:40.../Symfony/Component/Console/Helper/DialogHelper.php:97.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateDoctrineEntityCommand.php:145.../Symfony/Component/Console/Command/Command.php:205.../Symfony/Component/Console/Tester/CommandTester.php:66.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateDoctrineEntityCommandTest.php:395) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateDoctrineEntityCommandTest::testInteractiveCommand with data set #1 (array('AcmeBlogBundle:Blog/Post'), '', array('Blog\\Post', 'annotation', array()))RuntimeException: Aborted.../Symfony/Component/Console/Helper/DialogHelper.php:40.../Symfony/Component/Console/Helper/DialogHelper.php:97.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateDoctrineEntityCommand.php:121.../Symfony/Component/Console/Command/Command.php:205.../Symfony/Component/Console/Tester/CommandTester.php:66.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateDoctrineEntityCommandTest.php:396) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateDoctrineEntityCommandTest::testInteractiveCommand with data set #2 (array(), 'AcmeBlogBundle:Blog/Postyml', array('Blog\\Post', 'yml', array()))RuntimeException: Aborted.../Symfony/Component/Console/Helper/DialogHelper.php:40.../Symfony/Component/Console/Helper/DialogHelper.php:62.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateDoctrineEntityCommand.php:153.../Symfony/Component/Console/Command/Command.php:205.../Symfony/Component/Console/Tester/CommandTester.php:66.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateDoctrineEntityCommandTest.php:397) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateDoctrineEntityCommandTest::testInteractiveCommand with data set #3 (array(), 'AcmeBlogBundle:Blog/Postymltitle255descriptiontext', array('Blog\\Post', 'yml', array(array('title', 'string', 255), array('description', 'text'))))RuntimeException: Aborted.../Symfony/Component/Console/Helper/DialogHelper.php:40.../Symfony/Component/Console/Helper/DialogHelper.php:62.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateDoctrineEntityCommand.php:153.../Symfony/Component/Console/Command/Command.php:205.../Symfony/Component/Console/Tester/CommandTester.php:66.../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateDoctrineEntityCommandTest.php:39

@lenar
Copy link
ContributorAuthor

@fabpot: and you modified all those tests? I only modifiedTests/Command/GenerateDoctrineCrudCommandTest.php
and that doesn't fail as I see from your log. I just provided example, though I could add necessary changes for other tests too.

@fabpot
Copy link
Member

@lenar: ah, sorry about that. Then, can you provide a fix for all the other tests too? Thanks a lot.

@lenar
Copy link
ContributorAuthor

@fabpot: actually what do you think about this kind of fix instead for tests:lenar/SensioGeneratorBundle@517f263cb01ea2ea1ef2 instead my previous proposal (lenar/SensioGeneratorBundle@6ff3f26). Really simple, short and effective.

@fabpot
Copy link
Member

@lenar: looks good to me. Can you create a PR?

@lenar
Copy link
ContributorAuthor

[Console] Change back to fgets() in DialogHelper
fabpot added a commit that referenced this pull requestJul 27, 2011
Commits-------07298ac Detect EOF when reading input streamDiscussion----------[Console] Detect EOF when reading input streamThis is related to commits511a9a1 and3a5d508.First of them introduced abort-on-EOF and the second regressed the functionality.Problem is stream_get_line() doesn't return false on EOF. So it needs call to feof() todetect the situation.Still, it's not ideal. With fgets() it worked fine, but with stream_get_line() one has to pressCTRL+D twice to get out. I presume this could be bug in PHP itself.But better than nothing. Please consider.---------------------------------------------------------------------------by fabpot at 2011/07/19 22:47:53 -0700I have used `stream_get_line` especially because it does not return `false` on eof. This is needed when you pass your own stream for unit tests.---------------------------------------------------------------------------by lenar at 2011/07/25 06:05:59 -0700This is not the best solution I think. Tests should mimic and cope with real life not the other way around.Better solution would be to fix testcase. Like this:lenar/SensioGeneratorBundle@6ff3f26. Or maybe create a special "testing" stream wrapper that wraps php://memory and gives out just linefeeds after real data ends.And then change stream_get_line() back to fgets() if there is no other reason for this change.---------------------------------------------------------------------------by fabpot at 2011/07/25 06:24:20 -0700When applying your patch to the generator bundle (and revert to use `fgets`), I get "RuntimeException: Aborted" exceptions.---------------------------------------------------------------------------by lenar at 2011/07/25 06:35:08 -0700With d326f89 added +lenar/SensioGeneratorBundle@6ff3f26 I can successfully run every test in that file.---------------------------------------------------------------------------by fabpot at 2011/07/26 23:31:36 -0700@lenar: not for me. I have many 'Aborted' exception on my Mac.---------------------------------------------------------------------------by fabpot at 2011/07/26 23:41:18 -0700And I have the exact same errors on Linux:    There were 7 errors:    1) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateBundleCommandTest::testInteractiveCommand with data set #0 (array('/tmp'), 'Foo/BarBundle    ', array('Foo\\BarBundle', 'FooBarBundle', '/tmp/', 'annotation', false))    RuntimeException: Aborted    .../Symfony/Component/Console/Helper/DialogHelper.php:40    .../Symfony/Component/Console/Helper/DialogHelper.php:97    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateBundleCommand.php:165    .../Symfony/Component/Console/Command/Command.php:205    .../Symfony/Component/Console/Tester/CommandTester.php:66    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateBundleCommandTest.php:39    2) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateBundleCommandTest::testInteractiveCommand with data set#1 (array('/tmp'), 'Foo/BarBundle    BarBundle    foo    yml    n', array('Foo\\BarBundle', 'BarBundle', 'foo/', 'yml', false))    RuntimeException: Aborted    .../Symfony/Component/Console/Helper/DialogHelper.php:40    .../Symfony/Component/Console/Helper/DialogHelper.php:62    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateBundleCommand.php:83    .../Symfony/Component/Console/Command/Command.php:214    .../Symfony/Component/Console/Tester/CommandTester.php:66    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateBundleCommandTest.php:39    3) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateBundleCommandTest::testInteractiveCommand with data set#2 (array('/tmp', 'yml', 'BarBundle', true), 'Foo/BarBundle    ', array('Foo\\BarBundle', 'BarBundle', '/tmp/', 'yml', true))    RuntimeException: Aborted    .../Symfony/Component/Console/Helper/DialogHelper.php:40    .../Symfony/Component/Console/Helper/DialogHelper.php:97    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateBundleCommand.php:165    .../Symfony/Component/Console/Command/Command.php:205    .../Symfony/Component/Console/Tester/CommandTester.php:66    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateBundleCommandTest.php:39    4) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateDoctrineEntityCommandTest::testInteractiveCommand with data set #0 (array(), 'AcmeBlogBundle:Blog/Post    ', array('Blog\\Post', 'annotation', array()))    RuntimeException: Aborted    .../Symfony/Component/Console/Helper/DialogHelper.php:40    .../Symfony/Component/Console/Helper/DialogHelper.php:97    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateDoctrineEntityCommand.php:145    .../Symfony/Component/Console/Command/Command.php:205    .../Symfony/Component/Console/Tester/CommandTester.php:66    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateDoctrineEntityCommandTest.php:39    5) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateDoctrineEntityCommandTest::testInteractiveCommand with data set#1 (array('AcmeBlogBundle:Blog/Post'), '', array('Blog\\Post', 'annotation', array()))    RuntimeException: Aborted    .../Symfony/Component/Console/Helper/DialogHelper.php:40    .../Symfony/Component/Console/Helper/DialogHelper.php:97    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateDoctrineEntityCommand.php:121    .../Symfony/Component/Console/Command/Command.php:205    .../Symfony/Component/Console/Tester/CommandTester.php:66    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateDoctrineEntityCommandTest.php:39    6) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateDoctrineEntityCommandTest::testInteractiveCommand with data set#2 (array(), 'AcmeBlogBundle:Blog/Post    yml    ', array('Blog\\Post', 'yml', array()))    RuntimeException: Aborted    .../Symfony/Component/Console/Helper/DialogHelper.php:40    .../Symfony/Component/Console/Helper/DialogHelper.php:62    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateDoctrineEntityCommand.php:153    .../Symfony/Component/Console/Command/Command.php:205    .../Symfony/Component/Console/Tester/CommandTester.php:66    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateDoctrineEntityCommandTest.php:39    7) Sensio\Bundle\GeneratorBundle\Tests\Command\GenerateDoctrineEntityCommandTest::testInteractiveCommand with data set#3 (array(), 'AcmeBlogBundle:Blog/Post    yml    title    255    description    text    ', array('Blog\\Post', 'yml', array(array('title', 'string', 255), array('description', 'text'))))    RuntimeException: Aborted    .../Symfony/Component/Console/Helper/DialogHelper.php:40    .../Symfony/Component/Console/Helper/DialogHelper.php:62    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Command/GenerateDoctrineEntityCommand.php:153    .../Symfony/Component/Console/Command/Command.php:205    .../Symfony/Component/Console/Tester/CommandTester.php:66    .../symfony-standard/vendor/bundles/Sensio/Bundle/GeneratorBundle/Tests/Command/GenerateDoctrineEntityCommandTest.php:39---------------------------------------------------------------------------by lenar at 2011/07/26 23:56:46 -0700@fabpot: and you modified all those tests? I only modified ```Tests/Command/GenerateDoctrineCrudCommandTest.php```and that doesn't fail as I see from your log. I just provided example, though I could add necessary changes for other tests too.---------------------------------------------------------------------------by fabpot at 2011/07/27 00:09:32 -0700@lenar: ah, sorry about that. Then, can you provide a fix for all the other tests too? Thanks a lot.---------------------------------------------------------------------------by lenar at 2011/07/27 00:22:54 -0700@fabpot: actually what do you think about this kind of fix instead for tests:lenar/SensioGeneratorBundle@517f263cb01ea2ea1ef2 instead my previous proposal (lenar/SensioGeneratorBundle@6ff3f26). Really simple, short and effective.---------------------------------------------------------------------------by fabpot at 2011/07/27 00:37:51 -0700@lenar: looks good to me. Can you create a PR?---------------------------------------------------------------------------by lenar at 2011/07/27 00:45:36 -0700@fabpot:sensiolabs/SensioGeneratorBundle#60
@fabpotfabpot merged commit07298ac intosymfony:masterJul 27, 2011
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@lenar@fabpot@Seldaek@michelsalib

[8]ページ先頭

©2009-2025 Movatter.jp