-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.xml
256 lines (241 loc) · 15.4 KB
/
build.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
<?xml version="1.0" encoding="utf-8"?>
<project name="testlib4j" default="compile-src" basedir=".">
<property name="build.dir" location="build"/>
<property name="deploy.dir" location="deploy"/>
<property name="example.files.dir" location="example-files"/>
<property name="src.source.dir" location="src"/>
<property name="src.build.dir" location="${build.dir}/src"/>
<property name="tests.source.dir" location="tests"/>
<property name="tests.build.dir" location="${build.dir}/tests"/>
<property name="examples.source.dir" location="examples"/>
<property name="examples.build.dir" location="${build.dir}/examples"/>
<property name="examples.deploy.dir" location="${deploy.dir}/examples"/>
<property name="java.target" value="8"/>
<path id="src.deps">
<pathelement location="${src.build.dir}"/>
</path>
<target name="init">
<tstamp>
<format property="DSTAMP" pattern="yyyy-MM-dd" locale="US"/>
</tstamp>
<mkdir dir="${build.dir}"/>
<mkdir dir="${deploy.dir}"/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${deploy.dir}"/>
</target>
<target name="compile-src" depends="init">
<mkdir dir="${src.build.dir}"/>
<javac
srcdir="${src.source.dir}"
destdir="${src.build.dir}"
encoding="utf-8"
source="${java.target}"
target="${java.target}"
includeantruntime="false"
>
<compilerarg value="-Xlint:unchecked"/>
</javac>
<jar destfile="${deploy.dir}/testlib4j.jar" basedir="${src.build.dir}"/>
</target>
<macrodef name="compile-example-checker">
<attribute name="class"/>
<attribute name="name"/>
<sequential>
<mkdir dir="${examples.build.dir}/@{name}"/>
<javac
srcdir="${examples.source.dir}"
destdir="${examples.build.dir}/@{name}"
encoding="utf-8"
source="${java.target}"
target="${java.target}"
includeantruntime="false"
>
<include name="@{class}.java"/>
<classpath refid="src.deps"/>
</javac>
<jar destfile="${examples.deploy.dir}/@{name}.jar" basedir="${examples.build.dir}/@{name}">
<manifest>
<attribute name="Checker-Class" value="@{class}"/>
</manifest>
</jar>
</sequential>
</macrodef>
<macrodef name="test-example-checker">
<attribute name="description"/>
<attribute name="name"/>
<attribute name="input"/>
<attribute name="output"/>
<attribute name="answer"/>
<attribute name="expected-exit-code"/>
<sequential>
<echo level="info" message="Running checker @{name} on test: @{description}"/>
<java fork="false" failonerror="true" classname="ru.ifmo.testlib.CheckerFramework">
<classpath>
<pathelement location="${deploy.dir}/testlib4j.jar"/>
<pathelement location="${examples.deploy.dir}/@{name}.jar"/>
</classpath>
<sysproperty key="testlib.expected.exitcode" value="@{expected-exit-code}"/>
<arg value="${example.files.dir}/@{input}"/>
<arg value="${example.files.dir}/@{output}"/>
<arg value="${example.files.dir}/@{answer}"/>
</java>
</sequential>
</macrodef>
<target name="compile-examples" depends="compile-src">
<compile-example-checker class="CompareInteger" name="icmp"/>
<compile-example-checker class="CompareIntegers" name="ncmp"/>
<compile-example-checker class="YesNo" name="yesno"/>
</target>
<target name="compile-checker-unittests" depends="compile-src">
<compile-example-checker class="test/ThrowOkTest" name="test/throw-ok"/>
</target>
<target name="test-example-icmp" depends="compile-examples">
<test-example-checker description="Two equal files with single numbers"
name="icmp" expected-exit-code="0"
input="just-text.txt" output="number-42.txt" answer="number-42.txt"/>
<test-example-checker description="Two different files with single numbers"
name="icmp" expected-exit-code="1"
input="just-text.txt" output="number-32.txt" answer="number-42.txt"/>
<test-example-checker description="Only contestant's output is not-a-number"
name="icmp" expected-exit-code="2"
input="just-text.txt" output="yes.txt" answer="number-32.txt"/>
<test-example-checker description="Both files are not-a-numbers and equal"
name="icmp" expected-exit-code="3"
input="just-text.txt" output="no.txt" answer="no.txt"/>
<test-example-checker description="Both files are not-a-numbers and different"
name="icmp" expected-exit-code="3"
input="just-text.txt" output="yes.txt" answer="no.txt"/>
<test-example-checker description="Only jury's output is not-a-number"
name="icmp" expected-exit-code="3"
input="just-text.txt" output="number-32.txt" answer="no.txt"/>
<test-example-checker description="Contestant's file does not exist"
name="icmp" expected-exit-code="2"
input="just-text.txt" output="does-not-exist" answer="number-32.txt"/>
<test-example-checker description="Jury's file does not exist"
name="icmp" expected-exit-code="3"
input="just-text.txt" output="number-32.txt" answer="does-not-exist"/>
<test-example-checker description="Contestant's file is empty"
name="icmp" expected-exit-code="2"
input="just-text.txt" output="empty.txt" answer="number-32.txt"/>
<test-example-checker description="Jury's file is empty"
name="icmp" expected-exit-code="3"
input="just-text.txt" output="number-32.txt" answer="empty.txt"/>
<test-example-checker description="Jury's file does not exist and contestant's file is not-a-number"
name="icmp" expected-exit-code="3"
input="just-text.txt" output="yes.txt" answer="does-not-exist"/>
<test-example-checker description="Jury's file is empty and contestant's file is not-a-number"
name="icmp" expected-exit-code="3"
input="just-text.txt" output="yes.txt" answer="empty.txt"/>
<test-example-checker description="Contestant's file matches but has an extra output"
name="icmp" expected-exit-code="2"
input="just-text.txt" output="numbers-two-42s.txt" answer="number-42.txt"/>
<test-example-checker description="Contestant's file does not match and has an extra output"
name="icmp" expected-exit-code="1"
input="just-text.txt" output="numbers-two-42s.txt" answer="number-32.txt"/>
<test-example-checker description="Jury's file has an extra output"
name="icmp" expected-exit-code="0"
input="just-text.txt" output="number-42.txt" answer="numbers-two-42s.txt"/>
</target>
<target name="test-example-yesno" depends="compile-examples">
<test-example-checker description="Two equal files with YES"
name="yesno" expected-exit-code="0"
input="just-text.txt" output="yes.txt" answer="yes.txt"/>
<test-example-checker description="Two equal files with NO"
name="yesno" expected-exit-code="0"
input="just-text.txt" output="no.txt" answer="no.txt"/>
<test-example-checker description="Expected YES, found NO"
name="yesno" expected-exit-code="1"
input="just-text.txt" output="no.txt" answer="yes.txt"/>
<test-example-checker description="Expected NO, found YES"
name="yesno" expected-exit-code="1"
input="just-text.txt" output="yes.txt" answer="no.txt"/>
<test-example-checker description="Contestant's file is neither YES nor NO"
name="yesno" expected-exit-code="2"
input="just-text.txt" output="number-42.txt" answer="no.txt"/>
<test-example-checker description="Jury's file is neither YES nor NO"
name="yesno" expected-exit-code="3"
input="just-text.txt" output="yes.txt" answer="number-42.txt"/>
<test-example-checker description="Contestant's file does not exist"
name="yesno" expected-exit-code="2"
input="just-text.txt" output="does-not-exist" answer="no.txt"/>
<test-example-checker description="Jury's file does not exist"
name="yesno" expected-exit-code="3"
input="just-text.txt" output="yes.txt" answer="does-not-exist"/>
<test-example-checker description="Contestant's file is empty"
name="yesno" expected-exit-code="2"
input="just-text.txt" output="empty.txt" answer="no.txt"/>
<test-example-checker description="Jury's file is empty"
name="yesno" expected-exit-code="3"
input="just-text.txt" output="yes.txt" answer="empty.txt"/>
<test-example-checker description="Contestant's file matches but has an extra output"
name="yesno" expected-exit-code="2"
input="just-text.txt" output="just-text.txt" answer="yes.txt"/>
<test-example-checker description="Contestant's file does not match and has an extra output"
name="yesno" expected-exit-code="1"
input="just-text.txt" output="just-text.txt" answer="no.txt"/>
<test-example-checker description="Jury's file has an extra output"
name="yesno" expected-exit-code="0"
input="just-text.txt" output="yes.txt" answer="just-text.txt"/>
</target>
<target name="test-example-ncmp" depends="compile-examples">
<test-example-checker description="Two equal files with single numbers"
name="ncmp" expected-exit-code="0"
input="just-text.txt" output="number-42.txt" answer="number-42.txt"/>
<test-example-checker description="Two different files with single numbers"
name="ncmp" expected-exit-code="1"
input="just-text.txt" output="number-32.txt" answer="number-42.txt"/>
<test-example-checker description="Only contestant's output is not-a-number"
name="ncmp" expected-exit-code="2"
input="just-text.txt" output="yes.txt" answer="number-32.txt"/>
<test-example-checker description="Both files are not-a-numbers and equal"
name="ncmp" expected-exit-code="3"
input="just-text.txt" output="no.txt" answer="no.txt"/>
<test-example-checker description="Both files are not-a-numbers and different"
name="ncmp" expected-exit-code="3"
input="just-text.txt" output="yes.txt" answer="no.txt"/>
<test-example-checker description="Only jury's output is not-a-number"
name="ncmp" expected-exit-code="3"
input="just-text.txt" output="number-32.txt" answer="no.txt"/>
<test-example-checker description="Contestant's file does not exist"
name="ncmp" expected-exit-code="2"
input="just-text.txt" output="does-not-exist" answer="number-32.txt"/>
<test-example-checker description="Jury's file does not exist"
name="ncmp" expected-exit-code="3"
input="just-text.txt" output="number-32.txt" answer="does-not-exist"/>
<test-example-checker description="Contestant's file is empty"
name="ncmp" expected-exit-code="2"
input="just-text.txt" output="empty.txt" answer="number-32.txt"/>
<test-example-checker description="Jury's file is empty"
name="ncmp" expected-exit-code="2"
input="just-text.txt" output="number-32.txt" answer="empty.txt"/>
<test-example-checker description="Jury's file does not exist and contestant's file is not-a-number"
name="ncmp" expected-exit-code="3"
input="just-text.txt" output="yes.txt" answer="does-not-exist"/>
<test-example-checker description="Jury's file is empty and contestant's file is not-a-number"
name="ncmp" expected-exit-code="2"
input="just-text.txt" output="yes.txt" answer="empty.txt"/>
<test-example-checker description="Contestant's file matches but has an extra output"
name="ncmp" expected-exit-code="2"
input="just-text.txt" output="numbers-two-42s.txt" answer="number-42.txt"/>
<test-example-checker description="Contestant's file does not match and has an extra output"
name="ncmp" expected-exit-code="1"
input="just-text.txt" output="numbers-two-42s.txt" answer="number-32.txt"/>
<test-example-checker description="Jury's file has an extra output"
name="ncmp" expected-exit-code="2"
input="just-text.txt" output="number-42.txt" answer="numbers-two-42s.txt"/>
<test-example-checker description="Two equal files with multiple numbers"
name="ncmp" expected-exit-code="0"
input="just-text.txt" output="numbers-two-42s.txt" answer="numbers-two-42s.txt"/>
<test-example-checker description="Two files with same numbers but different whitespace"
name="ncmp" expected-exit-code="0"
input="just-text.txt" output="numbers-two-42s.txt" answer="numbers-two-42s-1line.txt"/>
</target>
<target name="run-checker-unittests" depends="compile-checker-unittests">
<test-example-checker description="Outcome.Type.OK is thrown and there is extra output"
name="test/throw-ok" expected-exit-code="2"
input="just-text.txt" output="numbers-two-42s.txt" answer="number-42.txt"/>
</target>
<target name="test" depends="run-checker-unittests, test-example-icmp, test-example-yesno, test-example-ncmp"/>
</project>