覆盖“@package_version@”从 Git 存储库安装时在 PHPUnit 输出中

发布于 2024-11-05 11:56:20 字数 370 浏览 0 评论 0 原文

我按照 git submodule add 将 PHPUnit 添加到项目中rel="nofollow">这篇博文。一切都运行良好,除了每次执行顶部的输出如下所示:

PHPUnit @package_version@,作者:Sebastian Bergmann。

看起来 PEAR 在安装过程中用版本号替换了该值,这对我没有多大帮助,因为我使用 Git 来安装文件。

有人遇到过这个问题吗?你是如何解决/解决这个问题的?

I added PHPUnit to a project via git submodule add per the instructions in this blog post. Everything is working beautifully, except the output at the top of each execution looks like this:

PHPUnit @package_version@ by Sebastian Bergmann.

It looks like PEAR replaces that value with the version number during its install process, which doesn't help me much since I'm using Git to install the files.

Has anyone encountered this issue, and how did you solve/work around it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

坏尐絯℡ 2024-11-12 11:56:21

你很好地回答了问题中的所有内容。这不是一个错误,而是一个功能 - 字符串 @package_version@ ​​是一个占位符,通过 PEAR 安装包时会被替换。

由于您使用的是用于开发的版本(来自 GitHub 的存储库克隆),因此您应该为此类问题做好准备。

如果您想要某个特定版本,请通过 PEAR 安装该特定版本。

我可以想到一些结帐后挂钩,可以用修订版 sha1 哈希替换字符串,但这并没有多大用处。

所以,用一句话来说——它就是这样的。

You pretty answered everything in the question. It's not a bug, it's a feature - the string @package_version@ is a placeholder that is replaced upon installing the package via PEAR.

Since you are using a version intended for development (repo clone from GitHub), you should be ready for issues like this.

If you want there some specific version instead, install this specific version via PEAR.

I can think of some post-checkout hook that would replace the string with revision sha1 hash, but that wouldn't be much useful.

So, in one sentence - it's intended to be this way.

冬天旳寂寞 2024-11-12 11:56:21

看来这个已经没有必要了。来自 PHPUnit 3.7.1 的变更日志

现在,当从 Composer 安装或 Git 签出中使用 PHPUnit 时,会显示版本号。

It looks like this is no longer necessary. From PHPUnit 3.7.1's changelog:

The version number is now displayed when using PHPUnit from a Composer install or Git checkout.

沙沙粒小 2024-11-12 11:56:21

碰巧,我正在处理的项目将通过 PEAR 进行分发,因此我将 PHPUnit 作为 package.xml 文件中的依赖项列出。这还允许用户灵活地选择要使用哪个版本的 PHPUnit 来运行测试。

As it happens, the project I'm working on is going to be distributed via PEAR, so I'll just list PHPUnit as a dependency in the package.xml file. This will also allow the user some flexibility as to which version of PHPUnit she'd like to run her tests with.

新雨望断虹 2024-11-12 11:56:21

这是我的解决方法,是的,它不是超级干净;)

我已经编辑了我的 phpunit 文件,不要忘记替换为您自己的路径:

#!/usr/bin/env php
<?php
while (substr(getcwd(), -3) != "Project_Folder") chdir('../');
if (in_array('--version', $argv)) {
    echo 'PHPUnit 3.6.0 by Sebastian Bergmann.';
    return;
}
// set main method
define('PHPUnit_MAIN_METHOD','PHPUnit_TextUI_Command::main');

// add phpunit to the include path
$paths = scandir('./var/lib/phpunit');
$includes = array();

foreach($paths as $path){
    if (!preg_match('/^\./', $path)){
        $includes[] = './var/lib/phpunit/' . $path;
    }
}
set_include_path(implode(PATH_SEPARATOR,$includes).PATH_SEPARATOR.get_include_path());

// set the auto loader
require 'PHPUnit/Autoload.php';
// execute
PHPUnit_TextUI_Command::main();

This is my workaround, and yes it's not super-clean ;)

I have edited my phpunit file, don't forget to replace with your own paths :

#!/usr/bin/env php
<?php
while (substr(getcwd(), -3) != "Project_Folder") chdir('../');
if (in_array('--version', $argv)) {
    echo 'PHPUnit 3.6.0 by Sebastian Bergmann.';
    return;
}
// set main method
define('PHPUnit_MAIN_METHOD','PHPUnit_TextUI_Command::main');

// add phpunit to the include path
$paths = scandir('./var/lib/phpunit');
$includes = array();

foreach($paths as $path){
    if (!preg_match('/^\./', $path)){
        $includes[] = './var/lib/phpunit/' . $path;
    }
}
set_include_path(implode(PATH_SEPARATOR,$includes).PATH_SEPARATOR.get_include_path());

// set the auto loader
require 'PHPUnit/Autoload.php';
// execute
PHPUnit_TextUI_Command::main();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文