aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/etc/testcases/taskdefs/delete.xml
blob: d74c8babc37f80da26aee10f56f632f803721885 (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
<?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="delete-test" basedir="." default="test1">

  <import file="../buildfiletest-base.xml"/>


  <property name="dir" location="${output}" />
  <basename property="dirname" file="${output}"/>

  <macrodef name="expectabsent">
    <attribute name="target" default="${dir}"/>
    <sequential>
      <fileset id="detritus" dir="@{target}" erroronmissingdir="false"/>
      <fail message="@{target} still has: ${toString:detritus}">
        <condition>
          <available file="@{target}" />
        </condition>
    </fail>
    </sequential>
  </macrodef>

  <macrodef name="expectdirsonly">
    <sequential>
      <fail>
        <condition>
          <or>
            <resourcecount when="greater" count="0">
              <fileset dir="${dir}" />
            </resourcecount>
            <not>
              <resourcecount count="${srcdirs}">
                <dirset dir="${dir}" />
              </resourcecount>
            </not>
          </or>
        </condition>
      </fail>
    </sequential>
  </macrodef>

  <target name="init">
    <resourcecount property="srcdirs">
      <dirset dir="${basedir}" />
    </resourcecount>

    <resourcecount property="srcsize">
      <files includes="${basedir}/" />
    </resourcecount>

    <mkdir dir="${dir}" />

    <copy todir="${dir}">
      <fileset dir="${basedir}" excludes="${dirname},${dirname}/**" />
    </copy>
  </target>

  <target name="test1">
    <delete />
  </target>

  <target name="test2" depends="init">
    <delete file="${dir}" />
    <fail>
      <condition>
        <not>
          <resourcecount count="${srcsize}">
            <files includes="${dir}/" />
          </resourcecount>
        </not>
      </condition>
    </fail>
  </target>

  <target name="test4" depends="init">
    <delete dir="${dir}" />
    <expectabsent />
  </target>

  <target name="test5" depends="init">
    <delete dir="${dir}" includes="**" />
    <expectdirsonly />
  </target>

  <target name="test6" depends="init">
    <delete dir="${dir}" includes="**" includeemptydirs="true" />
    <expectabsent />
  </target>

  <target name="test7" depends="init">
    <delete>
      <fileset id="fs" dir="${dir}" />
    </delete>
    <expectdirsonly />
  </target>

  <target name="test8" depends="init">
    <delete includeemptydirs="true">
      <fileset dir="${dir}" />
    </delete>
    <expectabsent />
  </target>

  <target name="test9" depends="init">
    <delete>
      <files>
          <include name="${dir}/**"/>
      </files>
    </delete>
    <expectabsent />
  </target>

  <target name="test10">
    <delete>
      <filelist dir="${dir}" files="test10absentfile" />
    </delete>
  </target>

  <target name="test11">
    <delete failonerror="false">
      <fileset dir="thisdenotesadirectorythatwillneverexistblah" />
    </delete>
  </target>

  <target name="test12">
    <delete failonerror="false" includeemptydirs="true">
      <fileset dir="thisdenotesadirectorythatwillneverexistblah" />
    </delete>
  </target>

  <target name="test13" depends="init">
    <delete includeemptydirs="true">
      <fileset dir="${dir}" />
      <fileset dir="${dir}" />
    </delete>
    <expectabsent />
  </target>

  <target name="test14" depends="init">
	<delete quiet="false">
		<fileset dir="${dir}" />
		<fileset dir="${dir}" />
	</delete>
  </target>

  <target name="test15" depends="init">
	<delete quiet="true">
		<fileset dir="${dir}" />
		<fileset dir="${dir}" />
	</delete>
  </target>
  <!-- Bugzilla 40313 -->
  <target name="test16.init">
    <mkdir dir="${dir}/CVS"/>
    <touch file="${dir}/CVS/lala"/>
    <mkdir dir="${dir}/subdir"/>
  </target>

  <target name="test16" depends="test16.init">
    <delete defaultexcludes="false" dir="${dir}" includeemptydirs="true"/>
    <expectabsent/>
  </target>

  <target name="test17" depends="test16.init">
    <delete dir="${dir}" defaultexcludes="true" includeemptydirs="true"/>
    <fail message="file in CVS dir deleted">
      <condition>
        <not>
          <available file="${dir}/CVS/lala"/>
        </not>
      </condition>
    </fail>
    <expectabsent target="${dir}/subdir"/>
  </target>



</project>