-
Notifications
You must be signed in to change notification settings - Fork 25
/
common.xml
361 lines (307 loc) · 11.4 KB
/
common.xml
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<project default="build">
<!--Set up some properties that will be used throughout the build script-->
<property name = "term" value="11au"/>
<property name = "course" value="cse331"/>
<property environment="env"/>
<property name = "base" location = '..'/>
<property name = "src" location = '.'/>
<property name = "dest" location = "${base}/bin"/>
<property name = "docdest" location = "${base}/doc"/>
<property name = "build.compiler" value = "javac1.6"/>
<property name="java.api"
value="http://download.oracle.com/javase/6/docs/api/" />
<property name="junit.api"
value="http://www.junit.org/junit/javadoc/4.5/" />
<property name="taglet.path" value="${base}/lib/javadoc331.jar" />
<condition property="extra.classpath" value="">
<not>
<isset property="extra.classpath" />
</not>
</condition>
<path id = "common.classpath">
<pathelement location = "${dest}"/>
<pathelement path="${extra.classpath}" />
<fileset dir="${base}/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="help">
<echo>cse331 ant targets:
build: build the code for this pset
doc: generate api documentation for this pset
test: run both SpecificationTests.java and ImplementationTests.java
as JUnit tests.
gui.test: run SpecificationTests.java and ImplementationTests.java
in the graphical JUnit mode.
gui.test -Duse.test=[classname]: Run a particular test in GUI mode
daikon: runs all tests through Daikon. See
http://pag.csail.mit.edu/daikon/ for more information about Daikon.
validate: ensure all required files are in SVN, and that a clean
SVN checkout compiles and passes all tests. Use only on attu
for best results.
run -Dprogram=[classname]: runs the given java program (use the
full name, like ps0.HelloWorld)
clean: deletes all .class files and generated documentation for this pset.
help: displays this message
</echo>
</target>
<!--Call cleancopy.check for all the required files (listed in
required.properties) -->
<target name="cleancopy" >
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="common.classpath" />
<echo message="Pset directory: ${pset}"/>
<property file="${pset}/required.properties"/>
<foreach list="${required.files}"
trim="true"
target="cleancopy.check"
param="required.file"/>
</target>
<!--Make sure required.file is there. If not, fail.-->
<target name="cleancopy.check">
<available file="${required.file}"
property="file.present"
value="yes"
filepath="${pset}"/>
<if>
<equals arg1="${file.present}" arg2="yes"/>
<then>
<echo message="Found required file ${required.file}"/>
</then>
<else>
<fail message="Could not find required file: ${required.file}"/>
</else>
</if>
</target>
<target name = "validate"
description = "Does a build and test on a clean SVN checkout.">
<echo>Validate checks out a fresh copy of the pset, checks for the
presence of required files, and runs all your tests to make sure
they pass. This target is meant to be called from attu; don't
trust it to make sure everything works unless you are on attu.
Note: the test reports will be generated under the scratch
directory the validate target creates.
</echo>
<property name = "validate.upone" location="${basedir}/.."/>
<property name = "validate.scratch" location="${validate.upone}/scratch"/>
<delete dir="${validate.scratch}" quiet="true"/>
<mkdir dir="${validate.scratch}"/>
<property name = "repo.location" value = "/projects/instr/${term}/${course}/${env.USER}/REPOS"/>
<echo message="${repo.location}"/>
<exec executable="svn"
dir="${validate.scratch}">
<arg line="export file://${repo.location}/cse331"/>
</exec>
<exec executable="ant"
dir="${validate.scratch}/cse331/src/${psetname}"
failonerror="true" >
<arg value="cleancopy"/>
</exec>
<exec executable="ant"
dir="${validate.scratch}/cse331/src/${psetname}"
failonerror="true">
<arg value="test.strict"/>
</exec>
<delete dir="${validate.scratch}" quiet="true"/>
</target>
<target name = "single.build" unless = "also.compile">
<echo message = "This pset is independent; building only this one."/>
<javac srcdir="${pset}"
destdir="${dest}"
debug="true"
fork="${build.fork}"
executable="/usr/local/bin/javac"
excludes=".svn,*/package.html"
includeantruntime="false">
<compilerarg value="-Xlint"/>
<classpath refid = "common.classpath"/>
</javac>
</target>
<target name = "total.build" >
<available file = "/usr/local/bin/javac"
property="build.fork"
value="yes"/>
<echo message = "Building all psets"/>
<javac srcdir="${src}"
destdir="${dest}"
debug="true"
fork="${build.fork}"
executable="/usr/local/bin/javac"
excludes=".svn,*/package.html,${staff.nocomp}"
includeantruntime="false">
<compilerarg value="-Xlint"/>
<classpath refid = "common.classpath"/>
</javac>
</target>
<target name = "multi.build" if = "also.compile">
<echo message = "This pset depends on others; building all associated psets now."/>
<echo message="${psetname}/**/*.java, ${also.compile}"/>
<javac srcdir="${src}"
destdir="${dest}"
fork="${build.fork}"
executable="/usr/local/bin/javac"
debug="true"
includes="${also.compile}, ${psetname}/**/*.java"
excludes=".svn,*/package.html,${staff.nocomp}"
includeantruntime="false">
<compilerarg value="-Xlint"/>
<classpath refid = "common.classpath"/>
</javac>
</target>
<target name = "build" description="Compiles the problem set">
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="common.classpath" />
<available file = "/usr/local/bin/javac"
property="build.fork"
value="yes"/>
<antcall target = "single.build"/>
<antcall target = "multi.build"/>
</target>
<target name = "clean" description="Deletes most of the generated files">
<delete>
<fileset dir = "${pset}"
casesensitive = "yes"
includes="**/daikon*.dtrace.gz **/daikon*.inv.*">
</fileset>
</delete>
<delete>
<fileset dir="${dest}"
casesensitive="yes"
includes="**/*.class">
</fileset>
</delete>
<delete dir = "${docdest}/${psetname}"/>
</target>
<target name = "doc" depends = "build"
description = "Build all the Javadoc API documentation">
<mkdir dir = "${docdest}"/>
<javadoc sourcepath="${src}" destdir="${docdest}" linksource="yes">
<classpath refid = "common.classpath"/>
<link href="${java.api}" />
<link href="${junit.api}" />
<fileset dir="${basedir}"
includes="${psetname}/**/*.java, ${also.compile}, ${staff.doc}"
excludes="${staff.nodoc}" />
<taglet name="javadoc331.RequiresTaglet" path="${taglet.path}" />
<taglet name="javadoc331.EffectsTaglet" path="${taglet.path}" />
<taglet name="javadoc331.ModifiesTaglet" path="${taglet.path}" />
<taglet name="javadoc331.ReturnsTaglet" path="${taglet.path}" />
<taglet name="javadoc331.SpecfieldTaglet" path="${taglet.path}" />
<taglet name="javadoc331.DerivedfieldTaglet" path="${taglet.path}" />
</javadoc>
</target>
<target name = "test.spec" depends = "build">
<mkdir dir = "${pset}/test/reports"/>
<junit printsummary="yes"
dir="${pset}/test/"
fork="on"
failureproperty="test.spec.failed"
forkmode="once">
<classpath refid = "common.classpath"/>
<test name="${psetname}.test.SpecificationTests"
todir="${pset}/test/reports">
<formatter type="plain"/>
</test>
<assertions>
<enable/>
</assertions>
</junit>
</target>
<target name = "test.impl" depends = "build">
<mkdir dir = "${pset}/test/reports"/>
<junit printsummary="yes"
dir="${pset}/test/"
fork="on"
failureproperty="test.impl.failed"
forkmode="once">
<classpath refid = "common.classpath"/>
<test name="${psetname}.test.ImplementationTests"
todir="${pset}/test/reports">
<formatter type="plain"/>
</test>
<assertions>
<enable/>
</assertions>
</junit>
</target>
<target name = "test" depends = "test.impl, test.spec"
description="Run all standard tests on the code">
<echo message="Records of this testing can be found in ${basedir}/${psetname}/test/reports/"/>
</target>
<target name = "test.strict" depends = "test">
<fail if="test.impl.failed"/>
<fail if="test.spec.failed"/>
</target>
<target name = "gui.test.all" depends = "build" unless="use.test">
<java classname="junit.swingui.TestRunner"
fork="Yes"
spawn="Yes"
dir="${pset}/test/"
classpathref="common.classpath">
<arg value="${psetname}.test.ImplementationTests"/>
<arg value="${psetname}.test.SpecificationTests"/>
<assertions>
<enable/>
</assertions>
</java>
</target>
<target name = "gui.test.one" depends = "build" if="use.test">
<java classname="junit.swingui.TestRunner"
fork="Yes"
spawn="Yes"
dir="${pset}/test/"
classpathref="common.classpath">
<arg value="${use.test}"/>
<assertions>
<enable/>
</assertions>
</java>
</target>
<target name="gui.test"
description="Run tests using the JUnit GUI. Optional parameter
use.test selects a particulart test; default runs all">
<antcall target="gui.test.all"/>
<antcall target="gui.test.one"/>
</target>
<!-- runs daikon on the student program. Results are prefixed with
${psetname}. The most interesting file is ${psetname}.inv.txt.
Note these are in the problem set directory rather than tests -->
<target name = "daikon" depends = "build"
description="Runs daikon on the program. Results are prefixed with the pset name">
<java classname="daikon.Chicory"
fork="yes"
spawn="no"
dir="${pset}"
classpathref="common.classpath">
<arg value="--ppt-omit-pattern=junit|^${psetname}.test"/>
<arg value="--dtrace-file=daikon.dtrace.gz"/>
<arg value="--daikon"/>
<arg value="--daikon_args"/>
<arg value="--config_option daikon.PptRelation.enable_object_user=false
--no_text_output --config_option daikon.Daikon.progress_delay=-1"/>
<arg value="junit.textui.TestRunner"/>
<arg value="${psetname}.test.SpecificationTests"/>
</java>
<java classname="daikon.PrintInvariants"
fork="yes"
spawn="no"
classpathref="common.classpath"
dir="${pset}"
output="${pset}/daikon.inv.txt">
<arg value="daikon.inv.gz"/>
</java>
<echo> "Results are in daikon.inv.txt" </echo>
</target>
<target name = "run" depends = "build" if="program"
description="Runs the given program argument">
<java classname="${program}"
fork="Yes"
spawn="Yes"
dir="${pset}"
classpathref="common.classpath"/>
<assertions>
<enable/>
</assertions>
</target>
<target name = "all" depends = "build, test, doc"/>
</project>