View | Details | Raw Unified | Return to bug 28505
Collapse All | Expand All

(-)src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java (-1 / +27 lines)
Lines 17-22 Link Here
17
17
18
package org.apache.tools.ant.taskdefs;
18
package org.apache.tools.ant.taskdefs;
19
19
20
import java.io.File;
21
import java.io.IOException;
22
20
import org.apache.tools.ant.BuildException;
23
import org.apache.tools.ant.BuildException;
21
import org.apache.tools.ant.BuildFileTest;
24
import org.apache.tools.ant.BuildFileTest;
22
import org.apache.tools.ant.Location;
25
import org.apache.tools.ant.Location;
Lines 109-113 Link Here
109
            "Did not see build exception",
112
            "Did not see build exception",
110
            false);
113
            false);
111
    }
114
    }
112
}
113
115
116
    public void testSymlinkedImports() throws Exception {
117
        String ln = "/usr/bin/ln";
118
        if (!new File(ln).exists()) {
119
            ln = "/bin/ln";
120
        }
121
        if (!new File(ln).exists()) {
122
            // Running on Windows or something, so skip it.
123
            return;
124
        }
125
        String symlink = "src/etc/testcases/taskdefs/import/symlinks/d3b";
126
        if (Runtime.getRuntime().exec(new String[] {ln, "-s", "d3a", symlink}).waitFor() != 0) {
127
            throw new IOException("'" + ln + " -s d3a " + symlink + "' failed");
128
        }
129
        try {
130
            configureProject(
131
                "src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml");
132
            assertPropertyEquals("ant.file.p2", new File("src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml").getAbsolutePath());
133
            assertPropertyEquals("ant.file.p3", new File("src/etc/testcases/taskdefs/import/symlinks/d3b/p3.xml").getAbsolutePath());
134
        } finally {
135
            new File(symlink).delete();
136
        }
137
    }
138
139
}
(-)src/main/org/apache/tools/ant/taskdefs/ImportTask.java (-9 lines)
Lines 131-138 Link Here
131
            }
131
            }
132
        }
132
        }
133
133
134
        importedFile = new File(getPath(importedFile));
135
136
        if (importStack.contains(importedFile)) {
134
        if (importStack.contains(importedFile)) {
137
            getProject().log(
135
            getProject().log(
138
                "Skipped already imported file:\n   "
136
                "Skipped already imported file:\n   "
Lines 148-158 Link Here
148
        }
146
        }
149
    }
147
    }
150
148
151
    private static String getPath(File file) {
152
        try {
153
            return file.getCanonicalPath();
154
        } catch (IOException e) {
155
            return file.getAbsolutePath();
156
        }
157
    }
158
}
149
}

Return to bug 28505