aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/tests/antunit/taskdefs/dependset-test.xml
blob: 55252593c5dfb2b7eafcd221c9c7056e6380ec64 (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
<?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="dependset-test" xmlns:au="antlib:org.apache.ant.antunit" default="antunit">

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

  <target name="setUp">
    <mkdir dir="${input}" />
    <mkdir dir="${output}" />
  </target>

  <target name="testNoSourcesOrTargets">
    <au:expectfailure expectedMessage="At least one set of source resources must be specified">
      <dependset />
    </au:expectfailure>
  </target>

  <target name="testNoTargets">
    <au:expectfailure expectedMessage="At least one set of target files must be specified">
      <dependset>
        <srcfilelist dir="." files="test2.tmp" />
      </dependset>
    </au:expectfailure>
  </target>

  <target name="testNoSources">
    <au:expectfailure expectedMessage="At least one set of source resources must be specified">
      <dependset>
        <targetfileset dir="." includes="test3.tmp" />
      </dependset>
    </au:expectfailure>
  </target>

  <target name="testMissingTargets" depends="setUp">
    <touch file="${input}/test4.tmp" />
    <dependset>
      <srcfilelist dir="${input}" files="test4.tmp" />
      <targetfileset id="targetfs" dir="${output}" includes="i-do-not-exist" />
    </dependset>
    <au:assertLogDoesntContain text="Deleting all target files." level="verbose" />
  </target>

  <target name="testMoreRecentSourceFile" depends="setUp">
    <touch file="${output}/older.tmp" />
    <sleep seconds="3" />
    <touch file="${input}/newer.tmp" />
    <dependset>
      <srcfilelist dir="${input}" files="newer.tmp" />
      <targetfilelist dir="${output}" files="older.tmp" />
    </dependset>
    <au:assertLogContains text="older.tmp&quot; is oldest target file" level="verbose" />
    <au:assertLogContains text="newer.tmp&quot; is newest source" level="verbose" />
    <au:assertLogContains text="Deleting all target files." level="verbose" />
    <au:assertLogDoesntContain text="Deleting" level="info" />
    <au:assertFileDoesntExist file="${output}/older.tmp" />
  </target>

  <target name="testMoreRecentSourceFileVerbose" depends="setUp">
    <touch file="${output}/older.tmp" />
    <sleep seconds="3" />
    <touch file="${input}/newer.tmp" />
    <dependset verbose="true">
      <srcfilelist dir="${input}" files="newer.tmp" />
      <targetfilelist dir="${output}" files="older.tmp" />
    </dependset>
    <au:assertLogContains text="older.tmp&quot; is oldest target file" level="info" />
    <au:assertLogContains text="newer.tmp&quot; is newest source" level="info" />
    <au:assertLogContains text="Deleting all target files." level="verbose" />
    <au:assertLogContains text="Deleting" level="info" />
    <au:assertFileDoesntExist file="${output}/older.tmp" />
  </target>

  <target name="testMultipleFiles" depends="setUp">
    <touch file="${input}/sourceset_1.tmp" />
    <touch file="${output}/targetset_1.tmp" />
    <sleep seconds="3" />
    <touch file="${input}/sourceset_2.tmp" />
    <touch file="${output}/targetset_2.tmp" />
    <sleep seconds="2" />
    <dependset>
      <sources>
        <filelist dir="${input}" files="sourceset_1.tmp,sourceset_2.tmp" />
      </sources>
      <targets>
        <filelist dir="${output}/" files="targetset_1.tmp,targetset_2.tmp" />
      </targets>
    </dependset>
    <au:assertLogContains text="targetset_1.tmp&quot; is oldest target file" level="verbose" />
    <au:assertLogContains text="sourceset_2.tmp&quot; is newest source" level="verbose" />
    <au:assertLogContains text="Deleting all target files." level="verbose" />
    <au:assertLogDoesntContain text="Deleting" level="info" />
    <au:assertFileDoesntExist file="${output}/targetset_1.tmp" />
    <au:assertFileDoesntExist file="${output}/targetset_2.tmp" />
  </target>

  <target name="testMultipleFilesVerbose" depends="setUp">
    <touch file="${input}/sourceset_1.tmp" />
    <touch file="${output}/targetset_1.tmp" />
    <sleep seconds="3" />
    <touch file="${input}/sourceset_2.tmp" />
    <touch file="${output}/targetset_2.tmp" />
    <sleep seconds="2" />
    <dependset verbose="true">
      <sources>
        <filelist dir="${input}" files="sourceset_1.tmp,sourceset_2.tmp" />
      </sources>
      <targets>
        <filelist dir="${output}/" files="targetset_1.tmp,targetset_2.tmp" />
      </targets>
    </dependset>
    <au:assertLogContains text="targetset_1.tmp&quot; is oldest target file" level="info" />
    <au:assertLogContains text="sourceset_2.tmp&quot; is newest source" level="info" />
    <au:assertLogContains text="Deleting all target files." level="verbose" />
    <au:assertLogContains text="Deleting" level="info" />
    <au:assertFileDoesntExist file="${output}/targetset_1.tmp" />
    <au:assertFileDoesntExist file="${output}/targetset_2.tmp" />
  </target>

  <target name="testMissingSourceResource" depends="setUp">
    <touch file="${output}/older.tmp" />
    <dependset>
      <sources>
        <propertyresource name="thereisnosuchproperty" />
      </sources>
      <targets>
        <filelist dir="${output}" files="older.tmp" />
      </targets>
    </dependset>
    <au:assertLogContains text="1 nonexistent sources" level="verbose" />
    <au:assertLogContains text="Deleting all target files." level="verbose" />
    <au:assertLogDoesntContain text="Deleting" level="info" />
    <au:assertLogDoesntContain text="Expected source propertyresource &quot;null&quot; is missing." level="info" />
    <au:assertFileDoesntExist file="${output}/older.tmp" />
  </target>

  <target name="testMissingSourceResourceVerbose" depends="setUp">
    <touch file="${output}/older.tmp" />
    <dependset verbose="true">
      <sources>
        <propertyresource name="thereisnosuchproperty" />
      </sources>
      <targets>
        <filelist dir="${output}" files="older.tmp" />
      </targets>
    </dependset>
    <au:assertLogContains text="1 nonexistent sources" level="verbose" />
    <au:assertLogContains text="Deleting all target files." level="verbose" />
    <au:assertLogContains text="Deleting" level="info" />
    <au:assertLogContains text="Expected source propertyresource &quot;null&quot; is missing." level="info" />
    <au:assertFileDoesntExist file="${output}/older.tmp" />
  </target>

  <target name="testExistingSourceResource" depends="setUp">
    <touch file="${output}/older.tmp" />
    <property name="foo" value="bar" />
    <dependset>
      <sources>
        <propertyresource name="foo" />
      </sources>
      <targets>
        <filelist dir="${output}" files="older.tmp" />
      </targets>
    </dependset>
    <au:assertLogDoesntContain text="Deleting all target files." level="verbose" />
    <au:assertFileExists file="${output}/older.tmp" />
  </target>

  <target name="testMissingTargetDirectory" depends="setUp">
    <au:assertFalse>
      <available file="${output}/test9dir" type="dir" />
    </au:assertFalse>
    <touch file="${input}/test9.tmp" />
    <dependset>
      <srcfileset dir="." includes="test9.tmp" />
      <targetfileset dir="${output}/test9dir" />
    </dependset>
    <au:assertLogDoesntContain text="Deleting all target files." level="verbose" />
  </target>

</project>