ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric" <eric.finger...@verizon.net>
Subject right way to use a condition
Date Mon, 24 May 2004 15:09:07 GMT
Hi;

I have a condition to determine whether or not my test target should run
junit reports. I placed the condition in a dependent task, test-init' (which
also tries to make use of the condition). The condition doesn't work however
(the tests run whether the condition is true or false), so I'm thinking I
haven't placed it in the right spot. The sample code is below.

Thanks much in advance, -Eric

1) The condition in the dependent tesk (test-init):

<!-- ======================================================== -->
<!-- target: test-init, set-up for testing -->
<!-- ======================================================== -->
<target name="test-init" description="--> prepare for testing"
	unless="tests.uptodate" <-------------------------------------CONDITION
>
	<!-- short-circuit running junit tests condition -->
	<condition property="tests.uptodate">
		<and>
			<uptodate>
				<srcfiles dir="${src.home}" includes="**/*.java" />
				<mapper type="glob"
					from="*.java"
					to="${build.classes.home}/*.class"/>
			</uptodate>
		<!-- ... -->
	</condition>
	<mkdir dir="${test.home}" />
	<copy todir="${test.home}">
		<fileset dir="test" excludes="**/*.java" />
	</copy>
	<delete dir="${test.data.home}" />
	<delete dir="${test.reports.home}" />
	<mkdir dir="${test.data.home}" />
	<mkdir dir="${test.reports.home}" />
</target>

2) the main run target (test)
<!-- ======================================================== -->
<!-- target: test, run JUnit tests -->
<!-- ======================================================== -->
	<target name="test"
	        depends="test-compile"
	        unless="tests.uptodate"
<-------------------------------------CONDITION
	        description="--> run JUnit tests"
	>
		<junit printsummary="false"
		       errorProperty="test.failed"
		       failureProperty="test.failed"
		       fork="$junit.fork}"
		>
			<classpath>
				<path refid="test.classpath" />
				<pathelement path="${java.class.path}" />
			</classpath>
			<formatter type="brief" usefile="false" />
			<formatter type="xml" />
			<batchtest todir="${test.data.home}">
				<fileset dir="${test.home}" includes="**/*Test.class" />
			</batchtest>
		</junit>

		<junitreport todir="${test.data.home}">
			<fileset dir="${test.data.home}">
				<include name="TEST-*.xml" />
			</fileset>
			<report format="frames" todir="${test.reports.home}" />
		</junitreport>

		<echo message="last build failed tests"
		      file="${test.last.failed.file}"
		/>

		<fail message="Tests failed. Check log and/or reports."
		      if="test.failed"
		/>

		<!-- Remove test failed file, as these tests succeeded -->
		<delete file="${test.last.failed.file}" />
	</target>



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


Mime
View raw message