ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doron Cohen <DOR...@il.ibm.com>
Subject Re: how to enable Java assertions (ie how to pass '-ea' to the jvm)
Date Thu, 31 May 2007 22:07:54 GMT
Thanks, I got it working now.

It is btw in a <junit>, not in a <java>, but I assume they
are equivalent.

Initially I was looking for a way to enable this from the
comnand line, without modifying our build.xml files. With
your feedback I found that adding this:
     <assertions>
         <enable/>
      </assertions>
to the <junit> target (which has fork=true) does the work,
and now Java assertions are enabled, regardless of ANT_OPTS.

This option was always there (in the docs) but I was so
focused on the command line path that I didn't see it.

I can modify the bulid files, so this solution is good
enough for my problem. Still I am curious why using the
documented ANT_OPTS did not work.

Thanks for your help,
Doron

"Peter Reilly" <peter.kitt.reilly@gmail.com> wrote on 31/05/2007 14:34:44:

> Also ensure that fork="yes".
> Peter
>
>
> On 5/31/07, David Alves <dalves@brnphoenix.com> wrote:
> > Can you use a <jvmarg> nested inside your <java> tag to specify the
-ea
> > parameter?
> >
> > Something like:
> >
> > <java classname="MyClass">
> >
> >         ...
> >
> >         <jvmarg value="-ea" />
> > </java>
> >
> > -----Original Message-----
> > From: Doron Cohen [mailto:DORONC@il.ibm.com]
> > Sent: Thursday, May 31, 2007 1:16 PM
> > To: user@ant.apache.org
> > Subject: how to enable Java assertions (ie how to pass '-ea'
> to the jvm)
> >
> >
> > Hi, probably a trivial question but I couldn't find a
> > working answer in the docs/archives/wiki/bugs. I have
> > a Java assert statement in my code that is supposed
> > to fail. Java compilation is with -source 1.4, which
> > compiles these assertions.
> >
> > When running from Java command line, like this:
> >   java -ea  junit.textui.TestRunner MyTestClass
> > or like this
> >   java -enableassertions junit.textui.TestRunner MyTestClass
> > The assert  (this is not Junit assert, it is a
> > Java assert) catches the bug and fails.
> >
> > But when running the same test case with ant:
> >   ant test
> > The assert is not applied and the test passes.
> >
> > Setting ANT_OPTS to '-ea' or to '-enableassertions'
> > did not work. This is with both ant 1.7.0 and 1.6.5.
> >
> > Now this is especially puzzling, since ANT_OPTS does
> > seem to work. For instance, when I set ANT_OPTS to
> > '-version', running "ant test" prints the Java version,
> > just as running "java -version" prints it.
> >
> > The Java version btw is HotSpot 1.5.0_06.
> > OS is Windows XP.
> >
> > Thanks,
> > Doron


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message