You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dirscanner-symlinks-test.xml 5.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
  17. <import file="../antunit-base.xml"/>
  18. <target name="setUp">
  19. <property name="base" location="${input}/base"/>
  20. <mkdir dir="${base}"/>
  21. </target>
  22. <target name="checkOs">
  23. <condition property="unix"><os family="unix"/></condition>
  24. </target>
  25. <macrodef name="assertDirIsEmpty">
  26. <attribute name="dir" default="${output}"/>
  27. <sequential>
  28. <local name="resources"/>
  29. <resourcecount property="resources">
  30. <fileset dir="@{dir}"/>
  31. </resourcecount>
  32. <au:assertEquals expected="0" actual="${resources}"/>
  33. </sequential>
  34. </macrodef>
  35. <target name="testSymlinkToSiblingFollow"
  36. depends="checkOs, setUp, -sibling"
  37. if="unix">
  38. <copy todir="${output}">
  39. <fileset dir="${base}" followsymlinks="true"/>
  40. </copy>
  41. <au:assertFileExists file="${output}/B/file.txt"/>
  42. </target>
  43. <target name="testSymlinkToSiblingNoFollow"
  44. depends="checkOs, setUp, -sibling"
  45. if="unix">
  46. <copy todir="${output}">
  47. <fileset dir="${base}" followsymlinks="false"/>
  48. </copy>
  49. <au:assertFileDoesntExist file="${output}/B/file.txt"/>
  50. </target>
  51. <target name="testBasedirIsSymlinkFollow"
  52. depends="checkOs, setUp, -basedir-as-symlink"
  53. if="unix">
  54. <copy todir="${output}">
  55. <fileset dir="${base}" followsymlinks="true"/>
  56. </copy>
  57. <au:assertFileExists file="${output}/file.txt"/>
  58. </target>
  59. <target name="testBasedirIsSymlinkNoFollow"
  60. depends="checkOs, setUp, -basedir-as-symlink"
  61. if="unix">
  62. <copy todir="${output}">
  63. <fileset dir="${base}" followsymlinks="false"/>
  64. </copy>
  65. <au:assertFileDoesntExist file="${output}/file.txt"/>
  66. </target>
  67. <target name="INFINITEtestLinkToParentFollow"
  68. depends="checkOs, setUp, -link-to-parent"
  69. if="unix">
  70. <copy todir="${output}">
  71. <fileset dir="${base}" followsymlinks="true"/>
  72. </copy>
  73. <symlink action="delete" link="${base}/A"/>
  74. <au:assertFileExists file="${output}/A/B/file.txt"/>
  75. </target>
  76. <target name="testLinkToParentFollowWithInclude"
  77. depends="checkOs, setUp, -link-to-parent"
  78. if="unix">
  79. <copy todir="${output}">
  80. <fileset dir="${base}" followsymlinks="true">
  81. <include name="A/B/*"/>
  82. </fileset>
  83. </copy>
  84. <symlink action="delete" link="${base}/A"/>
  85. <au:assertFileExists file="${output}/A/B/file.txt"/>
  86. </target>
  87. <!-- supposed to fail? -->
  88. <target name="testLinkToParentFollowWithIncludeMultiFollow"
  89. depends="checkOs, setUp, -link-to-parent"
  90. if="unix">
  91. <copy todir="${output}">
  92. <fileset dir="${base}" followsymlinks="true">
  93. <include name="A/base/A/B/*"/>
  94. </fileset>
  95. </copy>
  96. <symlink action="delete" link="${base}/A"/>
  97. <au:assertFileExists file="${output}/A/base/A/B/file.txt"/>
  98. </target>
  99. <target name="testLinkToParentNoFollow"
  100. depends="checkOs, setUp, -link-to-parent"
  101. if="unix">
  102. <copy todir="${output}">
  103. <fileset dir="${base}" followsymlinks="false"/>
  104. </copy>
  105. <symlink action="delete" link="${base}/A"/>
  106. <au:assertFileDoesntExist file="${output}/A/B/file.txt"/>
  107. </target>
  108. <target name="INFINITE testSillyLoopFollow"
  109. depends="checkOs, setUp, -silly-loop"
  110. if="unix">
  111. <copy todir="${output}">
  112. <fileset dir="${base}" followsymlinks="true"/>
  113. </copy>
  114. <symlink action="delete" link="${base}"/>
  115. <assertDirIsEmpty/>
  116. </target>
  117. <target name="testSillyLoopNoFollow"
  118. depends="checkOs, setUp, -silly-loop"
  119. if="unix">
  120. <copy todir="${output}">
  121. <fileset dir="${base}" followsymlinks="false"/>
  122. </copy>
  123. <symlink action="delete" link="${base}"/>
  124. <au:assertFileDoesntExist file="${output}"/>
  125. </target>
  126. <target name="-sibling" if="unix">
  127. <mkdir dir="${base}/A"/>
  128. <touch file="${base}/A/file.txt"/>
  129. <symlink link="${base}/B" resource="${base}/A"/>
  130. </target>
  131. <target name="-basedir-as-symlink" if="unix">
  132. <delete dir="${base}"/>
  133. <mkdir dir="${input}/realdir"/>
  134. <touch file="${input}/realdir/file.txt"/>
  135. <symlink link="${base}" resource="${input}/realdir"/>
  136. </target>
  137. <target name="-link-to-parent" if="unix">
  138. <mkdir dir="${input}/B"/>
  139. <touch file="${input}/B/file.txt"/>
  140. <symlink link="${base}/A" resource="${input}"/>
  141. </target>
  142. <target name="-silly-loop" if="unix">
  143. <delete dir="${base}"/>
  144. <symlink link="${base}" resource="${input}"/>
  145. </target>
  146. </project>