1 | <project name="length">
|
---|
2 | <property name="dir" location="lengthtestdir" />
|
---|
3 | <property name="dir.a" location="${dir}/a" />
|
---|
4 | <property name="dir.b" location="${dir}/b" />
|
---|
5 | <property name="zipfile" location="lengthtest.zip" />
|
---|
6 |
|
---|
7 | <target name="init">
|
---|
8 | <mkdir dir="${dir.a}" />
|
---|
9 | <mkdir dir="${dir.b}" />
|
---|
10 | <property name="foo" location="${dir.a}/foo" />
|
---|
11 | <property name="bar" location="${dir.b}/bar" />
|
---|
12 | <echo file="${foo}" message="foo" />
|
---|
13 | <echo file="${bar}" message="bar" />
|
---|
14 | </target>
|
---|
15 |
|
---|
16 | <target name="testEach" depends="init">
|
---|
17 | <length mode="each" property="length.each">
|
---|
18 | <fileset id="fs" dir="${dir}" />
|
---|
19 | </length>
|
---|
20 | <length string="${length.each}" property="length.length.each" />
|
---|
21 | <length string="${foo}${bar}........${line.separator}"
|
---|
22 | property="length.expected" />
|
---|
23 | <fail>
|
---|
24 | <!-- test that both files are represented, and that the
|
---|
25 | output is the expected length; do not assume order. -->
|
---|
26 | <condition>
|
---|
27 | <not>
|
---|
28 | <and>
|
---|
29 | <contains string="${length.each}" substring="${foo} : 3" />
|
---|
30 | <contains string="${length.each}" substring="${bar} : 3" />
|
---|
31 | <equals arg1="${length.length.each}" arg2="${length.expected}" />
|
---|
32 | </and>
|
---|
33 | </not>
|
---|
34 | </condition>
|
---|
35 | </fail>
|
---|
36 | </target>
|
---|
37 |
|
---|
38 | <target name="testEachCondition" depends="init">
|
---|
39 | <length mode="each" property="length.each">
|
---|
40 | <fileset id="fs" dir="${dir}" />
|
---|
41 | </length>
|
---|
42 | <length string="${foo}${bar}........${line.separator}"
|
---|
43 | property="length.expected" />
|
---|
44 | <fail>
|
---|
45 | <!-- test that both files are represented, and that the
|
---|
46 | output is the expected length; do not assume order. -->
|
---|
47 | <condition>
|
---|
48 | <not>
|
---|
49 | <and>
|
---|
50 | <contains string="${length.each}" substring="${foo} : 3" />
|
---|
51 | <contains string="${length.each}" substring="${bar} : 3" />
|
---|
52 | <length string="${length.each}" length="${length.expected}" />
|
---|
53 | </and>
|
---|
54 | </not>
|
---|
55 | </condition>
|
---|
56 | </fail>
|
---|
57 | </target>
|
---|
58 |
|
---|
59 | <target name="testAll" depends="init">
|
---|
60 | <length property="length.all">
|
---|
61 | <fileset id="foo" file="${dir.a}/foo" />
|
---|
62 | <fileset id="bar" file="${dir.b}/bar" />
|
---|
63 | </length>
|
---|
64 | <fail>
|
---|
65 | <condition>
|
---|
66 | <not>
|
---|
67 | <equals arg1="6" arg2="${length.all}" />
|
---|
68 | </not>
|
---|
69 | </condition>
|
---|
70 | </fail>
|
---|
71 | </target>
|
---|
72 |
|
---|
73 | <target name="testAllCondition" depends="init">
|
---|
74 | <fail>
|
---|
75 | <condition>
|
---|
76 | <not>
|
---|
77 | <length length="6">
|
---|
78 | <fileset id="foo" file="${dir.a}/foo" />
|
---|
79 | <fileset id="bar" file="${dir.b}/bar" />
|
---|
80 | </length>
|
---|
81 | </not>
|
---|
82 | </condition>
|
---|
83 | </fail>
|
---|
84 | </target>
|
---|
85 |
|
---|
86 | <target name="testFile" depends="init">
|
---|
87 | <length property="length.foo" file="${dir.a}/foo" />
|
---|
88 | <fail>
|
---|
89 | <condition>
|
---|
90 | <not>
|
---|
91 | <equals arg1="3" arg2="${length.foo}" />
|
---|
92 | </not>
|
---|
93 | </condition>
|
---|
94 | </fail>
|
---|
95 | </target>
|
---|
96 |
|
---|
97 | <target name="testFileCondition" depends="init">
|
---|
98 | <fail>
|
---|
99 | <condition>
|
---|
100 | <not>
|
---|
101 | <length length="3" file="${dir.a}/foo" />
|
---|
102 | </not>
|
---|
103 | </condition>
|
---|
104 | </fail>
|
---|
105 | </target>
|
---|
106 |
|
---|
107 | <target name="testBoth" depends="init">
|
---|
108 | <length property="length.foo" file="${dir.a}/foo">
|
---|
109 | <fileset file="${dir.b}/bar" />
|
---|
110 | </length>
|
---|
111 | <fail>
|
---|
112 | <condition>
|
---|
113 | <not>
|
---|
114 | <equals arg1="6" arg2="${length.foo}" />
|
---|
115 | </not>
|
---|
116 | </condition>
|
---|
117 | </fail>
|
---|
118 | </target>
|
---|
119 |
|
---|
120 | <target name="testBothCondition" depends="init">
|
---|
121 | <fail>
|
---|
122 | <condition>
|
---|
123 | <not>
|
---|
124 | <length length="6" file="${dir.a}/foo">
|
---|
125 | <fileset file="${dir.b}/bar" />
|
---|
126 | </length>
|
---|
127 | </not>
|
---|
128 | </condition>
|
---|
129 | </fail>
|
---|
130 | </target>
|
---|
131 |
|
---|
132 | <target name="testDupes" depends="init">
|
---|
133 | <length property="length.foo" file="${dir.a}/foo">
|
---|
134 | <fileset dir="${dir}" />
|
---|
135 | </length>
|
---|
136 | <fail>
|
---|
137 | <condition>
|
---|
138 | <not>
|
---|
139 | <equals arg1="9" arg2="${length.foo}" />
|
---|
140 | </not>
|
---|
141 | </condition>
|
---|
142 | </fail>
|
---|
143 | </target>
|
---|
144 |
|
---|
145 | <target name="testDupesCondition" depends="init">
|
---|
146 | <fail>
|
---|
147 | <condition>
|
---|
148 | <not>
|
---|
149 | <length length="9" file="${dir.a}/foo">
|
---|
150 | <fileset dir="${dir}" />
|
---|
151 | </length>
|
---|
152 | </not>
|
---|
153 | </condition>
|
---|
154 | </fail>
|
---|
155 | </target>
|
---|
156 |
|
---|
157 | <target name="testString">
|
---|
158 | <length string="foo" property="length.string" />
|
---|
159 | <fail>
|
---|
160 | <condition>
|
---|
161 | <not>
|
---|
162 | <equals arg1="3" arg2="${length.string}" />
|
---|
163 | </not>
|
---|
164 | </condition>
|
---|
165 | </fail>
|
---|
166 | </target>
|
---|
167 |
|
---|
168 | <target name="testStringCondition">
|
---|
169 | <fail>
|
---|
170 | <condition>
|
---|
171 | <not>
|
---|
172 | <length string="foo" length="3" />
|
---|
173 | </not>
|
---|
174 | </condition>
|
---|
175 | </fail>
|
---|
176 | </target>
|
---|
177 |
|
---|
178 | <target name="testTrimString">
|
---|
179 | <length string=" foo " trim="true" property="length.string" />
|
---|
180 | <fail>
|
---|
181 | <condition>
|
---|
182 | <not>
|
---|
183 | <equals arg1="3" arg2="${length.string}" />
|
---|
184 | </not>
|
---|
185 | </condition>
|
---|
186 | </fail>
|
---|
187 | </target>
|
---|
188 |
|
---|
189 | <target name="testTrimStringCondition">
|
---|
190 | <fail>
|
---|
191 | <condition>
|
---|
192 | <not>
|
---|
193 | <length string=" foo " trim="true" length="3" />
|
---|
194 | </not>
|
---|
195 | </condition>
|
---|
196 | </fail>
|
---|
197 | </target>
|
---|
198 |
|
---|
199 | <target name="testNoTrimString">
|
---|
200 | <length string=" foo " property="length.string" />
|
---|
201 | <fail>
|
---|
202 | <condition>
|
---|
203 | <not>
|
---|
204 | <equals arg1="5" arg2="${length.string}" />
|
---|
205 | </not>
|
---|
206 | </condition>
|
---|
207 | </fail>
|
---|
208 | </target>
|
---|
209 |
|
---|
210 | <target name="testNoTrimStringCondition">
|
---|
211 | <fail>
|
---|
212 | <condition>
|
---|
213 | <not>
|
---|
214 | <length string=" foo " length="5" />
|
---|
215 | </not>
|
---|
216 | </condition>
|
---|
217 | </fail>
|
---|
218 | </target>
|
---|
219 |
|
---|
220 | <target name="testTrimFile" description="should fail">
|
---|
221 | <length file="${ant.file}" trim="false" />
|
---|
222 | </target>
|
---|
223 |
|
---|
224 | <target name="testStringFile" description="should fail">
|
---|
225 | <length string="foo" file="${ant.file}" />
|
---|
226 | </target>
|
---|
227 |
|
---|
228 | <target name="testImmutable">
|
---|
229 | <length string="foo" property="length.string" />
|
---|
230 | <length string="foobar" property="length.string" />
|
---|
231 | <fail>
|
---|
232 | <condition>
|
---|
233 | <not>
|
---|
234 | <equals arg1="3" arg2="${length.string}" />
|
---|
235 | </not>
|
---|
236 | </condition>
|
---|
237 | </fail>
|
---|
238 | </target>
|
---|
239 |
|
---|
240 | <target name="zip" depends="init">
|
---|
241 | <zip destfile="${zipfile}">
|
---|
242 | <fileset file="${foo}" />
|
---|
243 | <fileset file="${bar}" />
|
---|
244 | </zip>
|
---|
245 | </target>
|
---|
246 |
|
---|
247 | <target name="testZipFileSet" depends="zip">
|
---|
248 | <length property="length.zipfile1">
|
---|
249 | <zipfileset src="${zipfile}" />
|
---|
250 | </length>
|
---|
251 | <length property="length.zipfile2">
|
---|
252 | <zipfileset src="${zipfile}" includes="bar" />
|
---|
253 | </length>
|
---|
254 | <fail>
|
---|
255 | <condition>
|
---|
256 | <not>
|
---|
257 | <and>
|
---|
258 | <equals arg1="6" arg2="${length.zipfile1}" />
|
---|
259 | <equals arg1="3" arg2="${length.zipfile2}" />
|
---|
260 | </and>
|
---|
261 | </not>
|
---|
262 | </condition>
|
---|
263 | </fail>
|
---|
264 | </target>
|
---|
265 |
|
---|
266 | <target name="testZipFileSetCondition" depends="zip">
|
---|
267 | <fail>
|
---|
268 | <condition>
|
---|
269 | <not>
|
---|
270 | <and>
|
---|
271 | <length length="6">
|
---|
272 | <zipfileset src="${zipfile}" />
|
---|
273 | </length>
|
---|
274 | <length length="3">
|
---|
275 | <zipfileset src="${zipfile}" includes="bar" />
|
---|
276 | </length>
|
---|
277 | </and>
|
---|
278 | </not>
|
---|
279 | </condition>
|
---|
280 | </fail>
|
---|
281 | </target>
|
---|
282 |
|
---|
283 | <target name="cleanup">
|
---|
284 | <delete dir="${dir}" />
|
---|
285 | <delete file="${zipfile}" />
|
---|
286 | </target>
|
---|
287 |
|
---|
288 | </project>
|
---|