我可以将 PHPUnit 打包为 phar 吗?
我想将 PHPUnit 和其他各种测试依赖项打包成一个 phar 并将其放入 svn.这样我就可以在任何客户端机器上运行 phpunit 而不需要梨.这个可以吗?
I would like to package PHPUnit and various other test dependencies into a phar and put that into svn. This way I can run phpunit on any client machine without needing pear. Can this be done?
推荐答案
当前状态:
phpunit.phar 的工作已经在 phpunit repo
但生成的 phar 不稳定且功能不完整.
Current status:
Work on a phpunit.phar has started in the phpunit repo
but the generated phar is not stable and not feature complete.
如果它到达那里,就会有正式版本
If it gets there there will be official releases
如果可以的话,我会给你 500 个代表,一个 100 个雄鹿和我的第一个孩子......好吧,不......只是前两个.
If you can I'll give you 500 rep, a 100 Bucks and my first born.. well no.. just the first two.
严肃点:
我现在至少在 3 次会议上就这个话题向 PHPUnit 的创建者唠叨了.这似乎是不可能的.
I've nagged the creator of PHPUnit about this topic on at least 3 conferences now and well.. it doesn't seem like it's possible.
这有几个问题.首先 PHPUnit 为测试隔离生成了新的 php 进程.问题在于 phar 无法分辨是哪个 php 可执行文件调用了它.因此,如果您使用自定义编译版本启动 phpunit,它将使用默认".安装了 php 以生成隔离测试.
There are a couple of issues with that. First off PHPUnit spawns new php processes for test isolation. The problem with this is that a phar can't tell which php executable called it. So if you start phpunit with a custom compiled version it would use the "default" php installed to spawn the isolated tests.
其次,据我所知并被告知不可能将图像和 css 等静态文件放在 phar 中.这使得生成代码覆盖率变得更加困难.这需要在这方面做一些工作.
Secondly as far as i know and have been told it's not possible to put static files like images and css in a phar. Which makes generating code coverage a lot harder. That would require some work on that part.
还有其他一些问题我记不得了,这与 xDebug 能够为 phars 提供代码覆盖(以及 phpunit 依赖于不为其自己的代码生成超额等)和其他事情有关.
There are other issues i can't recall exactly recall right having to do with xDebug being able to provide code coverage for phars (and phpunit relying on not generating overage for it's own code and so) and others things.
曾经有一个 phar
但是据我了解,这与 phpunit 的当前状态不符,而且从来没有真正完全工作过.
我并不是说它不能做到,只是很多人已经放弃了创建 phpunit.phar,包括开发它的人.(这只是我的印象,我当然不能在这里代表塞巴斯蒂安,可能完全错了,把这当作一点免责声明)
I'm not saying it can't be done just that various people already have given up on creating a phpunit.phar including the guy how develops it. (That is just my impression, i of course can't speak for Sebastian here and might be completely wrong, take this as a little disclaimer)
您不必为此构建 .phar!
You don't have to build a .phar to do so!
对于我的公司,我维护一个 svnd 版本的 PHPUnit.这不是推荐的使用方式,但它可以正常工作!
For my company I maintain a svnd version of PHPUnit. It's not the recommended way of using it but it works without much issues!
按照 phpunit github 上的 使用 git checkout"
说明进行操作网站.然后,您需要将这些文件放入您的 php 包含路径中,它可以工作.
Follow the "using from a git checkout"
instructions on the phpunit github site. You then need to put those files into your php include path and it works.
我的建议是创建一个自定义 phpunit.sh 来修改包含路径,然后调用原始 phpunit.sh 传递所有参数.这需要做一些工作,但效果很好,而且比创建 phar 存档要容易得多:)
My suggestion would be to create a custom phpunit.sh that modifies the include path and then calls the original phpunit.sh passing along all arguments. It's a little bit of work but it works quite well and it is a hell of a lot easier than creating a phar archive :)
相关文章