You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Daniel John Debrunner <dj...@apache.org> on 2007/01/11 20:46:12 UTC

junit-oneclass target questions

Q1) The junit-oneclass target has a classpath entry:
       <classpath>
         <pathelement path="${out.dir}"/>
         <pathelement path="${junit}"/>
       </classpath>

    However if execute a target such as junit-jdbc4 target without 
CLASSPATH set I fail to execute the task. When I explictly set CLASSPATH 
to just contain the classes folder and junit.jar from tools/java I run 
the task successfully.
So what is the above classpath entry doing?

Q2) From a call to junit-oneclass can I set a system property for the 
forked JVM? E.g.

     <antcall target="junit-oneclass">
       <param name="derby.junit.jvm"
              value="${jdk16}/bin/java"/>
       <param name="derby.junit.testname"
 
value="org.apache.derbyTesting.functionTests.tests.jdbcapi.AutoloadBooting"/>
     </antcall>

How could I set a system property that will be passed onto the JVM 
running the junit test?

Thanks,
Dan.


Re: junit-oneclass target questions

Posted by Andrew McIntyre <mc...@gmail.com>.
On 1/12/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Can the classpath tag and its entries be removed junit-oneclass?

Definitely. As I said in the previous email, I don't think Ant should
be setting a classpath anyway. I've removed it with revision 495657.

andrew

Re: junit-oneclass target questions

Posted by Daniel John Debrunner <dj...@apache.org>.
Andrew McIntyre wrote:
> On 1/11/07, Daniel John Debrunner <dj...@apache.org> wrote:
>> Q1) The junit-oneclass target has a classpath entry:
>>        <classpath>
>>          <pathelement path="${out.dir}"/>
>>          <pathelement path="${junit}"/>
>>        </classpath>
>>
>>     However if execute a target such as junit-jdbc4 target without
>> CLASSPATH set I fail to execute the task. When I explictly set CLASSPATH
>> to just contain the classes folder and junit.jar from tools/java I run
>> the task successfully.
>> So what is the above classpath entry doing?
> 
> Nothing. :-)
> 
> For the same reason that junit.jar doesn't actually get added to the
> classpath, the contents of ${out.dir} are not being added either. [1]
> I'm not sure that they should anyway. I think the targets should rely
> on the setting of the classpath for the classes instead of trying to
> set one themselves, since the user knows better than Ant whether they
> want to run from the classes, jars, or at some point in the future,
> however they were packaged in the distribution they downloaded.

Actually it's more than nothing, in fact it's annoying. :-)

If CLASSPATH is unset or set to empty then those lines do nothing.

If CLASSPATH includes junit.jar then those classpath pathelements do add 
those paths to the *front* of the classpath passed onto the JVM.

Since ${out.dir} (classes folder) is added to the front it overrides any 
other Derby entries in CLASSPATH, such as the jar files. So setting the 
CLASSPATH as this:

export CLASSPATH=`cygpath -wp 
"${HOME}/jars/insane/derbyTesting.jar:${HOME}/jars/insane/derby.jar:${HOME}/tools/java/junit.jar"`

does not result in the tests being run against the jar files. Thus 
anyone using the ant targets to run tests might not be testing what they 
think they are.

Can the classpath tag and its entries be removed junit-oneclass?

Thanks,
Dan.



Re: junit-oneclass target questions

Posted by Andrew McIntyre <mc...@gmail.com>.
On 1/11/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> Seems like we almost rely on that behaviour today, given we use param in
> some of the calls to junit-oneclass, such as junit-jdbc4. I confirmed
> that values set in param are reset with a simple experiment.

My concern was that a variable that isn't used every time might have a
value set by a previous antcall the next time it was invoked, in an
antcall where you didn't want that setting. If you tested it and it
resets it to have no value, then great. :-)

andrew

Re: junit-oneclass target questions

Posted by Daniel John Debrunner <dj...@apache.org>.
Andrew McIntyre wrote:
> On 1/11/07, Daniel John Debrunner <dj...@apache.org> wrote:

Thanks for the reply.

[Q1 snipped]

>> Q2) From a call to junit-oneclass can I set a system property for the
>> forked JVM? E.g.
>>
>>      <antcall target="junit-oneclass">
>>        <param name="derby.junit.jvm"
>>               value="${jdk16}/bin/java"/>
>>        <param name="derby.junit.testname"
>>
>> value="org.apache.derbyTesting.functionTests.tests.jdbcapi.AutoloadBooting"/> 
>>
>>      </antcall>
>>
>> How could I set a system property that will be passed onto the JVM
>> running the junit test?
> 
> We could put a placeholder <jvmarg> into the junit-oneclass <java>
> task that is set to the value of a property. I believe that if the
> property is set in an antcall <param>, the value of the property will
> be reverted back to its previous unset state once that antcall is
> done, so the property wouldn't affect other calls to junit-oneclass,
> but I would want to test that to be certain.

Seems like we almost rely on that behaviour today, given we use param in 
some of the calls to junit-oneclass, such as junit-jdbc4. I confirmed 
that values set in param are reset with a simple experiment.

Thanks,
Dan.



Re: junit-oneclass target questions

Posted by Andrew McIntyre <mc...@gmail.com>.
On 1/11/07, Daniel John Debrunner <dj...@apache.org> wrote:
> Q1) The junit-oneclass target has a classpath entry:
>        <classpath>
>          <pathelement path="${out.dir}"/>
>          <pathelement path="${junit}"/>
>        </classpath>
>
>     However if execute a target such as junit-jdbc4 target without
> CLASSPATH set I fail to execute the task. When I explictly set CLASSPATH
> to just contain the classes folder and junit.jar from tools/java I run
> the task successfully.
> So what is the above classpath entry doing?

Nothing. :-)

For the same reason that junit.jar doesn't actually get added to the
classpath, the contents of ${out.dir} are not being added either. [1]
I'm not sure that they should anyway. I think the targets should rely
on the setting of the classpath for the classes instead of trying to
set one themselves, since the user knows better than Ant whether they
want to run from the classes, jars, or at some point in the future,
however they were packaged in the distribution they downloaded.

> Q2) From a call to junit-oneclass can I set a system property for the
> forked JVM? E.g.
>
>      <antcall target="junit-oneclass">
>        <param name="derby.junit.jvm"
>               value="${jdk16}/bin/java"/>
>        <param name="derby.junit.testname"
>
> value="org.apache.derbyTesting.functionTests.tests.jdbcapi.AutoloadBooting"/>
>      </antcall>
>
> How could I set a system property that will be passed onto the JVM
> running the junit test?

We could put a placeholder <jvmarg> into the junit-oneclass <java>
task that is set to the value of a property. I believe that if the
property is set in an antcall <param>, the value of the property will
be reverted back to its previous unset state once that antcall is
done, so the property wouldn't affect other calls to junit-oneclass,
but I would want to test that to be certain.

[1] http://ant.apache.org/faq.html#delegating-classloaderhttp://ant.apache.org/faq.html#delegating-classloader