2012-07-29 20 views
1

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 

如果你认为我现在用的是不好的工具,我的目的,告诉过我这些,我会很高兴知道还有别的东西。

回答

-2

u有上线的语法时才错误2 mytest的

时inapropriate代码传递或无法正常关闭,如{}

你可以张贴线2的mytest的

+0

难道你读完整个问题?我不是在问这个错误,我是在问这个工具。错误是有意的。 – 2012-07-29 12:18:14

0

谈到基本你可以尝试使用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