-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
str_repeat(): Second argument has to be greater than or equal to 0 #1976
Comments
Can you provide a minimal, self-contained, reproducing test case? |
I noticed that is seems to go wrong on displaying the results. As a workarount I am now using the --tap option phpunit -c app --tap Then I get no error |
The only place in PHPUnit's code where |
Me too, but somehow it does. May be it is caused by the php7 Rc7 prerelease ?? I'll test again as soon php7 is officially released and the i'll report Thanks ! |
Can you share the contents of |
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
Thank you for sharing your configuration. I do not see anything in there that would explain the problem. Are you sure that this does not come from a usage of |
I do not think so. |
I am seeing this issue appearing at the end of my test suite whilst running in a BuildKite environment on an unbuntu machine. It appears to me that As you can see below if console returns 0 for $console = new Console;
$maxNumberOfColumns = $console->getNumberOfColumns();
if ($numberOfColumns == 'max' || $numberOfColumns > $maxNumberOfColumns) {
$numberOfColumns = $maxNumberOfColumns;
} The consequence of this is the This causes the second parameter of The console class is using For what it's worth the output of my test runs within the CI environment don't contain the nice line endings you'd expect from an 80 character vendor/bin/phpunit -d memory_limit=1024M --configuration phpunit.xml --verbose
PHPUnit 5.1.3 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.16-2+deb.sury.org~trusty+1
Configuration: /var/lib/buildkite-agent/builds/api/phpunit.xml
.......................................................SIIIIIIII........................................................III.....................................................................................................S..........III....................................................................................................................................................
[ErrorException]
str_repeat(): Second argument has to be greater than or equal to 0 The stack trace of the error is reported in my logs as follows: [2015-12-21 23:20:21] lumen.ERROR: exception 'ErrorException' with message 'str_repeat(): Second argument has to be greater than or equal to 0' in /vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php:603
Stack trace:
#0 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\{closure}(2, 'str_repeat(): S...', '/var/lib/buildk...', 603, Array)
#1 /vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(603): str_repeat(' ', -403)
#2 /vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(572): PHPUnit_TextUI_ResultPrinter->writeProgress('.')
#3 /vendor/phpunit/phpunit/src/Framework/TestResult.php(391): PHPUnit_TextUI_ResultPrinter->endTest(Object(GeocodeValidatorTest), 5.5074691772461E-05)
#4 /vendor/phpunit/phpunit/src/Framework/TestResult.php(833): PHPUnit_Framework_TestResult->endTest(Object(GeocodeValidatorTest), 5.5074691772461E-05)
#5 /vendor/phpunit/phpunit/src/Framework/TestCase.php(726): PHPUnit_Framework_TestResult->run(Object(GeocodeValidatorTest))
#6 /vendor/phpunit/phpunit/src/Framework/TestSuite.php(747): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#7 /vendor/phpunit/phpunit/src/Framework/TestSuite.php(747): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#8 /vendor/phpunit/phpunit/src/Framework/TestSuite.php(747): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#9 /vendor/phpunit/phpunit/src/TextUI/TestRunner.php(429): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#10 vendor/phpunit/phpunit/src/TextUI/Command.php(155): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#11 vendor/phpunit/phpunit/src/TextUI/Command.php(106): PHPUnit_TextUI_Command->run(Array, true)
#12 vendor/phpunit/phpunit/phpunit(47): PHPUnit_TextUI_Command::main() My work around I am yet to investigate why the buildkite tty reports a zero column width but I was able to solve the issue by setting the tty column width manually at the appropriate point in my setup scripts. stty cols 80 Preventing the Issue It might be worth preventing Console from returning a zero value in the regex cases. |
Thank you jessedc, that post saved me a lot of time. I am adding in my vote for your suggested change. This problem (where str_repeat()'s 2nd argument was a negative value) also occurs when attempting to execute phpunit on a remote host via Ansible, which uses SSH, so I'm providing diagnosis and workaround to other Ansible/phpunit users: I used Ansible's debug feature to reveal its stty settings as follows:
Truncated output from above reveals rows = 0:
Adding a simple command to my ansible task as follows fixed the problem:
|
The same issue happens on Scrutinizer:
Running It would be good to check the shell columns to avoid this error though. |
Can you please check whether sebastianbergmann/environment@22aa49b fixes the issue? Thanks! |
I've just tried with |
I am getting this error on my Test Case, when I use it in Docker image that I created. PHP Warning: str_repeat(): Second argument has to be greater than or equal to 0 in /usr/share/php/PHPUnit/TextUI/ResultPrinter.php on line 600 Docker Image is : https://hub.docker.com/r/archergod/phpall/ Basically the docker image is ubuntu docker, that I add PHP 7, mysql and Though on same test on my local Windows machines, with PHPUnit 5.6 with PHP 7 it works without any warning. |
Got this on https://travis-ci.org/Ocramius/ProxyManager/jobs/177276352#L574 Possibly related to one of these dependencies being downgraded when dealing with the Latest dependencies don't cause the issue |
@Ocramius Any suggestion on what I should do here? |
Probably bumping dependencies On 19 Nov 2016 5:44 p.m., "Sebastian Bergmann" notifications@github.com
|
follow the link and change -1 to 0 |
When I run phpunit version 5.0.10 on a symfony 2.8 project running on centos 7 with php7-Rc7
I get the error: str_repeat(): Second argument has to be greater than or equal to 0.
I can see that the test has run, but I am unable to see where the error occurs....
output
$ ./phpunitdir/phpunit.phar --debug -v -c app
PHPUnit 5.0.10 by Sebastian Bergmann and contributors.
Runtime: PHP 7.0.0RC7 with Xdebug 2.4.0rc1
Configuration: /var/www/html/symblogudm/app/phpunit.xml.dist
Starting test 'Blog\CoreBundle\Tests\Controller\PostControllerTest::testIndex'.
Fstr_repeat(): Second argument has to be greater than or equal to 0
Regards,
Hans Nieuwenhuis
The text was updated successfully, but these errors were encountered: