默认情况下,Phing,甚至任何内置的记录器(phing.listener.NoBannerLogger、phing.listener.AnsiColorLogger、phing.listener.XmlLogger和phing.listener.HtmlColorLogger)都有相当详细的输出。
我的用例是使用Phing作为预提交钩子来运行测试。因此,我不在乎日志phing中的所有信息可能提供给我。我只是将它用作运行测试的多平台工具。
示例:
Buildfile: /private/var/workspace/www/me_com/build.xml
SBKSWWW > main:
[delete] Deleting /private/var/workspace/www/me_com/temp/pre-commit-hook/changed_files
[delete] Deleting directory /private/var/workspace/www/me_com/temp/pre-commit-hook
[mkdir] Created dir: /private/var/workspace/www/me_com/temp/pre-commit-hook
[phplint] Parse error: parse error in ./www/MyTest.php on line 2
[phpcodesniffer] 2 files where checked
[phpcodesniffer] No syntax errors detected
BUILD FINISHED
Total time: 0.3430 seconds对于我的用例来说,这些行中有很多都是多余的和无用的。实际上,我甚至不运行原意的“构建”。
我想让phing日志看起来像这样:
✔ Commited code matches coding standards
✘ Commited code has syntax errors!
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in MyTest.php on line 2如果你认为我是为了我的目的而使用坏工具,告诉我,我也很高兴知道还有别的东西。
发布于 2012-10-18 11:07:47
您可以尝试的是使用phing.listener.XmlLogger并使用您自己的样式表在xsltproc中穿行。
给出一个基本的build.xml文件,该文件只对PHP进行链接:
<?xml version="1.0" ?>
<project name="Example" basedir=".">
<target name="lint" description="PHP syntax check">
<phplint>
<fileset dir="src">
<include name="**/*.php"/>
</fileset>
</phplint>
</target>
</project>与parse.xsl耦合
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"
omit-xml-declaration="yes"/>
<xsl:template match="/build">
<xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable>
<xsl:for-each select="target">
<xsl:text>Task: </xsl:text>
<xsl:value-of select="concat(@name, $newline)" />
<xsl:choose>
<xsl:when test="task/message[@priority = 'error']">
<xsl:value-of select="concat(task/message[@priority = 'error'], $newline)"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>No errors</xsl:text>
<xsl:value-of select="$newline" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>使用phing -logger phing.listener.XmlLogger lint | xsltproc parse.xsl -调用将给您提供一些干净的内容,如:
Task: lint
Fatal error: Only variables can be passed by reference in Request.class.php on line 128发布于 2020-05-03 20:46:56
从Phing2.11.0开始,您将使用phing.listener.SilentLogger
发布于 2012-07-29 12:17:20
你在第2行测试中有一个系统错误。
它基本上是在传递不适当的代码或没有像{}那样正确关闭时出现的。
你能把我测试的第2行贴出来吗?
https://stackoverflow.com/questions/11709160
复制相似问题