You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Greg Irvine <gr...@thalesatm.com> on 2007/09/25 00:40:51 UTC
"catching" test failure/error (or more generally failure within calls)
I would like to fail our build on junit test failure and still produce the
junit report.
Easy enough generally, however, our build runs somewhat similarly to make in
that I have an ant properties file in each folder that describes the list of
folders to build within that folder, and using common imported generic build
files, it recurses through folders until it finds a project and does a build
(<javac>, <jar>, <junit>, etc).
Once all folders have been recursed through the top level build.xml produces
the report.
The problem I have is that because the <junit> call is done within each
project (eventually, via a tree of nested <subant> calls) if I use the
haltonfailure/haltonerror attributes of <junit> the build fails within the
nested build file and never returns to the top level build file to produce
the report.
Any suggestions?
Cheers.
Greg
Ps. The reason I've nested things like this is because there may be projects
in the folder structure I don't want in the main build (for one reason or
another), so I use the properties to specify which subfolders to build
throughout the full structure.
Perhaps if I shifted the lists of folders a single list/file at the top
level I could remove the <subant> nesting and just have a top level file...
hmm... any other suggestions welcome...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: an input for ant arg.
Posted by David Weintraub <qa...@gmail.com>.
What about creating a <loadfile> task with a few <filtersets>?
Loadfile places the content of a file into a property. The
<filterchain> acts on the contents of that file. I load the file
input.sql into the property ${sql.line}. But, I add three filter
chains. The first filters out all lines except the one I am looking
for. The second transforms that line by removing the beginning and
trailing ends of the line, leaving only the middle you want. I also
had to add one more to strip out the linefeed on the end of the line.
<project name="test" default="test" basedir=".">
<target name="test">
<loadfile
srcfile="input.sql"
property="sql.line">
<filterchain>
<linecontainsregexp>
<regexp pattern="where keyp_clientid in .*--Second Wave"/>
</linecontainsregexp>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="^where keyp_clientid in
.*(\(.*\)).*$" replace="\1"/>
</tokenfilter>
<striplinebreaks/>
</filterchain>
</loadfile>
<echo message="Line is "${sql.line}""/>
</target>
</project>
What's nice about this is that it depends upon no operating specific
<exec> tasks, or outside ant tasks.
On Jan 9, 2008 5:00 PM, Chun Ji <CJ...@pro-unlimited.com> wrote:
>
> Hi all,
>
> I have a file: "input.sql" which contans a line as:
> "
> ...
> where keyp_clientid in (7,32,113,33) --Second Wave
> ..
> ",
>
> And I need this " (7, 32, 113, 33)" as an input string to excute a java class, and that is command line I use on my linux box, and it works,
> "
> java Test `grep "^where keyp_clientid in" input.sql | awk '{print $4}'`
>
> ".
>
>
>
> Now the question is how can I use this command line in an Ant Makefile to get the same results? Here is what I did in my "build.xml" and it fails:
> "
> ...
> <target name="migration">
> <exec executable="java" dir=".">
> <arg line="..."/>
> <arg line="Test `grep "^where keyp_clientid in" input.sql | awk '{print $4}'` "/>
> </exec>
> <xslt .../>
> </target>
> ...
> "
> The error msg is: Element type "arg" must be followed by either attribute specifications, ">" or "/>"
>
>
>
> So what should I do to solve this issue ? Any comments is welcome!
>
>
>
> thanks a lot,
>
>
>
> Chun
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
--
David Weintraub
qazwart@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: "catching" test failure/error (or more generally failure within
calls)
Posted by Geoffrey Mitchell <ge...@homedecorators.com>.
Use the "failureproperty" attribute of the junit task to set a property
on failure. How to propagate that back to your top level build is
another question. You could write out a file and check for it, I suppose.
Greg Irvine wrote:
>I would like to fail our build on junit test failure and still produce the
>junit report.
>
>Easy enough generally, however, our build runs somewhat similarly to make in
>that I have an ant properties file in each folder that describes the list of
>folders to build within that folder, and using common imported generic build
>files, it recurses through folders until it finds a project and does a build
>(<javac>, <jar>, <junit>, etc).
>Once all folders have been recursed through the top level build.xml produces
>the report.
>
>The problem I have is that because the <junit> call is done within each
>project (eventually, via a tree of nested <subant> calls) if I use the
>haltonfailure/haltonerror attributes of <junit> the build fails within the
>nested build file and never returns to the top level build file to produce
>the report.
>
>Any suggestions?
>
>
>Cheers.
>
>Greg
>
>
>Ps. The reason I've nested things like this is because there may be projects
>in the folder structure I don't want in the main build (for one reason or
>another), so I use the properties to specify which subfolders to build
>throughout the full structure.
>Perhaps if I shifted the lists of folders a single list/file at the top
>level I could remove the <subant> nesting and just have a top level file...
>hmm... any other suggestions welcome...
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>
>
--
Geoffrey Mitchell
Programmer/Analyst
Home Decorator's Collection
314-684-1062
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: an input for ant arg.
Posted by Alec Fernandez <Al...@sas.com>.
Don't for get to use " for the " char and ' for the ' char in your ant source
>> -----Original Message-----
>> From: Steve Loughran [mailto:stevel@apache.org]
>> Sent: Thursday, January 10, 2008 5:30 AM
>> To: Ant Users List
>> Subject: Re: an input for ant arg.
>>
>> Chun Ji wrote:
>>
>> > <target name="migration">
>> > <exec executable="java" dir=".">
>> > <arg line="..."/>
>> > <arg line="Test `grep "^where keyp_clientid in"
>> input.sql | awk '{print $4}'` "/>
>> > </exec>
>> > <xslt .../>
>> > </target>
>> > ...
>> > "
>> > The error msg is: Element type "arg" must be followed by
>> either attribute specifications, ">" or "/>"
>> >
>> >
>> >
>> > So what should I do to solve this issue ? Any comments is welcome!
>> >
>>
>> The problem is the second <arg> statement has way too many
>> quotes in the line attribute for XML to handle. This an XML
>> problem, not an ant one.
>> You can use paired single quotes
>>
>> line='some "inner" thing'
>> or double
>> line="some 'other' thing"
>> but you cant have the same quotation type inside as out.
>>
>> Try creating the string from a couple of properties
>> <property name="grep" value='"^where keyp_clientid in"' />
>> ..and build these up
>>
>> of course, when you do that you'd find that the pipe, the
>> grep and the awk wouldnt work, as they are shell commands.
>> You'd need to run bash.
>> Much better to
>> -create at an outputredirector for the output
>> -create a filterchain in the outputredirector that did your search
>>
>> -steve
>>
>> --
>> Steve Loughran
>> http://www.1060.org/blogxter/publish/5
>> Author: Ant in Action http://antbook.org/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For
>> additional commands, e-mail: user-help@ant.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: an input for ant arg.
Posted by Steve Loughran <st...@apache.org>.
Chun Ji wrote:
> <target name="migration">
> <exec executable="java" dir=".">
> <arg line="..."/>
> <arg line="Test `grep "^where keyp_clientid in" input.sql | awk '{print $4}'` "/>
> </exec>
> <xslt .../>
> </target>
> ...
> "
> The error msg is: Element type "arg" must be followed by either attribute specifications, ">" or "/>"
>
>
>
> So what should I do to solve this issue ? Any comments is welcome!
>
The problem is the second <arg> statement has way too many quotes in the
line attribute for XML to handle. This an XML problem, not an ant one.
You can use paired single quotes
line='some "inner" thing'
or double
line="some 'other' thing"
but you cant have the same quotation type inside as out.
Try creating the string from a couple of properties
<property name="grep" value='"^where keyp_clientid in"' />
..and build these up
of course, when you do that you'd find that the pipe, the grep and the
awk wouldnt work, as they are shell commands. You'd need to run bash.
Much better to
-create at an outputredirector for the output
-create a filterchain in the outputredirector that did your search
-steve
--
Steve Loughran http://www.1060.org/blogxter/publish/5
Author: Ant in Action http://antbook.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
an input for ant arg.
Posted by Chun Ji <CJ...@pro-unlimited.com>.
Hi all,
I have a file: "input.sql" which contans a line as:
"
...
where keyp_clientid in (7,32,113,33) --Second Wave
..
",
And I need this " (7, 32, 113, 33)" as an input string to excute a java class, and that is command line I use on my linux box, and it works,
"
java Test `grep "^where keyp_clientid in" input.sql | awk '{print $4}'`
".
Now the question is how can I use this command line in an Ant Makefile to get the same results? Here is what I did in my "build.xml" and it fails:
"
...
<target name="migration">
<exec executable="java" dir=".">
<arg line="..."/>
<arg line="Test `grep "^where keyp_clientid in" input.sql | awk '{print $4}'` "/>
</exec>
<xslt .../>
</target>
...
"
The error msg is: Element type "arg" must be followed by either attribute specifications, ">" or "/>"
So what should I do to solve this issue ? Any comments is welcome!
thanks a lot,
Chun
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org