ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Genter" <>
Subject RE: Working directory confusion
Date Tue, 01 Feb 2005 17:44:37 GMT
No, the basedir was correct, but the cwd wasn't.

For each test case I copy the jars required by that test case as well as
its test data into the test case's subdirectory. This allows each test
case to be a self-contained unit if I need to pull it out for further
analysis or send it to someone or whatever. What that means, though, is
that I want to define a classpath like this:

<path id="exec.class.path">
  <pathelement location="./Test.jar"/>
  <pathelement location="./Object.jar"/>
  <pathelement location="./Messaging.jar"/>

where "." is the test directory. I then do:

<subant genericantfile="${basedir}/build.xml" target="test1">
  <dirset dir="." includes="test1"/>

<subant genericantfile="${basedir}/build.xml" target="test2">
  <dirset dir="." includes="test2"/>

and so forth. (This is simplified, not every directory is intended to be
invoked separately by <subant>.) The targets look like this:

<target name="test1">
  <junit haltonfailure="on" fork="true">
      <path refid="exec.class.path"/>
    <test name="com.silverlink.object.BasicTest"/>

<target name="test2">
  <junit haltonfailure="on" fork="true">
      <path refid="exec.class.path"/>
    <test name="com.silverlink.object.AdvancedTest"/>

I was hoping that when target test1 was invoked, the current working
directory would be "./test1" while when target test2 is invoked, the
current working directory would be "./test2", where "." is the
${basedir} of the original ant invocation. Instead, though the <subant>s
have their ${basedir} as expected ("./test1" and "./test2",
respectively), the CWDs are still the original ${basedir}. This means my
tests can't find their data, which are stored in the test

Rick Genter
Principal Engineer
Silverlink Communications
(781) 272-3080 x242

-----Original Message-----
From: Dominique Devienne [] 
Sent: Tuesday, February 01, 2005 12:12 PM
To: Ant Users List
Subject: RE: Working directory confusion

> From: Rick Genter []
> My overall issue is that I'm trying to build an ant script that will
> a number of unit tests after it builds my product. Each test is in its
> own test subdirectory; what I *really* wanted to do was use <subant>
> using the genericantfile attribute to specify the build file, but
> running each test in its own directory sharing a common set of
> properties. That failed pretty miserably, though.

And why/how did it fail? Because the basedir was not correct again? --DD

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message