Skip to content

Commit cfb3ed8

Browse files
author
Mike Klimek
committed
Merge pull request #18 from khwolf:master
Added unit test suites to the ant build.xml
2 parents ac79c6c + 7658a05 commit cfb3ed8

File tree

3 files changed

+163
-155
lines changed

3 files changed

+163
-155
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/src/arden/constants/node
99
/src/arden/constants/parser
1010
/dist/
11+
/report/

build.xml

Lines changed: 152 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,106 @@
66
77
Author: Hannes Flicka (hflicka@github)
88
-->
9-
<project name="arden2bytecode" default="default" basedir=".">
10-
<description>arden2bytecode ant build script.</description>
9+
<project name="arden2bytecode" default="jar" basedir=".">
10+
<description>arden2bytecode ant build script</description>
11+
12+
<!-- global properties -->
13+
<property name="debug" value="on" />
14+
<property name="optimize" value="off" />
15+
<property name="deprecation" value="on" />
16+
<tstamp>
17+
<format property="release.stamp" pattern="yyyy-MM-dd" locale="en,US" />
18+
</tstamp>
19+
<property name="version" value="${DSTAMP}-${TSTAMP}" />
20+
<property name="name" value="${ant.project.name}" />
21+
<property name="src.dir" value="src" />
22+
<property name="test.dir" value="test" />
23+
<property name="test.report.dir" value="report" />
24+
<property name="tools.dir" value="tools" />
25+
<property name="resource.dir" value="resource" />
26+
<property name="lib.dir" value="lib" />
27+
<property name="build.dir" value="bin" />
28+
<property name="dist.dir" value="dist" />
29+
<property name="dist.file" value="${name}-${version}.jar" />
30+
<property name="mainclass" value="arden.MainClass" />
31+
<property name="mainclass.test.implementation" value="arden.tests.implementation.ImplementationTestSuite" />
32+
<property name="mainclass.test.specification" value="arden.tests.specification.SpecificationTestSuite" />
33+
34+
<filter token="log" value="true" />
35+
<filter token="verbose" value="true" />
1136

12-
<target name="default" depends="jar"
13-
description="default target, depends on 'jar' which means a binary jar file will be built.">
37+
<path id="build.classpath">
38+
<fileset dir="${lib.dir}">
39+
<include name="*.jar" />
40+
</fileset>
41+
</path>
42+
<path id="run.classpath">
43+
<path refid="build.classpath" />
44+
<path location="${build.dir}" />
45+
<path location="." />
46+
</path>
47+
<path id="test.classpath">
48+
<path refid="run.classpath" />
49+
</path>
50+
<path id="dist.classpath">
51+
<path location="." />
52+
</path>
53+
<fileset id="dist.libs" dir="${lib.dir}" includes="*.jar">
54+
<!-- exclude these libs from the generated jar -->
55+
<exclude name="junit*.jar" />
56+
<exclude name="hamcrest-core*.jar" />
57+
<exclude name="sqlite-jdbc*.jar" />
58+
</fileset>
59+
60+
61+
<target name="clean"
62+
description="Clean the 'bin', 'dist' and 'reports' directories and delete SableCC-generated .java files">
63+
<delete includeemptydirs="true" failonerror="false">
64+
<fileset dir="${build.dir}" includes="**/*" />
65+
<fileset dir="${dist.dir}" includes="**/*" />
66+
<fileset dir="${test.report.dir}" includes="**/*" />
67+
<fileset dir="${src.dir}/arden/constants/analysis" includes="**/*" />
68+
<fileset dir="${src.dir}/arden/constants/lexer" includes="**/*" />
69+
<fileset dir="${src.dir}/arden/constants/node" includes="**/*" />
70+
<fileset dir="${src.dir}/arden/constants/parser" includes="**/*" />
71+
<fileset dir="${src.dir}/arden/compiler/analysis" includes="**/*" />
72+
<fileset dir="${src.dir}/arden/compiler/lexer" includes="**/*" />
73+
<fileset dir="${src.dir}/arden/compiler/node" includes="**/*" />
74+
<fileset dir="${src.dir}/arden/compiler/parser" includes="**/*" />
75+
</delete>
1476
</target>
1577

16-
<target name="init"
17-
description="initializes used variables, mostly paths and directories">
18-
<tstamp>
19-
<format property="release.stamp" pattern="yyyy-MM-dd" locale="en,US" />
20-
</tstamp>
21-
<property name="debug" value="on" />
22-
<property name="optimize" value="off" />
23-
<property name="deprecation" value="on" />
24-
<property name="version" value="${DSTAMP}-${TSTAMP}" />
25-
<property name="name" value="${ant.project.name}" />
26-
<property name="src.dir" value="src" />
27-
<property name="test.dir" value="test" />
28-
<property name="tools.dir" value="tools" />
29-
<property name="resource.dir" value="resource" />
30-
<property name="lib.dir" value="lib" />
31-
<property name="build.dir" value="bin" />
32-
<property name="dist.dir" value="dist" />
33-
<property name="dist.jar" value="${name}-${version}.jar" />
34-
<property name="run.entrypoint" value="arden.MainClass" />
35-
<filter token="log" value="true" />
36-
<filter token="verbose" value="true" />
37-
<path id="build.classpath">
38-
<fileset dir="${lib.dir}">
39-
<include name="*.jar" />
40-
</fileset>
41-
</path>
42-
<path id="run.classpath">
43-
<path refid="build.classpath" />
44-
<path location="${build.dir}" />
45-
<path location="." />
46-
</path>
47-
<path id="jar.classpath">
48-
<path location="." />
49-
</path>
78+
79+
<target name="compile" depends="sableCC"
80+
description="Compile sources">
81+
<mkdir dir="${build.dir}" />
5082

51-
<condition property="sableCCDirectoriesExist">
52-
<and>
53-
<available file="${src.dir}/arden/compiler/analysis" type="dir" />
54-
<available file="${src.dir}/arden/compiler/lexer" type="dir" />
55-
<available file="${src.dir}/arden/compiler/node" type="dir" />
56-
<available file="${src.dir}/arden/compiler/parser" type="dir" />
57-
<available file="${src.dir}/arden/constants/analysis" type="dir" />
58-
<available file="${src.dir}/arden/constants/lexer" type="dir" />
59-
<available file="${src.dir}/arden/constants/node" type="dir" />
60-
<available file="${src.dir}/arden/constants/parser" type="dir" />
61-
</and>
62-
</condition>
83+
<!-- copy other (not .java) files -->
84+
<copy todir="${build.dir}">
85+
<fileset dir="${src.dir}">
86+
<exclude name="**/*.java" />
87+
<exclude name="**/*.class" />
88+
</fileset>
89+
<fileset dir="${test.dir}">
90+
<exclude name="**/*.java" />
91+
<exclude name="**/*.class" />
92+
</fileset>
93+
</copy>
6394

95+
<javac srcdir="${src.dir}:${test.dir}" destdir="${build.dir}" debug="${debug}"
96+
classpathref="build.classpath" optimize="${optimize}" source="1.6" includeantruntime="false">
97+
<include name="**/*.java" />
98+
</javac>
6499
</target>
65100

66-
<target name="createSableCCDirectories" unless="sableCCDirectoriesExist">
101+
102+
<target name="sableCC" depends="sableCC.constants, sableCC.compiler"
103+
description="Start sableCC to generate parsers from grammars">
104+
</target>
105+
106+
107+
<target name="init.sableCC">
108+
<!-- create SableCC directories -->
67109
<mkdir dir="${src.dir}/arden/compiler/analysis" />
68110
<mkdir dir="${src.dir}/arden/compiler/lexer" />
69111
<mkdir dir="${src.dir}/arden/compiler/node" />
@@ -72,110 +114,60 @@
72114
<mkdir dir="${src.dir}/arden/constants/lexer" />
73115
<mkdir dir="${src.dir}/arden/constants/node" />
74116
<mkdir dir="${src.dir}/arden/constants/parser" />
75-
</target>
76-
77-
<target name="cleanClasses" depends="init"
78-
description="clean all java classes and files in the 'bin' directory">
79-
<mkdir dir="${build.dir}" />
80-
<delete includeemptydirs="true">
81-
<fileset dir="${build.dir}" includes="**/*" />
82-
</delete>
83-
</target>
84-
85-
<target name="clean" depends="init,createSableCCDirectories,cleanClasses"
86-
description="clean the 'bin' and 'dist' directories and delete sableCC-generated .java files">
87-
<mkdir dir="${dist.dir}" />
88-
<delete includeemptydirs="true">
89-
<fileset dir="${dist.dir}" includes="**/*" />
90-
<fileset dir="${src.dir}/arden/compiler/analysis" includes="**/*" />
91-
<fileset dir="${src.dir}/arden/compiler/lexer" includes="**/*" />
92-
<fileset dir="${src.dir}/arden/compiler/node" includes="**/*" />
93-
<fileset dir="${src.dir}/arden/compiler/parser" includes="**/*" />
94-
<fileset dir="${src.dir}/arden/constants/analysis" includes="**/*" />
95-
<fileset dir="${src.dir}/arden/constants/lexer" includes="**/*" />
96-
<fileset dir="${src.dir}/arden/constants/node" includes="**/*" />
97-
<fileset dir="${src.dir}/arden/constants/parser" includes="**/*" />
98-
</delete>
99-
</target>
100117

101-
<target name="initSableCC" depends="init,createSableCCDirectories">
102-
<uptodate property="arden.compiler.update.necessary" targetfile="${src.dir}/arden.scc">
118+
<uptodate property="sableCC.compiler.update.necessary" targetfile="${src.dir}/arden.scc">
103119
<srcfiles dir="${src.dir}/arden/compiler/analysis" includes="**/*" />
104120
<srcfiles dir="${src.dir}/arden/compiler/lexer" includes="**/*" />
105121
<srcfiles dir="${src.dir}/arden/compiler/node" includes="**/*" />
106122
<srcfiles dir="${src.dir}/arden/compiler/parser" includes="**/*" />
107123
</uptodate>
108-
<uptodate property="arden.constants.update.necessary" targetfile="${src.dir}/ardenConstants.scc">
124+
<uptodate property="sableCC.constants.update.necessary" targetfile="${src.dir}/ardenConstants.scc">
109125
<srcfiles dir="${src.dir}/arden/constants/analysis" includes="**/*" />
110126
<srcfiles dir="${src.dir}/arden/constants/lexer" includes="**/*" />
111127
<srcfiles dir="${src.dir}/arden/constants/node" includes="**/*" />
112128
<srcfiles dir="${src.dir}/arden/constants/parser" includes="**/*" />
113129
</uptodate>
130+
114131
<taskdef name="sablecc" classname="org.sablecc.ant.taskdef.Sablecc">
115132
<classpath>
116-
<pathelement location="${tools.dir}/sablecc.jar"/>
133+
<pathelement location="${tools.dir}/sablecc.jar" />
117134
</classpath>
118135
</taskdef>
119136
</target>
137+
120138

121-
<target name="sableCC.constants" depends="init,initSableCC" if="arden.constants.update.necessary">
122-
<sablecc src="${src.dir}" includes="ardenConstants.scc"
123-
outputdirectory="${src.dir}"></sablecc>
124-
</target>
125-
126-
<target name="sableCC.compiler" depends="init,initSableCC" if="arden.compiler.update.necessary">
127-
<sablecc src="${src.dir}" includes="arden.scc"
128-
outputdirectory="${src.dir}"></sablecc>
129-
</target>
130-
131-
<target name="sableCC" depends="init,initSableCC,sableCC.constants,sableCC.compiler"
132-
description="start sableCC to generate parsers from grammars">
133-
</target>
134-
135-
<target name="compileOnly" depends="init"
136-
description="compile all .java files in ./src">
137-
<mkdir dir="${build.dir}" />
138-
<copy todir="${build.dir}">
139-
<fileset dir="${src.dir}">
140-
<exclude name="**/*.java"/>
141-
<exclude name="**/*.class"/>
142-
</fileset>
143-
</copy>
144-
<javac srcdir="${src.dir}"
145-
destdir="${build.dir}"
146-
debug="${debug}"
147-
classpathref="build.classpath"
148-
optimize="${optimize}"
149-
source="1.6"
150-
includeantruntime="false">
151-
<include name="**/*.java" />
152-
</javac>
139+
<target name="sableCC.compiler" depends="init.sableCC" if="sableCC.compiler.update.necessary">
140+
<sablecc src="${src.dir}" includes="arden.scc" outputdirectory="${src.dir}"/>
153141
</target>
142+
154143

155-
<target name="compile" depends="sableCC,compileOnly"
156-
description="start sableCC and, after that, compile sources">
144+
<target name="sableCC.constants" depends="init.sableCC" if="sableCC.constants.update.necessary">
145+
<sablecc src="${src.dir}" includes="ardenConstants.scc" outputdirectory="${src.dir}"/>
157146
</target>
147+
158148

159-
<target name="jarOnly" depends="init"
160-
description="generate .jar bundle from compiled files (excluding tests) without actually compiling the sources">
149+
<target name="jar" depends="compile" description="Generate .jar bundle">
161150
<mkdir dir="${dist.dir}" />
162-
<manifestclasspath property="manifest.classpath" jarfile="${dist.jar}">
163-
<classpath refid="jar.classpath" />
151+
<manifestclasspath property="manifest.classpath" jarfile="${dist.file}">
152+
<classpath refid="dist.classpath" />
164153
</manifestclasspath>
165-
<jar destfile="${dist.dir}/${dist.jar}">
154+
<jar destfile="${dist.dir}/${dist.file}">
166155
<manifest>
167156
<attribute name="Built-By" value="${user.name}" />
168-
<attribute name="Main-Class" value="${run.entrypoint}" />
157+
<attribute name="Main-Class" value="${mainclass}" />
169158
<!-- <attribute name="Class-Path" value="${manifest.classpath}" /> -->
170159
<attribute name="Implementation-Vendor" value="${user.name}" />
171160
<attribute name="Implementation-Title" value="${name}" />
172161
<attribute name="Implementation-Version" value="${version}" />
173162
</manifest>
163+
<!-- exclude tests -->
174164
<fileset dir="${build.dir}" excludes="${build.dir}/arden/tests" />
175165
<fileset file="${resource.dir}/arden2bytecode.config" />
176-
<zipgroupfileset dir="${lib.dir}" includes="*.jar" />
166+
<zipgroupfileset refid="dist.libs" />
177167
</jar>
178-
<basename property="jar.filename" file="${dist.jar}" />
168+
<basename property="jar.filename" file="${dist.file}" />
169+
170+
<!-- generated cmd and shell script -->
179171
<echo file="${dist.dir}/${name}.cmd" append="false">@echo off
180172
java -jar "%~dp0${jar.filename}" %*
181173
rem pause
@@ -186,28 +178,24 @@
186178
<chmod file="${dist.dir}/${name}" perm="ugo+x" />
187179
</target>
188180

189-
<target name="jar" depends="compile,jarOnly"
190-
description="compile, then package everything into a .jar">
191-
</target>
192181

193-
<target name="distOnly" depends="jarOnly"
194-
description="build distribution .tar and .zip file">
195-
<tar destfile="${dist.dir}/${name} - binary release ${release.stamp}.tar.gz"
196-
compression="gzip">
182+
<target name="dist" depends="jar" description="Build distribution .tar and .zip file">
183+
<tar destfile="${dist.dir}/${name} - binary release ${release.stamp}.tar.gz" compression="gzip">
197184
<tarfileset dir="${dist.dir}">
198-
<include name="${dist.jar}"/>
199-
<include name="${name}.cmd"/>
185+
<include name="${dist.file}" />
186+
<include name="${name}.cmd" />
200187
</tarfileset>
201188
<tarfileset dir="${dist.dir}" filemode="755">
202-
<include name="${name}"/>
189+
<include name="${name}" />
203190
</tarfileset>
204191
<tarfileset dir="${resource.dir}">
205192
<include name="examples/**" />
206193
</tarfileset>
207194
</tar>
195+
208196
<zip destfile="${dist.dir}/${name} - binary release ${release.stamp}.zip">
209197
<zipfileset dir="${dist.dir}">
210-
<include name="${dist.jar}" />
198+
<include name="${dist.file}" />
211199
<include name="${name}.cmd" />
212200
</zipfileset>
213201
<zipfileset dir="${dist.dir}" filemode="755">
@@ -218,36 +206,45 @@
218206
</zipfileset>
219207
</zip>
220208
</target>
209+
221210

222-
<target name="dist" depends="jar,distOnly"
223-
description="build distribution .tar and .zip file">
211+
<target name="run" depends="compile" description="Run the program from the bin directory">
212+
<property name="echoclasspath" refid="run.classpath" />
213+
<echo message="Running ${mainclass} with classpath: ${echoclasspath}" />
214+
<java classname="${mainclass}" classpathref="run.classpath" fork="true">
215+
</java>
224216
</target>
217+
225218

226-
<target name="compileAndJarOnly" depends="compileOnly,jarOnly"
227-
description="compile the sources without starting sableCC, then package a .jar">
219+
<target name="test" depends="test.specification, test.implementation"
220+
description="Generate report of the test suites (implementation and standard compliance)">
221+
<junitreport todir="${test.report.dir}">
222+
<fileset dir="${test.report.dir}">
223+
<include name="TEST-*.xml" />
224+
</fileset>
225+
<report format="noframes" todir="${test.report.dir}" />
226+
</junitreport>
228227
</target>
229228

230-
<target name="runOnly" depends="init"
231-
description="run the program from the bin directory">
232-
<property name="echoclasspath" refid="run.classpath" />
233-
<echo message="Running ${run.entrypoint} with classpath: ${echoclasspath}" />
234-
<java classname="${run.entrypoint}" classpathref="run.classpath" fork="true"></java>
235-
</target>
236229

237-
<target name="run" depends="compile,runOnly"
238-
description="compile, then run the program">
230+
<target name="test.implementation" depends="compile">
231+
<mkdir dir="${test.report.dir}" />
232+
<junit fork="yes" printsummary="withOutAndErr">
233+
<formatter type="xml" />
234+
<classpath refid="test.classpath" />
235+
<test name="${mainclass.test.implementation}" todir="${test.report.dir}" />
236+
</junit>
239237
</target>
240238

241-
<target name="runAndRedirectOutput" depends="compile"
242-
description="run the program and redirect output to 'output.txt'">
243-
<property name="echoclasspath" refid="run.classpath" />
244-
<echo message="Redirecting output to 'output.txt'" />
245-
<echo message="Running ${run.entrypoint} with classpath: ${echoclasspath}" />
246-
<java classname="${run.entrypoint}"
247-
classpathref="run.classpath"
248-
fork="true"
249-
output="output.txt"
250-
logError="true"></java>
239+
240+
<target name="test.specification" depends="compile">
241+
<mkdir dir="${test.report.dir}" />
242+
<junit fork="yes" printsummary="withOutAndErr">
243+
<formatter type="xml" />
244+
<classpath refid="test.classpath" />
245+
<test name="${mainclass.test.specification}" todir="${test.report.dir}" />
246+
</junit>
251247
</target>
248+
252249
</project>
253250

0 commit comments

Comments
 (0)