<!-- ============================================================================== --> <!-- This assumes a complete pre-built eclipse workspace --> <!-- ============================================================================== --> <project name="junitModules" default="test-all-but-ajc" basedir="."> <property name="project.name" value="junitModules"/> <target name="info"> <echo > Variables to consider defining: aspectjrt.path path to release version of runtime test.classpath use "jar.classpath" or "bin.classpath" (default is bin if available) Both require module tests be built with the modules. bin.classpath: use eclipse bin/ directories jar.classpath: use build.xml jar files: cd build ant clean ant -Dtrim.testing.default=false build-testing-jars java13.path: path to jdk 1.3 java.exe command for ajc tests java14.path: path to jdk 1.4 java.exe command for ajc tests </echo> </target> <target name="init"> <property name="haltOnTestFailure" value="false"/> <property name="modules.dir" location="${basedir}/.."/> <property name="jar.dir" location="${modules.dir}/aj-build/jars"/> <property name="tests.module.dir" location="${modules.dir}/tests"/> <property name="aspectj.modules.lib.dir" location="${modules.dir}/lib"/> <property name="harness.lib.dir" location="${aspectj.modules.lib.dir}/test"/> <property name="junitModules.output.dir" location="${tests.module.dir}/bin/junitXmlOutput" /> <property name="aspectjrt.path" location="${aspectj.modules.lib.dir}/test/aspectjrt.jar"/> <property name="ajc.tests.xml.file" location="${tests.module.dir}/ajcTests.xml"/> <property name="ajc.tests.output.file" location="${junitModules.output.dir}/ajc/TEST-ajcTests.xml"/> <property name="ajc.tests.emacssym.xml.file" location="${tests.module.dir}/ajcTestsEmacssym.xml"/> <property name="ajc.tests.emacssym.output.file" location="${junitModules.output.dir}/ajc/TEST-ajcTestsEmacssym.xml"/> <mkdir dir="${junitModules.output.dir}"/> <path id="lib.classpath"> <pathelement location="${aspectj.modules.lib.dir}/bcel/bcel.jar" /> <pathelement location="${aspectj.modules.lib.dir}/jdiff/jdiff.jar" /> <pathelement location="${aspectj.modules.lib.dir}/commons/commons.jar" /> <pathelement location="${aspectj.modules.lib.dir}/ant/lib/ant.jar" /> <pathelement location="${aspectj.modules.lib.dir}/ant/lib/xml-apis.jar" /> <pathelement location="${aspectj.modules.lib.dir}/ant/lib/xercesImpl.jar" /> <pathelement location="${aspectj.modules.lib.dir}/junit/junit.jar" /> <pathelement location="${modules.dir}/org.eclipse.jdt.core/jdtcore-for-aspectj.jar" /> </path> <path id="bin.classpath"> <pathelement location="${modules.dir}/ajde/bin" /> <pathelement location="${modules.dir}/ajbrowser/bin" /> <pathelement location="${modules.dir}/asm/bin" /> <pathelement location="${modules.dir}/bridge/bin" /> <pathelement location="${modules.dir}/build/bin" /> <pathelement location="${modules.dir}/org.aspectj.ajdt.core/bin" /> <pathelement location="${modules.dir}/runtime/bin" /> <pathelement location="${modules.dir}/taskdefs/bin" /> <pathelement location="${modules.dir}/testing/bin" /> <pathelement location="${modules.dir}/testing-client/bin" /> <pathelement location="${modules.dir}/testing-drivers/bin" /> <pathelement location="${modules.dir}/testing-util/bin" /> <pathelement location="${modules.dir}/util/bin" /> <pathelement location="${modules.dir}/weaver/bin" /> <path refid="lib.classpath"/> </path> <!-- requires normal build, i.e., with test classes --> <path id="jar.classpath"> <pathelement location="${jar.dir}/ajde.jar" /> <pathelement location="${jar.dir}/ajbrowser.jar" /> <pathelement location="${jar.dir}/asm.jar" /> <pathelement location="${jar.dir}/bridge.jar" /> <pathelement location="${jar.dir}/build.jar" /> <pathelement location="${jar.dir}/org.aspectj.ajdt.core.jar" /> <pathelement location="${jar.dir}/runtime.jar" /> <pathelement location="${jar.dir}/taskdefs.jar" /> <pathelement location="${jar.dir}/testing.jar" /> <pathelement location="${jar.dir}/testing-client.jar" /> <pathelement location="${jar.dir}/testing-drivers.jar" /> <pathelement location="${jar.dir}/testing-util.jar" /> <pathelement location="${jar.dir}/util.jar" /> <pathelement location="${jar.dir}/weaver.jar" /> <path refid="lib.classpath"/> </path> <available property="bin.path.available" file="${modules.dir}/weaver/bin"/> <available property="jar.path.available" file="${jar.dir}/asm.jar"/> </target> <target name="select-path" depends="select-jar,select-bin" unless="test.classpath"/> <target name="select-bin" depends="init" if="bin.path.available"> <property name="test.classpath" value="bin.classpath"/> </target> <target name="select-jar" depends="init" if="jar.path.available" unless="bin.path.available"> <property name="test.classpath" value="jar.classpath"/> </target> <target name="clean" depends="init"> <delete dir="${junitModules.output.dir}"/> </target> <target name="jdepend" depends="init" description="run jdepend - untested"> <jdepend format="xml"> <sourcespath> <pathelement location="${tests.module.dir}/../testing/src" /> </sourcespath> <classpath> <pathelement location="${tests.module.dir}/../bin" /> </classpath> </jdepend> </target> <target name="redirect-test-all" depends="init" description="run from another Ant process to redirect output"> <antcall target="clean"/> <mkdir dir="${junitModules.output.dir}"/> <ant dir="${basedir}" antfile="junitModules.xml" target="run-test-all" inheritAll="false" output="${junitModules.output.dir}/output.txt"/> <echo message="View log in ${junitModules.output.dir}/output.txt"/> <property name="fileUrl" location="${junitModules.output.dir}/html/index.html"/> <echo message="View results in file:${fileUrl}"/> </target> <target name="test-all-at-once" depends="init,select-path" description="run all module tests (except IDE integrations)"> <echo message="fails - AJDE needs ../ajde-style paths"/> <mkdir dir="${junitModules.output.dir}"/> <delete dir="${junitModules.output.dir}"/> <mkdir dir="${junitModules.output.dir}"/> <junit fork="on" includeAntRuntime="off" dir="${tests.module.dir}" printsummary="yes" haltonfailure="${haltOnTestFailure}" > <classpath> <path refid="${test.classpath}"/> </classpath> <jvmarg value="-Daspectjrt.path=${aspectjrt.path}" /> <formatter type="xml"/> <batchtest todir="${junitModules.output.dir}"> <formatter type="xml"/> <fileset dir="${modules.dir}/ajbrowser/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/asm/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/ajde/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/bridge/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/build/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/org.aspectj.ajdt.core/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/runtime/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/taskdefs/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/testing/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/testing-client/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/testing-drivers/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/testing-util/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/util/testsrc"> <include name="*ModuleTests.java" /> </fileset> <fileset dir="${modules.dir}/weaver/testsrc"> <include name="*ModuleTests.java" /> </fileset> </batchtest> </junit> </target> <target name="test-ajctest-junit" depends="init,select-path" description="run JUnit tests"> <antcall target="run-ajctests-junit-tests"/> <antcall target="report-tests"/> </target> <target name="test-all-but-ajc" depends="init,select-path" description="run all module tests (except IDE integrations)"> <mkdir dir="${junitModules.output.dir}"/> <delete dir="${junitModules.output.dir}"/> <mkdir dir="${junitModules.output.dir}"/> <antcall target="run-module-junit-tests"> <param name="moduleName" value="ajbrowser"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="ajde"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="asm"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="weaver"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="bridge"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="build"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="org.aspectj.ajdt.core"/> </antcall> <!-- no JUnit testsrc in org.eclipse.jdt.core --> <antcall target="run-module-junit-tests"> <param name="moduleName" value="runtime"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="taskdefs"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="testing"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="testing-client"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="testing-drivers"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="testing-util"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="util"/> </antcall> <antcall target="report-tests"/> </target> <target name="test-all" depends="init,select-path" description="run all module tests (except IDE integrations)"> <mkdir dir="${junitModules.output.dir}"/> <delete dir="${junitModules.output.dir}"/> <mkdir dir="${junitModules.output.dir}"/> <antcall target="run-module-junit-tests"> <param name="moduleName" value="ajbrowser"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="ajde"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="asm"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="weaver"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="bridge"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="build"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="org.aspectj.ajdt.core"/> </antcall> <!-- no JUnit testsrc in org.eclipse.jdt.core --> <antcall target="run-module-junit-tests"> <param name="moduleName" value="runtime"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="taskdefs"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="testing"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="testing-client"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="testing-drivers"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="testing-util"/> </antcall> <antcall target="run-module-junit-tests"> <param name="moduleName" value="util"/> </antcall> <!-- run the ajc tests too... --> <antcall target="ajc-tests"> </antcall> <antcall target="ajc-tests-emacssym"> </antcall> <antcall target="report-tests"/> </target> <target name="init-taskdefs" depends="init" description="define junit taskdefs" > <property name="aj.taskdef.package" value="org.aspectj.internal.tools.ant.taskdefs"/> <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"> <classpath> <pathelement location="${aspectj.modules.lib.dir}/ant/xlib/optional.jar" /> <pathelement location="${aspectj.modules.lib.dir}/junit/junit.jar" /> </classpath> </taskdef> <taskdef name="junitreport" classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator"> <classpath> <pathelement location="${aspectj.modules.lib.dir}/ant/xlib/optional.jar" /> <pathelement location="${aspectj.modules.lib.dir}/junit/junit.jar" /> </classpath> </taskdef> </target> <target name="run-ajctests-junit-tests" depends="init-taskdefs" description="run the JUnit harness wrapper tests"> <mkdir dir="${junitModules.output.dir}/ajctest"/> <delete dir="${junitModules.output.dir}/ajctest"/> <mkdir dir="${junitModules.output.dir}/ajctest"/> <!-- fork to load classes, include AntRuntime to get taskdef classes junit.jar --> <echo message="Starting ajctest JUnit tests..."/> <junit fork="on" includeAntRuntime="off" dir="${modules.dir}/testing-drivers" printsummary="yes" haltonfailure="${haltOnTestFailure}" > <classpath> <path refid="${test.classpath}"/> <pathelement location="${aspectjrt.path}"/> </classpath> <jvmarg value="-Daspectjrt.path=${aspectjrt.path}" /> <jvmarg value="-Dharness.libdir=${harness.lib.dir}" /> <formatter type="xml"/> <batchtest todir="${junitModules.output.dir}/ajctest"> <formatter type="xml"/> <fileset dir="${modules.dir}/testing-drivers/testsrc"> <include name="org/aspectj/testing/drivers/*UsingJUnit.java" /> </fileset> </batchtest> </junit> </target> <target name="run-module-junit-tests" depends="init-taskdefs" description="run all junit tests for a module"> <mkdir dir="${junitModules.output.dir}/${moduleName}"/> <!-- fork to load classes, include AntRuntime to get taskdef classes junit.jar --> <echo message="Starting ${moduleName} tests..."/> <junit fork="on" includeAntRuntime="off" dir="${modules.dir}/${moduleName}" printsummary="yes" haltonfailure="${haltOnTestFailure}" > <classpath> <path refid="${test.classpath}"/> <pathelement location="${aspectjrt.path}"/> </classpath> <!-- AMC added this next line, needed when testing release builds, (those whose version is something other than DEVELOPMENT). The NullIdeAdapter used for various Ajde tests picks up this property and adds it to the project classpath, which allows the Ajde version tests to complete. Having built a release version, use e.g. ant -Daspectjrt.path=../aj-build/dist/lib/aspectjrt.jar --> <jvmarg value="-Daspectjrt.path=${aspectjrt.path}" /> <formatter type="xml"/> <batchtest todir="${junitModules.output.dir}/${moduleName}"> <formatter type="xml"/> <fileset dir="${modules.dir}/${moduleName}/testsrc"> <include name="*ModuleTests.java" /> </fileset> </batchtest> </junit> </target> <target name="report-tests" depends="init-taskdefs"> <mkdir dir="${junitModules.output.dir}/html"/> <junitreport todir="${junitModules.output.dir}/html" tofile="results.html"> <fileset dir="${junitModules.output.dir}/"> <include name="**/TEST-*.xml"/> </fileset> <report format="frames" todir="${junitModules.output.dir}/html"/> </junitreport> <property name="fileUrl" location="${junitModules.output.dir}/html/index.html"/> <echo message="View results in file:${fileUrl}"/> </target> <target name="ajc-tests" depends="init-taskdefs"> <mkdir dir="${junitModules.output.dir}/ajc"/> <java classname="org.aspectj.testing.drivers.Harness" classpathref="${test.classpath}" output="${ajc.tests.output.file}" fork="true"> <arg value="-cruisecontrol"/> <arg file="${ajc.tests.xml.file}"/> </java> </target> <target name="ajc-tests-emacssym" depends="init-taskdefs"> <mkdir dir="${junitModules.output.dir}/ajc"/> <copy file="${ajc.tests.xml.file}" tofile="${ajc.tests.emacssym.xml.file}"/> <java classname="org.aspectj.testing.drivers.Harness" classpathref="${test.classpath}" output="${ajc.tests.emacssym.output.file}" fork="true"> <arg value="-cruisecontrol"/> <arg value="-emacssym"/> <arg file="${ajc.tests.emacssym.xml.file}"/> </java> <delete file="${ajc.tests.emacssym.xml.file}"/> </target> </project>