通过 PECL 安装 Xdebug 后不带参数运行 phpunit 会生成有关权限的警告
我在 Ubuntu 10.04 上运行 Zend Framework 1.10,刚刚安装了 Xdebug 来通过 PECL 生成代码覆盖率。
如果我像这样运行 phpunit:
$ phpunit --coverage-html ~/coverage
它工作得很好。运行单元测试,然后生成代码覆盖率输出。没有错误消息或警告。
但如果我这样做:
$ phpunit
测试运行良好,但是当代码覆盖开始时,我得到这个:
Generating code coverage report, this may take a moment.PHP Warning: mkdir(): Permission denied in /usr/share/php/PHPUnit/Util/Filesystem.php on line 209
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:147
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:214
PHP 5. PHPUnit_Util_Report::render() /usr/share/php/PHPUnit/TextUI/TestRunner.php:479
PHP 6. PHPUnit_Util_Filesystem::getDirectory() /usr/share/php/PHPUnit/Util/Report.php:87
PHP 7. mkdir() /usr/share/php/PHPUnit/Util/Filesystem.php:209
Warning: mkdir(): Permission denied in /usr/share/php/PHPUnit/Util/Filesystem.php on line 209
Call Stack:
0.0003 322324 1. {main}() /usr/bin/phpunit:0
0.0521 4658252 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
0.0521 4658716 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:147
0.5944 12773356 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:214
37.1550 24746768 5. PHPUnit_Util_Report::render() /usr/share/php/PHPUnit/TextUI/TestRunner.php:479
37.1550 24746768 6. PHPUnit_Util_Filesystem::getDirectory() /usr/share/php/PHPUnit/Util/Report.php:87
37.1560 24746984 7. mkdir() /usr/share/php/PHPUnit/Util/Filesystem.php:209
在安装 Xdebug 之前,运行 phpunit 时不带任何参数工作得很好。
我认为这只是一个愚蠢的权限问题,源于我的 Xdebug 的 PECL 安装,但看起来 /usr/share/php/phpunit 中的所有内容都应该被授予 root 权限,所以……有什么想法吗?
I am running Zend Framework 1.10 on Ubuntu 10.04, just installed Xdebug to generate code coverage, via PECL.
If I run phpunit like so:
$ phpunit --coverage-html ~/coverage
It works just fine. Unittests run, then code coverage output is generated. No error messages or warnings.
But if I do:
$ phpunit
The tests run fine, but when code coverage begins, I get this:
Generating code coverage report, this may take a moment.PHP Warning: mkdir(): Permission denied in /usr/share/php/PHPUnit/Util/Filesystem.php on line 209
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:147
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:214
PHP 5. PHPUnit_Util_Report::render() /usr/share/php/PHPUnit/TextUI/TestRunner.php:479
PHP 6. PHPUnit_Util_Filesystem::getDirectory() /usr/share/php/PHPUnit/Util/Report.php:87
PHP 7. mkdir() /usr/share/php/PHPUnit/Util/Filesystem.php:209
Warning: mkdir(): Permission denied in /usr/share/php/PHPUnit/Util/Filesystem.php on line 209
Call Stack:
0.0003 322324 1. {main}() /usr/bin/phpunit:0
0.0521 4658252 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:52
0.0521 4658716 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:147
0.5944 12773356 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:214
37.1550 24746768 5. PHPUnit_Util_Report::render() /usr/share/php/PHPUnit/TextUI/TestRunner.php:479
37.1550 24746768 6. PHPUnit_Util_Filesystem::getDirectory() /usr/share/php/PHPUnit/Util/Report.php:87
37.1560 24746984 7. mkdir() /usr/share/php/PHPUnit/Util/Filesystem.php:209
Before I installed Xdebug, running phpunit without any arguments worked just fine.
I presume this is just a silly permissioning problem stemming from my PECL installation of Xdebug, but it looks like everything in /usr/share/php/phpunit is supposed to be permissioned as root, soooooo...any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误消息只是告诉您
mkdir
无法在某处创建文件夹,但不能在它试图创建的位置创建文件夹。我假设您有一个
phpunit.xml.dist
,其中使用目标定义了coverage-html
类型的
您的计算机上不存在该文件,您的当前用户也没有写入权限。PHPUnit 不会在无人告知的情况下尝试生成覆盖率报告,如果您不在 cli 上执行此操作,则
phpunit.xml
是剩下的唯一选择。The error message just tells you that
mkdir
can't create a folder somewhere but not where it is trying to do so.I would assume you have an
phpunit.xml.dist
in which a<logger>
of the typecoverage-html
is defined with a target that doesn't exist on your machine which your current user doesn't have write access too.PHPUnit doesn't try to generate a coverage report without somneone telling it do and if you don't do it on the cli a
phpunit.xml
is the only option left.