-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console][ProgressBar] redrawFrequency should never be 0 #16742
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
Nice PR! Maybe I would add explicit test to cover the change in behavior of |
👍 But please add a test
There cannot be a test for this. Otherwise it would fail. |
ecdcaab
to
368423b
Compare
Added tests and rebased against the newest 2.8 branch. |
public function testRedrawFrequencyIsAtLeastOneIfZeroGiven() | ||
{ | ||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), | ||
array($output = $this->getOutputStream(), 6)); |
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.
should be on one line to be consistent
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.
and $output
is not used. please remove the var in testRedrawFrequency and testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven as well
…se produce an error.
368423b
to
6a0a811
Compare
@Tobion All done. :) |
👍 Should be merged in 2.7 Status: Reviewed |
Thank you @dritter. |
Set the redraw frequency at least to 1. Setting it to 0 would otherwise produce a "division by zero" error.
why?
I had a piece of code that used a ProgressBar and set the redraw frequency to a calculated value. In some cases this calculated value was 0 (or just smaller than 1, internally a cast to
int
is made). In thesetProgress
the redraw frequency is used for a calculation of the period. There the error happens (and shows that redraw frequency should never be 0).Ticket
There is no ticket concerning this issue. I could do one, if you want.
Tests
This gets tested implicitly in
ProgressBarTest::testNonDecoratedOutputWithoutMax
.