From: Brad C. <bc...@bo...> - 2003-04-04 18:59:51
|
The missing section here (and where my problem originally came from) was that I'm using the optional <depend> task to do the java dependency checking. This has the possibility of removing class files without the java file ever changing, leaving an orphaned XML test result file. So, in order to make sure I clean up any stale XML test data I have to use <outofdate> "backwards" to get the list of xml files that had no matching class file. I would prefer to do it directly, but there is no complement to the "package" mapper that will change it back to a directory structure. My hope is that <pathtofileset> will covert <outofdate>'s paths to something I can use for deletion, instead of the nasty <pathconvert> <-> fileset conversion I'm currently doing. My other concern is that using the "dir" attribute on the mapper will not give me all of the existing XML files, only the ones that get mapped to because of existing class files. Without a reverse "package" mapper to clean up the stale XML I fear this won't work. If all of this doesn't work I may have to write my own task that takes a testdatadir, testsrcdir, and testclassesdir and does all the work in java, giving you back a fileset of the tests that need to be executed. Brad At 06:04 AM 4/4/2003, peter reilly wrote: >Ok I have coded task pathtofileset and added an extra >dir attribute to the mapper used by outofdate. > >I will try to get these changes to source code control >today (unless vetoed :)). > >Peter. > >With these changes one can run unit tests on source files >that are changed as follows: > > <target name="test-changed" depends="compile-tests"> > <taskdef resource="net/sf/antcontrib/antcontrib.properties" > classpath="${contrib.jar}"/> > > <property name="test.report.dir" location="test.report"/> > > <mkdir dir="${test.report.dir}"/> > > > <!-- set changed.sources.path to contain sources that are > newer than their corresponding report xml files --> > <outofdate outputsourcespath="changed.sources.path"> > <sourcefiles> > <fileset dir="${src}"/> > </sourcefiles> > <mapper dir="${src}" type="package" from="*.java" > to="${test.report.dir}/TEST-*Test.xml"/> > </outofdate> > > <!-- misuse outof date to map one path to another > map changes sources to corresponding test classes --> > <outofdate alltargetspath="changed.classes.path"> > <sourcefiles> > <path refid="changed.sources.path"/> > </sourcefiles> > <mapper dir="${src}" type="glob" from="*.java" > to="${testclasses}/*Test.class"/> > </outofdate> > > <!-- convert test classes path to a test classes file set --> > <pathtofileset dir="${testclasses}" > pathrefid="changed.classes.path" > name="changed.classes.fileset"/> > > <!-- only run the test classes corresponding to changed file set --> > <junit haltonfailure="true"> > <formatter type="xml"/> > <formatter type="brief" usefile="false"/> > <batchtest todir="${test.report.dir}"> > <fileset refid="changed.classes.fileset"/> > </batchtest> > <sysproperty key="antcontrib.jar" file="${contrib.jar}"/> > <classpath> > <pathelement location="${contrib.jar}"/> > <pathelement location="${testclasses}"/> > <pathelement location="${ant.testutil}"/> > <pathelement location="${junit.jar}"/> > </classpath> > </junit> > </target> > > > >------------------------------------------------------- >This SF.net email is sponsored by: ValueWeb: >Dedicated Hosting for just $79/mo with 500 GB of bandwidth! >No other company gives more support or power for your dedicated server >http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ >_______________________________________________ >Ant-contrib-developers mailing list >Ant...@li... >https://lists.sourceforge.net/lists/listinfo/ant-contrib-developers |