aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/exec/apply-test.xml
blob: 1b5a661a3bea7ce0f5151c594b8d4392dee40651 (plain)
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<project name="apply-test" default="antunit"
         xmlns:au="antlib:org.apache.ant.antunit">
  <import file="../../antunit-base.xml" />

  <property environment="env" />
  <!-- UNIX -->
  <available file="sh" filepath="${env.PATH}" property="sh.executable" />
  <!-- CYGWIN -->
  <available file="sh.exe" filepath="${env.PATH}" property="sh.exe.executable" />
  <condition property="test.can.run">
    <or>
      <isset property="sh.executable" />
      <isset property="sh.exe.executable" />
    </or>
  </condition>
  <!-- UNIX -->
  <available file="sed" filepath="${env.PATH}" property="sed.executable" />
  <!-- CYGWIN -->
  <available file="sed.exe" filepath="${env.PATH}" property="sed.exe.executable" />
  <condition property="sed.can.run">
    <or>
      <isset property="sed.executable" />
      <isset property="sed.exe.executable" />
    </or>
  </condition>
  <!-- UNIX -->
  <available file="echo" filepath="${env.PATH}" property="echo.executable" />
  <!-- CYGWIN -->
  <available file="echo.exe" filepath="${env.PATH}" property="echo.exe.executable" />
  <condition property="echo.can.run">
    <or>
      <isset property="echo.executable" />
      <isset property="echo.exe.executable" />
    </or>
  </condition>

  <!-- UNIX -->
  <available file="ls" filepath="${env.PATH}" property="ls.executable" />
  <!-- CYGWIN -->
  <available file="ls.exe" filepath="${env.PATH}" property="ls.exe.executable" />
  <!-- piggyback the name of the executable here -->
  <condition property="ls.can.run" value="ls">
    <isset property="ls.executable" />
  </condition>
  <condition property="ls.can.run" value="ls.exe">
    <isset property="ls.exe.executable" />
  </condition>

  <property name="eol" value="${line.separator}" />

  <macrodef name="rcat">
    <attribute name="refid" />
    <sequential>
      <echo>@@{refid}=@{refid}</echo>
      <concat><resources refid="@{refid}" /></concat>
    </sequential>
  </macrodef>

  <macrodef name="assertEmptyFile">
    <attribute name="file" />
    <sequential>
      <au:assertTrue>
        <and>
          <available file="@{file}" type="file" />
          <length length="0" file="@{file}" />
        </and>
      </au:assertTrue>
    </sequential>
  </macrodef>

  <target name="xyz">
    <mkdir dir="${input}"/>
    <mkdir dir="${output}"/>
    <echo file="${input}/x">s/x/blah/g${eol}</echo>
    <echo file="${input}/y">s/y/blah/g${eol}</echo>
    <echo file="${input}/z">s/z/blah/g${eol}</echo>
    <fileset id="xyz" dir="${input}" includes="x,y,z" />
    <filelist id="xyzlist" dir="${input}" files="x,y,z" />
    <property name="x" location="${input}/x" />
    <property name="y" location="${input}/y" />
    <property name="z" location="${input}/z" />
  </target>

  <target name="testNoRedirect" depends="xyz" if="test.can.run">
    <apply executable="sh">
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
    </apply>

    <au:assertLogContains text="${x} out" />
    <au:assertLogContains text="${y} out" />
    <au:assertLogContains text="${z} out" />
    <au:assertLogContains text="${x} err" />
    <au:assertLogContains text="${y} err" />
    <au:assertLogContains text="${z} err" />

    <!--

    The original junit test also verified that x out happened before
    y out, and y out happened before z out; likewise with err output.
    I added the antunit:logcontent resource hoping that would help,
    but I think we need a way to filter (copy) resources first.
    THAT necessitates the string-to-resource coding we are currently
    discussing on the dev list IMO.  MJB, 9/22/2006

    -->

  </target>

  <target name="testRedirect1" depends="xyz" if="test.can.run">
    <apply executable="sh" output="${output}/redirect.out" append="true">
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
    </apply>

    <au:assertTrue>
      <resourcecount count="1">
        <restrict id="results">
          <file file="${output}/redirect.out" />
          <and xmlns="antlib:org.apache.tools.ant.types.resources.selectors">
            <contains text="${x} out" />
            <contains text="${y} out" />
            <contains text="${z} out" />
            <contains text="${x} err" />
            <contains text="${y} err" />
            <contains text="${z} err" />
          </and>
        </restrict>
      </resourcecount>
    </au:assertTrue>

  </target>

  <target name="testRedirect2" depends="xyz" if="test.can.run">
    <apply executable="sh" output="${output}/redirect.out"
           error="${output}/redirect.err" append="true">
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
    </apply>

    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <string value="${x} out${eol}${y} out${eol}${z} out" />
          <file file="${output}/redirect.out" />
        </resourcesmatch>
        <resourcesmatch astext="true">
          <string value="${x} err${eol}${y} err${eol}${z} err" />
          <file file="${output}/redirect.err" />
        </resourcesmatch>
      </and>
    </au:assertTrue>
  </target>

  <target name="testRedirect3" depends="xyz" if="test.can.run">
    <apply executable="sh" logerror="true" append="true"
           output="${output}/redirect.out" outputproperty="redirect3.out">
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
    </apply>

    <au:assertTrue>
      <resourcesmatch astext="true">
        <string value="${x} out${eol}${y} out${eol}${z} out" />
        <file file="${output}/redirect.out" />
        <propertyresource name="redirect3.out" />
      </resourcesmatch>
    </au:assertTrue>

    <au:assertLogContains text="${x} err" />
    <au:assertLogContains text="${y} err" />
    <au:assertLogContains text="${z} err" />
  </target>

  <target name="testRedirect4" depends="xyz" if="test.can.run">
    <apply executable="sh" append="true"
           error="${output}/redirect.err" errorproperty="redirect4.err"
           output="${output}/redirect.out" outputproperty="redirect4.out">
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
    </apply>

    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <string value="${x} out${eol}${y} out${eol}${z} out" />
          <file file="${output}/redirect.out" />
          <propertyresource name="redirect4.out" />
        </resourcesmatch>
        <resourcesmatch astext="true">
          <string value="${x} err${eol}${y} err${eol}${z} err" />
          <file file="${output}/redirect.err" />
          <propertyresource name="redirect4.err" />
        </resourcesmatch>
      </and>
    </au:assertTrue>
  </target>

  <target name="testRedirect5" depends="xyz" if="sed.can.run">
    <apply executable="sed" inputstring="x y z${eol}" append="true"
           error="${output}/redirect.err" errorproperty="redirect5.err"
           output="${output}/redirect.out" outputproperty="redirect5.out">
      <arg value="-f" />
      <fileset refid="xyz" />
    </apply>

    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <propertyresource name="redirect5.out" />
          <string value="blah y z${eol}x blah z${eol}x y blah" />
          <file file="${output}/redirect.out" />
        </resourcesmatch>
        <equals arg1="${redirect5.err}" arg2="" />
      </and>
    </au:assertTrue>
    <assertEmptyFile file="${output}/redirect.err" />
  </target>

  <target name="testRedirect6" depends="xyz" if="sed.can.run">
    <echo file="${input}/redirect.in">x y z${eol}</echo>
    <apply executable="sed" input="${input}/redirect.in" append="true"
           error="${output}/redirect.err" errorproperty="redirect6.err"
           output="${output}/redirect.out" outputproperty="redirect6.out">
      <arg value="-f" />
      <filelist refid="xyzlist" />
    </apply>

    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <propertyresource name="redirect6.out" />
          <string value="blah y z${eol}x blah z${eol}x y blah" />
          <file file="${output}/redirect.out" />
        </resourcesmatch>
        <equals arg1="${redirect6.err}" arg2="" />
        <length length="0"><file file="${output}/redirect.err" /></length>
      </and>
    </au:assertTrue>
  </target>

  <target name="testRedirect7" depends="xyz" if="sed.can.run">
    <apply executable="sed" inputstring="x y z${eol}"
           error="${output}/redirect.err" output="${output}/redirect.out"
           outputproperty="redirect7.out">
      <arg value="-f" />
      <fileset refid="xyz" />
    </apply>

    <au:assertTrue>
      <and>
        <equals arg1="${redirect7.out}" arg2="blah y z" />
        <resourcesmatch astext="true">
          <file file="${output}/redirect.out" />
          <string value="x y blah" />
        </resourcesmatch>
      </and>
    </au:assertTrue>
    <assertEmptyFile file="${output}/redirect.err" />
  </target>

  <target name="testRedirector1" description="fail"
          depends="xyz" if="test.can.run">
    <au:expectfailure
            expectedmessage="cannot have &gt; 1 nested &lt;redirector&gt;s">
      <apply executable="sh">
        <arg value="parrot.sh" />
        <fileset refid="xyz" />
        <redirector output="${output}/redirector.out" />
        <redirector output="${output}/whocares" />
      </apply>
    </au:expectfailure>
  </target>

  <target name="testRedirector2" depends="xyz" if="test.can.run">
    <apply executable="sh">
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
      <redirector output="${output}/redirector.out" append="true" />
    </apply>
    <au:assertTrue>
      <resourcecount count="1">
        <restrict id="results">
          <file file="${output}/redirector.out" />
          <and xmlns="antlib:org.apache.tools.ant.types.resources.selectors">
            <contains text="${x} out" />
            <contains text="${y} out" />
            <contains text="${z} out" />
            <contains text="${x} err" />
            <contains text="${y} err" />
            <contains text="${z} err" />
          </and>
        </restrict>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testRedirector3" depends="xyz" if="test.can.run">
    <apply executable="sh">
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
      <redirector append="true"
                  output="${output}/redirector.out"
                  error="${output}/redirector.err" />
    </apply>
    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <string value="${x} out${eol}${y} out${eol}${z} out" />
          <file file="${output}/redirector.out" />
        </resourcesmatch>
        <resourcesmatch astext="true">
          <string value="${x} err${eol}${y} err${eol}${z} err" />
          <file file="${output}/redirector.err" />
        </resourcesmatch>
      </and>
    </au:assertTrue>
  </target>

  <target name="testRedirector4" depends="xyz" if="test.can.run">
    <apply executable="sh">
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
      <redirector output="${output}/redirector.out" logerror="true"
                  append="true" outputproperty="redirector4.out" />
    </apply>

    <au:assertTrue>
      <resourcesmatch astext="true">
        <string value="${x} out${eol}${y} out${eol}${z} out" />
        <file file="${output}/redirector.out" />
        <propertyresource name="redirector4.out" />
      </resourcesmatch>
    </au:assertTrue>

    <au:assertLogContains text="${x} err" />
    <au:assertLogContains text="${y} err" />
    <au:assertLogContains text="${z} err" />
  </target>

  <target name="testRedirector5" depends="xyz" if="test.can.run">
    <apply executable="sh">
      <redirector error="${output}/redirector.err"
                  errorproperty="redirector5.err"
                  output="${output}/redirector.out"
                  outputproperty="redirector5.out"
                  append="true" />
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
    </apply>
    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <string value="${x} out${eol}${y} out${eol}${z} out" />
          <file file="${output}/redirector.out" />
          <propertyresource name="redirector5.out" />
        </resourcesmatch>
        <resourcesmatch astext="true">
          <string value="${x} err${eol}${y} err${eol}${z} err" />
          <file file="${output}/redirector.err" />
          <propertyresource name="redirector5.err" />
        </resourcesmatch>
      </and>
    </au:assertTrue>
  </target>

  <target name="testRedirector6" depends="xyz" if="test.can.run">
    <apply executable="sh">
      <redirector append="true" outputproperty="redirector6.out"
                  errorproperty="redirector6.err">
        <outputmapper type="merge" to="${output}/redirector.out" />
        <errormapper type="merge" to="${output}/redirector.err" />
      </redirector>
      <arg value="parrot.sh" />
      <filelist refid="xyzlist" />
    </apply>

    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <string value="${x} out${eol}${y} out${eol}${z} out" />
          <file file="${output}/redirector.out" />
          <propertyresource name="redirector6.out" />
        </resourcesmatch>
        <resourcesmatch astext="true">
          <string value="${x} err${eol}${y} err${eol}${z} err" />
          <file file="${output}/redirector.err" />
          <propertyresource name="redirector6.err" />
        </resourcesmatch>
      </and>
    </au:assertTrue>
  </target>

  <target name="testRedirector7" depends="xyz" if="test.can.run">
    <apply executable="sh">
      <redirector append="true" outputproperty="redirector7.out"
                  errorproperty="redirector7.err">
        <outputmapper type="merge" to="${output}/redirector.out" />
        <errormapper type="merge" to="${output}/redirector.err" />
        <errorfilterchain>
          <replacestring from="err" to="ERROR!!!" />
        </errorfilterchain>
      </redirector>
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
    </apply>

    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <string value="${x} out${eol}${y} out${eol}${z} out" />
          <file file="${output}/redirector.out" />
          <propertyresource name="redirector7.out" />
        </resourcesmatch>
        <resourcesmatch astext="true">
          <string value="${x} ERROR!!!${eol}${y} ERROR!!!${eol}${z} ERROR!!!" />
          <file file="${output}/redirector.err" />
          <propertyresource name="redirector7.err" />
        </resourcesmatch>
      </and>
    </au:assertTrue>
  </target>

  <target name="testRedirector8" depends="xyz" if="sed.can.run">
    <echo file="${input}/redirector.in">x y z${eol}</echo>
    <apply executable="sed">
      <redirector append="true" outputproperty="redirector8.out"
                  errorproperty="redirector8.err">
        <inputmapper type="merge" to="${input}/redirector.in" />
        <outputmapper type="merge" to="${output}/redirector.out" />
        <errormapper type="merge" to="${output}/redirector.err" />
      </redirector>
      <arg value="-f" />
      <fileset refid="xyz" />
    </apply>

    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <propertyresource name="redirector8.out" />
          <string value="blah y z${eol}x blah z${eol}x y blah" />
          <file file="${output}/redirector.out" />
        </resourcesmatch>
        <equals arg1="${redirector8.err}" arg2="" />
      </and>
    </au:assertTrue>
    <assertEmptyFile file="${output}/redirector.err" />
  </target>

  <macrodef name="valRor9-12">
    <attribute name="n" />
    <sequential>
      <au:assertTrue>
        <and>
          <equals arg1="" arg2="${redirector@{n}.err}" />
          <resourcesmatch astext="true">
           <string value="blah after y after z${eol}x after blah after z${eol}x after y after blah" />
           <propertyresource name="redirector@{n}.out" />
           <file file="${output}/redirector.out" />
          </resourcesmatch>
        </and>
      </au:assertTrue>
      <assertEmptyFile file="${output}/redirector.err" />
    </sequential>
  </macrodef>

  <target name="testRedirector9" depends="xyz" if="sed.can.run">
    <echo file="${input}/redirector.in">x before y before z${eol}</echo>
    <apply executable="sed">
      <redirector outputproperty="redirector9.out"
                  errorproperty="redirector9.err" append="true">
        <inputfilterchain>
          <replacestring from="before" to="after" />
        </inputfilterchain>
        <inputmapper type="merge" to="${input}/redirector.in" />
        <outputmapper type="merge" to="${output}/redirector.out" />
        <errormapper type="merge" to="${output}/redirector.err" />
      </redirector>
      <arg value="-f" />
      <fileset refid="xyz" />
    </apply>

    <valRor9-12 n="9" />
  </target>

  <target name="testRedirector10" depends="xyz" if="sed.can.run">
    <echo file="${input}/redirector.in">x before y before z${eol}</echo>
    <apply executable="sed">
      <redirector outputproperty="redirector10.out"
                  errorproperty="redirector10.err" append="true">
        <outputfilterchain>
          <replacestring from="before" to="after" />
        </outputfilterchain>
        <outputmapper type="merge" to="${output}/redirector.out" />
        <errormapper type="merge" to="${output}/redirector.err" />
      </redirector>
      <arg value="-f" />
      <srcfile />
      <arg value="${input}/redirector.in" />
      <filelist refid="xyzlist" />
    </apply>

    <valRor9-12 n="10" />
  </target>

  <target name="testRedirector11" depends="xyz" if="sed.can.run">
    <apply executable="sed">
      <redirector outputproperty="redirector11.out"
                  errorproperty="redirector11.err"
                  inputstring="x before y before z${eol}"
                  append="true">
        <inputfilterchain>
          <replacestring from="before" to="after" />
        </inputfilterchain>
        <outputmapper type="merge" to="${output}/redirector.out" />
        <errormapper type="merge" to="${output}/redirector.err" />
      </redirector>
      <arg value="-f" />
      <fileset refid="xyz" />
    </apply>

    <valRor9-12 n="11" />
  </target>

  <target name="testRedirector12" depends="xyz" if="sed.can.run">
    <echo file="${input}/redirector.in">x before y before z${eol}</echo>
    <apply executable="sed" output="${output}/redirector.out"
           error="${output}/redirector.err">
      <redirector outputproperty="redirector12.out"
                  errorproperty="redirector12.err" append="true">
        <outputfilterchain>
          <replacestring from="before" to="after" />
        </outputfilterchain>
        <outputmapper type="glob" from="nomatch" to="nomatchout" />
        <errormapper type="glob" from="nomatch" to="nomatcherr" />
      </redirector>
      <arg value="-f" />
      <srcfile />
      <arg value="${input}/redirector.in" />
      <filelist refid="xyzlist" />
    </apply>

    <valRor9-12 n="12" />
  </target>

  <target name="testRedirector13" depends="xyz" if="test.can.run">
    <apply executable="sh">
      <redirector>
        <outputfilterchain>
          <replacestring from="out" to="OUTPUT???" />
        </outputfilterchain>
        <errorfilterchain>
          <replacestring from="err" to="ERROR!!!" />
        </errorfilterchain>
      </redirector>
      <arg value="parrot.sh" />
      <fileset refid="xyz" />
    </apply>

    <au:assertLogContains text="${x} OUTPUT???" />
    <au:assertLogContains text="${y} OUTPUT???" />
    <au:assertLogContains text="${z} OUTPUT???" />
    <au:assertLogContains text="${x} ERROR!!!" />
    <au:assertLogContains text="${y} ERROR!!!" />
    <au:assertLogContains text="${z} ERROR!!!" />
  </target>

  <target name="testRedirector14" depends="xyz" if="sed.can.run">
    <echo file="${input}/redirector.in">z before y before x${eol}</echo>
    <apply executable="sed">
      <redirector append="true"
                  inputstring="x before y before z${eol}">
        <outputfilterchain>
          <replacestring from="before" to="after" />
        </outputfilterchain>
        <inputmapper type="glob" from="x" to="${input}/redirector.in" />
        <outputmapper type="glob" from="y" to="${output}/redirector.out" />
        <errormapper type="glob" from="z" to="${output}/redirector.err" />
      </redirector>
      <arg value="-f" />
      <fileset refid="xyz" />
    </apply>

    <assertEmptyFile file="${output}/redirector.err" />

    <au:assertTrue>
      <and>
        <resourcesmatch astext="true">
          <string value="x after blah after z" />
          <file file="${output}/redirector.out" />
        </resourcesmatch>
      </and>
    </au:assertTrue>
    <au:assertLogContains text="z after y after blahx after y after blah"/>
  </target>

  <target name="pad">
    <condition property="pad" value="">
      <or>
        <not>
          <os family="dos" />
        </not>
        <not>
          <or>
            <equals arg1="${ant.java.version}" arg2="1.1" />
            <equals arg1="${ant.java.version}" arg2="1.2" />
          </or>
        </not>
      </or>
    </condition>

    <condition property="pad" value=" ">
      <and>
        <os family="dos" />
        <or>
          <equals arg1="${ant.java.version}" arg2="1.2" />
        </or>
      </and>
    </condition>

  </target>

  <target name="testIgnoreMissing" depends="xyz,pad" if="echo.can.run">
    <filelist id="xylist" dir="${input}" files="x,y" />
    <delete file="${input}/z" />

    <pathconvert property="xy" pathsep="${pad}${eol}" refid="xylist" />

    <pathconvert property="xyz" pathsep="${pad}${eol}" refid="xyzlist" />

    <apply executable="echo" ignoremissing="true"
           outputproperty="ignoretrue" append="true">
      <filelist refid="xyzlist" />
    </apply>

    <apply executable="echo" ignoremissing="false"
           outputproperty="ignorefalse" append="true">
      <filelist refid="xyzlist" />
    </apply>

    <au:assertTrue>
      <and>
        <equals arg1="${xy}${pad}" arg2="${ignoretrue}" />
        <equals arg1="${xyz}${pad}" arg2="${ignorefalse}" />
      </and>
    </au:assertTrue>
  </target>

  <target name="testForce" depends="xyz,pad" if="echo.can.run">
    <presetdef name="ekko">
      <apply executable="echo" append="true" dest="${input}">
        <filelist refid="xyzlist" />
        <mapper type="identity" />
      </apply>
    </presetdef>

    <pathconvert property="xyz" pathsep="${pad}${eol}" refid="xyzlist" />

    <ekko outputproperty="foo" />
    <ekko outputproperty="bar" force="true" />

    <au:assertTrue>
      <and>
        <equals arg1="${foo}" arg2="" />
        <equals arg1="${bar}" arg2="${xyz}" />
      </and>
    </au:assertTrue>
  </target>

  <target name="testNoDest" depends="xyz" if="echo.can.run">
    <presetdef name="ekko">
      <apply executable="echo" addsourcefile="false" force="true">
        <filelist dir="${input}" files="x" />
        <globmapper from="*" to="${input}/*" />
        <targetfile />
      </apply>
    </presetdef>
    <ekko outputproperty="dest" dest="${input}" />
    <ekko outputproperty="nodest" />

    <au:assertFileDoesntExist file="${dest}" />
    <au:assertFileExists file="${nodest}" />
  </target>

  <target name="testLsPath" if="ls.can.run" depends="xyz">
    <apply executable="ls" parallel="false" outputproperty="lsPathOut"
           force="true" dest="${input}" append="true" type="both">
      <path path="${env.PATH}" />
      <identitymapper/>
    </apply>
    <au:assertTrue>
      <resourcecount count="1">
        <restrict>
          <propertyresource name="lsPathOut" />
          <containsregexp expression="^${ls.can.run}$"
              xmlns="antlib:org.apache.tools.ant.types.resources.selectors" />
        </restrict>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testLsPathParallel" if="ls.can.run" depends="xyz">
    <apply executable="ls" parallel="true" outputproperty="lsPathParallelOut"
           force="true" dest="${input}" append="true" type="both">
      <path path="${env.PATH}" />
      <identitymapper/>
    </apply>
    <au:assertTrue>
      <resourcecount count="1">
        <restrict>
          <propertyresource name="lsPathParallelOut" />
          <containsregexp expression="^${ls.can.run}$"
              xmlns="antlib:org.apache.tools.ant.types.resources.selectors" />
        </restrict>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testSrcfilePrefix" if="test.can.run" depends="xyz">
    <apply executable="sh" force="true">
      <arg value="parrot.sh" />
      <srcfile prefix="-Dfoo="/>
      <fileset refid="xyz" />
    </apply>
    <au:assertLogContains text="-Dfoo=${x} out" />
    <au:assertLogContains text="-Dfoo=${y} out" />
    <au:assertLogContains text="-Dfoo=${z} out" />
  </target>

  <target name="testTargetfileSuffix" if="test.can.run" depends="xyz">
    <apply executable="sh" addsourcefile="false" dest="${input}">
      <arg value="parrot.sh" />
      <targetfile suffix=",x"/>
      <fileset refid="xyz" />
      <globmapper from="*" to="*.bar"/>
    </apply>
    <au:assertLogContains text="${x}.bar,x out" />
    <au:assertLogContains text="${y}.bar,x out" />
    <au:assertLogContains text="${z}.bar,x out" />
  </target>

  <target name="testRedirectorWithParallel" if="test.can.run" depends="xyz">
    <apply executable="sh" dest="${input}" parallel="true" addsourcefile="yes">
      <arg value="parrot.sh" />
      <targetfile/>
      <fileset refid="xyz" />
      <globmapper from="*" to="*.bar"/>
      <redirector output="${output}/all_out.txt" append="yes"/>
    </apply>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="x.bar out"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="x.bar err"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="x out"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="x err"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="y.bar out"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="y.bar err"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="y out"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="y err"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="z.bar out"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="z.bar err"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="z out"/>
    <au:assertResourceContains resource="${output}/all_out.txt"
                               value="z err"/>
  </target>
</project>