ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harold Putman <hput...@lexmark.com>
Subject Re: Trying to execute 'grep'
Date Thu, 16 Aug 2012 11:51:39 GMT
Jeff,
You might be able to do this natively within ant

This is how it could work for a single file:
<target name="test-failure-check">
  <local name="error.found"/>
  <loadfile property="error.found"
srcfile="${home.dir}/runtime/logs/test-results/file.xml">
<filterchain>
<linecontainsregexp>
<regexp pattern="failure"/>
</linecontainsregexp>
</filterchain>
  </loadfile>
  <fail message="Unit test failure(s)" unless="error.found"/>
</target>

Doing this this with *.xml is left as an exercise for the reader :-)

Harold

On Wed, Aug 15, 2012 at 6:56 PM, Jeff Lowery <jeff.l@mavericklabel.com>wrote:

> Have the following target:
>
> <target name="test-failure-check">
>                 <exec executable="grep">
>                         <arg line="failure
> ${home.dir}/runtime/logs/test-results/*.xml" />
>                         <redirector outputproperty="grep.out" />
>                 </exec>
>                 <echo message="grep.out='${grep.out}'" />
>
>                 <fail message="Unit test failure(s)">
>                         <condition>
>                                 <not>
>                                         <equals arg1="${grep.out}" arg2=""
> />
>                                 </not>
>                         </condition>
>                 </fail>
> </target>
>
> and getting the following echo:
>
> [echo] grep.out='grep:
> /Users/jeff.l/Documents/workspace/homedir/runtime/logs/test-results/*.xml:
> No such file or directory'
>
> yet if I execute "grep failure
> /Users/jeff.l/Documents/workspace/homedir/runtime/logs/test-results/*.xml",
> from the command line, I get results back.
>
>
> -- Jeff
>
>
>
>


-- 
Harold PUTMAN
Web Technology Specialist
*Lexmark International, Inc. <http://www.lexmark.com>*
740 W New Circle Rd.
Lexington, KY 40550
+1(859) 232-2839
hputman@lexmark.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message