ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Genter" <rgen...@silverlink.com>
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"/>
  ...
</path>

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

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

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

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">
    <classpath>
      <path refid="exec.class.path"/>
    </classpath>
    <test name="com.silverlink.object.BasicTest"/>
  </junit>
</target>

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

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
subdirectories.

--
Rick Genter
Principal Engineer
Silverlink Communications
<mailto:rgenter@silverlink.com>
(781) 272-3080 x242

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

> From: Rick Genter [mailto:rgenter@silverlink.com]
> 
> My overall issue is that I'm trying to build an ant script that will
run
> 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: 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


Mime
View raw message