File: run-tests.xml

package info (click to toggle)
texhyphj 1.2+dfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 448 kB
  • sloc: java: 2,033; xml: 297; makefile: 24
file content (116 lines) | stat: -rw-r--r-- 3,716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="runUnitTests">
	<description>Buildfile for this project</description>
	
	<import file="build-properties.xml"/>

	<property name="test-src.dir" value="${basedir}/test"/>

	<property name="test-build.dir" value="${ant-output.dir}/test-build.temp"/>
	<property name="tests-jar.name" value="tests-temp.jar"/>

	<property name="dist-unzip.dir" value="${ant-output.dir}/test-unzip"/>
	<property name="dist-root.dir" value="${ant-output.dir}/test-unzip/${zip-foler-prefix}"/>
	<property name="dist-lib.dir" value="${dist-unzip.dir}/${zip-foler-prefix}/lib"/>
	
	<property name="test.report.dir" value="${ant-output.dir}/test-report"/>
	<property name="test.report-temp.dir" value="${ant-output.dir}/test-report.temp"/>

	<path id="test.classpath">
		<!--
		<fileset dir="${dist-lib.dir}">
			<include name="*.jar"/>
		</fileset>--> 
		<fileset dir="${dist-root.dir}">
			<include name="*.jar"/>
		</fileset>
		<fileset dir="${lib.dir}">
			<include name="junit*.jar"/>
			<include name="hamcrest*.jar"/>
		</fileset>
		<fileset dir="${ant-output.dir}">
			<include name="${tests-jar.name}"/>
		</fileset>
	</path>
	
	<patternset id="test.patternset">
		<include name="**/*.*"/>
		<exclude name="**/doc-files/**/*.*"/>
		<exclude name="**/package.html"/>
	</patternset>
	
    <target name="compileTests">
    	<subant target="buildZip">
    		<fileset dir="${basedir}">
    			<include name="build.xml"/>
    		</fileset>
    	</subant>
    	
    	<!-- Unzip dotify -->
    	<delete dir="${dist-unzip.dir}"/>
    	<unzip src="${distribution.zip}" dest="${dist-unzip.dir}"/>
    	
    	<delete dir="${test-build.dir}"/>
    	<mkdir dir="${test-build.dir}"/>

    	<!-- Compile test files -->
	    <javac srcdir="${test-src.dir}" destdir="${test-build.dir}" includeantruntime="false" encoding="UTF-8">
			<classpath>
				<fileset dir="${dist-root.dir}">
					<include name="*.jar"/>
				</fileset>
				<fileset dir="${lib.dir}">
					<include name="junit*.jar"/>
					<include name="hamcrest*.jar"/>
				</fileset>
			</classpath>
	    </javac>
    	
    	<!-- Copy required resource files -->
    	<copy todir="${test-build.dir}" >
    	  <fileset dir="${test-resources.dir}"/>
    	</copy>
    </target>
	
	<target name="runUnitTests" description="Run unit tests" depends="compileTests">
		<!-- <antcall target="compileTests"/> -->
		<jar destfile="${ant-output.dir}/${tests-jar.name}">
    		<fileset dir="${test-build.dir}">
    			<patternset refid="test.patternset"/>
    		</fileset>
			<fileset dir="${test-src.dir}">
				<patternset refid="test.patternset"/>
			</fileset>
    	</jar>

    	<delete dir="${test.report.dir}"/>
    	<mkdir dir="${test.report.dir}"/>

		<mkdir dir="${test.report-temp.dir}"/>

		<junit fork="yes" printsummary="no" haltonfailure="no" errorproperty="testerror" failureproperty="testfail">
			<batchtest fork="yes" todir="${test.report-temp.dir}">
		      <fileset dir="${test-build.dir}">
		        <include name="**/*Test.class" />
		      </fileset>
		    </batchtest>
		    <formatter type="xml" />
		    <classpath refid="test.classpath" />
		</junit>
		
		<junitreport todir="${test.report.dir}">
			<fileset dir="${test.report-temp.dir}">
				<include name="TEST-*.xml" />
			</fileset>
			<report todir="${test.report.dir}" />
		</junitreport>
		
		<delete dir="${test.report-temp.dir}"/>
		<delete dir="${test-build.dir}"/>
		<delete file="${ant-output.dir}/${tests-jar.name}"/>
		<delete dir="${dist-unzip.dir}"/>

		<fail if="testerror" message="Error in tests"/>
	</target>
	
</project>