Skip to content
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

Replace echo to flushable stdout #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andras-tim
Copy link

Added outPath and forceFlush arguments

FYI:
This is useful, when a custom phpunit printer explicit flushes its results.

@andras-tim andras-tim changed the title Replace echo to flushable stdout - fix #19 Replace echo to flushable stdout Mar 27, 2017
@andras-tim
Copy link
Author

This was sent in #19 too before

Copy link
Owner

@johnkary johnkary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Andras! Thank you for submitting this PR. Could you better help me understand this use case for a custom printer? Why are they useful and what problem does this PR solve?

Why is stdout a better way of outputting the report? If I recall correctly, PHPUnit itself uses echo to print to terminal.

When would a developer want to use stderr instead of stdout?

Does outPath support all file paths? How does this feature respond when the file path is not writeable, not openable, or does not exist?

@@ -302,6 +334,8 @@ protected function renderFooter()
*/
protected function loadOptions(array $options)
{
$this->outPath = isset($options['outPath']) ? $options['outPath'] : 'php://stdout';
$this->forceFlush = isset($options['forceFlush']) ? $options['forceFlush'] : False;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use lower-case false instead of capitalized False per PSR-2 standard.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for my mistake, I fixed this

@andras-tim
Copy link
Author

Dear @johnkary ,

On our several systems we can't change buffering strategy, and the only one solution for continuous phpunit status printing was a flushing results printer. When the result is printing with explicit flushes, your stuff printed the output after the end of phpunit output, what wasn't so good.

- In other hand, the phpunit result printer supports out of the box the flushing, therefore I think, this not extremely bad idea, check my example in #19 (comment)

So, I tried to implement the flushing in your stuff, but I couldn't reach the flushing without writing php://stdout directly.

- There looked good a freely configurable output when I wrote the fopen(), e.g. for a file output for this result, or "red highlighting" in docker with php://stderr.

So this is the history/reason of these two arguments.

@andras-tim
Copy link
Author

Dear @johnkary,
do you have any update?

@andras-tim
Copy link
Author

Where we sticked @johnkary? Should I help you?

@johnkary
Copy link
Owner

@andras-tim Sorry, very busy with paid work. Will have time to look closer sometime in May.

@andras-tim
Copy link
Author

@johnkary, is there any news?

@andras-tim
Copy link
Author

ping

@johnkary
Copy link
Owner

johnkary commented Jul 3, 2017

@andras-tim I've begun looking at this and looks like it will work! I'll give it a final look using a custom result printer to be sure.

In the meantime I tried using your changes to phpunit-speedtrap with whatthejeff/nyancat-phpunit-resultprinter, the PHPUnit results printer that prints Nyancat output for test results. That library didn't support PHPUnit 6 yet so I fixed it and PR'd 😋

@andras-tim
Copy link
Author

Thank you @johnkary!

@andras-tim
Copy link
Author

@johnkary, is there any news?

Added outPath and forceFlush arguments

FYI:
This is useful, when a custom phpunit printer explicit flushes its results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants