With includes="alpha/beta/gamma", gamma must not be scanned if beta is a symlink. Fix is in the works. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274832 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,9 +1,6 @@ | |||||
| <project name="directoryscanner-test" basedir="."> | <project name="directoryscanner-test" basedir="."> | ||||
| <property name="tmp.dir" location="tmp"/> | <property name="tmp.dir" location="tmp"/> | ||||
| <target name="setup"> | <target name="setup"> | ||||
| <mkdir dir="${tmp.dir}"/> | |||||
| <mkdir dir="${tmp.dir}/alpha"/> | |||||
| <mkdir dir="${tmp.dir}/alpha/beta"/> | |||||
| <mkdir dir="${tmp.dir}/alpha/beta/gamma"/> | <mkdir dir="${tmp.dir}/alpha/beta/gamma"/> | ||||
| <touch file="${tmp.dir}/alpha/beta/gamma/gamma.xml"/> | <touch file="${tmp.dir}/alpha/beta/gamma/gamma.xml"/> | ||||
| <touch file="${tmp.dir}/alpha/beta/beta.xml"/> | <touch file="${tmp.dir}/alpha/beta/beta.xml"/> | ||||
| @@ -11,4 +8,11 @@ | |||||
| <target name="cleanup"> | <target name="cleanup"> | ||||
| <delete dir="${tmp.dir}" quiet="true"/> | <delete dir="${tmp.dir}" quiet="true"/> | ||||
| </target> | </target> | ||||
| <target name="symlink-setup" depends="setup"> | |||||
| <mkdir dir="${tmp.dir}/epsilon/gamma"/> | |||||
| <delete dir="${tmp.dir}/alpha/beta"/> | |||||
| <symlink link="${tmp.dir}/alpha/beta" resource="${tmp.dir}/epsilon"/> | |||||
| <touch file="${tmp.dir}/alpha/beta/gamma/gamma.xml"/> | |||||
| </target> | |||||
| </project> | </project> | ||||
| @@ -144,6 +144,34 @@ public class DirectoryScannerTest extends BuildFileTest { | |||||
| new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); | new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); | ||||
| } | } | ||||
| public void testAllowSymlinks() { | |||||
| if (!supportsSymlinks) { | |||||
| return; | |||||
| } | |||||
| getProject().executeTarget("symlink-setup"); | |||||
| DirectoryScanner ds = new DirectoryScanner(); | |||||
| ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); | |||||
| ds.setIncludes(new String[] {"alpha/beta/gamma/"}); | |||||
| ds.scan(); | |||||
| compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, | |||||
| new String[] {"alpha/beta/gamma"}); | |||||
| } | |||||
| public void testProhibitSymlinks() { | |||||
| if (!supportsSymlinks) { | |||||
| return; | |||||
| } | |||||
| getProject().executeTarget("symlink-setup"); | |||||
| DirectoryScanner ds = new DirectoryScanner(); | |||||
| ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); | |||||
| ds.setIncludes(new String[] {"alpha/beta/gamma/"}); | |||||
| ds.setFollowSymlinks(false); | |||||
| ds.scan(); | |||||
| compareFiles(ds, new String[] {}, new String[] {}); | |||||
| } | |||||
| // father and child pattern test | // father and child pattern test | ||||
| public void testOrderOfIncludePatternsIrrelevant() { | public void testOrderOfIncludePatternsIrrelevant() { | ||||
| String [] expectedFiles = {"alpha/beta/beta.xml", | String [] expectedFiles = {"alpha/beta/beta.xml", | ||||